aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/kdrive
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/kdrive
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/kdrive')
-rw-r--r--xorg-server/hw/kdrive/ephyr/XF86dri.c1275
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.c1465
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.h105
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr_draw.c76
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdri.c328
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdri.h77
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.c1480
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.h10
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrglxext.c1434
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostglx.c666
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostglx.h59
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c51
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h26
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c1053
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h237
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrinit.c494
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrproxyext.c82
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrvideo.c2491
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.c1798
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.h240
-rw-r--r--xorg-server/hw/kdrive/ephyr/os.c22
-rw-r--r--xorg-server/hw/kdrive/ephyr/xf86dri.h80
-rw-r--r--xorg-server/hw/kdrive/fake/fake.c922
-rw-r--r--xorg-server/hw/kdrive/fake/fake.h85
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbdev.c789
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbinit.c98
-rw-r--r--xorg-server/hw/kdrive/linux/evdev.c1058
-rw-r--r--xorg-server/hw/kdrive/linux/keyboard.c1015
-rw-r--r--xorg-server/hw/kdrive/linux/linux.c385
-rw-r--r--xorg-server/hw/kdrive/linux/mouse.c956
-rw-r--r--xorg-server/hw/kdrive/linux/ms.c134
-rw-r--r--xorg-server/hw/kdrive/linux/ps2.c142
-rw-r--r--xorg-server/hw/kdrive/linux/tslib.c48
-rw-r--r--xorg-server/hw/kdrive/src/kcmap.c159
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.c1205
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.h555
-rw-r--r--xorg-server/hw/kdrive/src/kinfo.c71
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c1358
-rw-r--r--xorg-server/hw/kdrive/src/kmode.c542
-rw-r--r--xorg-server/hw/kdrive/src/kshadow.c43
-rw-r--r--xorg-server/hw/kdrive/src/kxv.c3797
-rw-r--r--xorg-server/hw/kdrive/src/kxv.h318
42 files changed, 13292 insertions, 13937 deletions
diff --git a/xorg-server/hw/kdrive/ephyr/XF86dri.c b/xorg-server/hw/kdrive/ephyr/XF86dri.c
index 247580e0a..74bf67678 100644
--- a/xorg-server/hw/kdrive/ephyr/XF86dri.c
+++ b/xorg-server/hw/kdrive/ephyr/XF86dri.c
@@ -1,628 +1,647 @@
-/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
-/**************************************************************************
-
-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 file has been copied from the mesa source tree and a little bit
- * modified by:
- *
- * Dodji Seketeli <dodji@openedhand.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-/*
- * including some server headers (like kdrive-config.h)
- * might define the macro _XSERVER64
- * on 64 bits machines. That macro must _NOT_ be defined for Xlib
- * client code, otherwise bad things happen.
- * So let's undef that macro if necessary.
- */
-#ifdef _XSERVER64
-#undef _XSERVER64
-#endif
-
-/* THIS IS NOT AN X CONSORTIUM STANDARD */
-
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include <GL/glx.h>
-#include "xf86dri.h"
-#include <X11/dri/xf86driproto.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
-
-Bool XF86DRIOpenFullScreen(Display *dpy, int screen, Drawable drawable);
-Bool XF86DRICloseFullScreen(Display *dpy, int screen, Drawable drawable);
-
-Bool XF86DRIQueryExtension (Display *dpy, int *event_basep, int *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;
- }
-}
-
-Bool XF86DRIQueryVersion(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;
-}
-
-Bool
-XF86DRIQueryDirectRenderingCapable (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;
-}
-
-Bool
-XF86DRIOpenConnection (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 *)calloc(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;
-}
-
-Bool XF86DRIAuthConnection(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;
-}
-
-Bool XF86DRICloseConnection(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;
-}
-
-Bool XF86DRIGetClientDriverName(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 *)calloc(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;
-}
-
-Bool XF86DRICreateContextWithConfig(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;
-}
-
-Bool XF86DRICreateContext(Display *dpy, int screen, Visual *visual,
- XID *context, drm_context_t *hHWContext)
-{
- return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
- context, hHWContext );
-}
-
-GLboolean XF86DRIDestroyContext( Display *dpy, int screen, XID context)
-{
- 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;
-}
-
-GLboolean
-XF86DRICreateDrawable (Display *dpy, int screen,
- XID drawable, drm_drawable_t * hHWDrawable)
-{
- 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;
-}
-
-static int noopErrorHandler(Display *dpy, XErrorEvent *xerr)
-{
- return 0;
-}
-
-GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen,
- XID drawable )
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIDestroyDrawableReq *req;
- int (*oldXErrorHandler)(Display *, XErrorEvent *);
-
- TRACE("DestroyDrawable...");
- XF86DRICheckExtension (dpy, info, False);
-
- /* This is called from the DRI driver, which used call it like this
- *
- * if (windowExists(drawable))
- * destroyDrawable(drawable);
- *
- * which is a textbook race condition - the window may disappear
- * from the server between checking for its existance and
- * destroying it. Instead we change the semantics of
- * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
- * the windows is gone, by wrapping the destroy call in an error
- * handler. */
-
- XSync(dpy, GL_FALSE);
- oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
-
- LockDisplay(dpy);
- GetReq(XF86DRIDestroyDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIDestroyDrawable;
- req->screen = screen;
- req->drawable = drawable;
- UnlockDisplay(dpy);
- SyncHandle();
-
- XSetErrorHandler(oldXErrorHandler);
-
- TRACE("DestroyDrawable... return True");
- return True;
-}
-
-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=NULL;
- 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 *)calloc(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 *)calloc(len, 1);
- if (*pBackClipRects)
- _XRead(dpy, (char*)*pBackClipRects, len);
- } else {
- *pBackClipRects = NULL;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return True");
- return True;
-}
-
-Bool
-XF86DRIGetDeviceInfo (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 *)calloc(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;
-}
-
-Bool
-XF86DRIOpenFullScreen(Display *dpy, int screen, Drawable drawable)
-{
- /* This function and the underlying X protocol are deprecated.
- */
- (void) dpy;
- (void) screen;
- (void) drawable;
- return False;
-}
-
-Bool
-XF86DRICloseFullScreen(Display *dpy, int screen, Drawable drawable)
-{
- /* This function and the underlying X protocol are deprecated.
- */
- (void) dpy;
- (void) screen;
- (void) drawable;
- return True;
-}
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+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 file has been copied from the mesa source tree and a little bit
+ * modified by:
+ *
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+/*
+ * including some server headers (like kdrive-config.h)
+ * might define the macro _XSERVER64
+ * on 64 bits machines. That macro must _NOT_ be defined for Xlib
+ * client code, otherwise bad things happen.
+ * So let's undef that macro if necessary.
+ */
+#ifdef _XSERVER64
+#undef _XSERVER64
+#endif
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <GL/glx.h>
+#include "xf86dri.h"
+#include <X11/dri/xf86driproto.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
+Bool
+XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable);
+Bool
+XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable);
+
+Bool
+XF86DRIQueryExtension(Display * dpy, int *event_basep, int *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;
+ }
+}
+
+Bool
+XF86DRIQueryVersion(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;
+}
+
+Bool
+XF86DRIQueryDirectRenderingCapable(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;
+}
+
+Bool
+XF86DRIOpenConnection(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 *) calloc(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;
+}
+
+Bool
+XF86DRIAuthConnection(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;
+}
+
+Bool
+XF86DRICloseConnection(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;
+}
+
+Bool
+XF86DRIGetClientDriverName(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 *) calloc(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;
+}
+
+Bool
+XF86DRICreateContextWithConfig(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;
+}
+
+Bool
+XF86DRICreateContext(Display * dpy, int screen, Visual * visual,
+ XID *context, drm_context_t * hHWContext)
+{
+ return XF86DRICreateContextWithConfig(dpy, screen, visual->visualid,
+ context, hHWContext);
+}
+
+GLboolean
+XF86DRIDestroyContext(Display * dpy, int screen, XID context)
+{
+ 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;
+}
+
+GLboolean
+XF86DRICreateDrawable(Display * dpy, int screen,
+ XID drawable, drm_drawable_t * hHWDrawable)
+{
+ 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;
+}
+
+static int
+noopErrorHandler(Display * dpy, XErrorEvent * xerr)
+{
+ return 0;
+}
+
+GLboolean
+XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIDestroyDrawableReq *req;
+ int (*oldXErrorHandler) (Display *, XErrorEvent *);
+
+ TRACE("DestroyDrawable...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ /* This is called from the DRI driver, which used call it like this
+ *
+ * if (windowExists(drawable))
+ * destroyDrawable(drawable);
+ *
+ * which is a textbook race condition - the window may disappear
+ * from the server between checking for its existance and
+ * destroying it. Instead we change the semantics of
+ * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
+ * the windows is gone, by wrapping the destroy call in an error
+ * handler. */
+
+ XSync(dpy, GL_FALSE);
+ oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSetErrorHandler(oldXErrorHandler);
+
+ TRACE("DestroyDrawable... return True");
+ return True;
+}
+
+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 = NULL;
+ 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 *) calloc(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 *) calloc(len, 1);
+ if (*pBackClipRects)
+ _XRead(dpy, (char *) *pBackClipRects, len);
+ }
+ else {
+ *pBackClipRects = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return True");
+ return True;
+}
+
+Bool
+XF86DRIGetDeviceInfo(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 *) calloc(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;
+}
+
+Bool
+XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable)
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return False;
+}
+
+Bool
+XF86DRICloseFullScreen(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/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index 7ebf1c253..8eda539aa 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -36,11 +36,12 @@
#include "ephyrdri.h"
#include "ephyrdriext.h"
#include "ephyrglxext.h"
-#endif /* XF86DRI */
+#endif /* XF86DRI */
#include "xkbsrv.h"
extern int KdTsPhyScreen;
+
#ifdef GLXEXT
extern Bool noGlxVisualInit;
#endif
@@ -48,179 +49,162 @@ extern Bool noGlxVisualInit;
KdKeyboardInfo *ephyrKbd;
KdPointerInfo *ephyrMouse;
EphyrKeySyms ephyrKeySyms;
-Bool ephyrNoDRI=FALSE ;
-Bool ephyrNoXV=FALSE ;
+Bool ephyrNoDRI = FALSE;
+Bool ephyrNoXV = FALSE;
static int mouseState = 0;
static Rotation ephyrRandr = RR_Rotate_0;
typedef struct _EphyrInputPrivate {
- Bool enabled;
+ Bool enabled;
} EphyrKbdPrivate, EphyrPointerPrivate;
-Bool EphyrWantGrayScale = 0;
-
+Bool EphyrWantGrayScale = 0;
Bool
-ephyrInitialize (KdCardInfo *card, EphyrPriv *priv)
+ephyrInitialize(KdCardInfo * card, EphyrPriv * priv)
{
- OsSignal(SIGUSR1, hostx_handle_signal);
-
- priv->base = 0;
- priv->bytes_per_line = 0;
- return TRUE;
+ OsSignal(SIGUSR1, hostx_handle_signal);
+
+ priv->base = 0;
+ priv->bytes_per_line = 0;
+ return TRUE;
}
Bool
-ephyrCardInit (KdCardInfo *card)
+ephyrCardInit(KdCardInfo * card)
{
- EphyrPriv *priv;
-
- priv = (EphyrPriv *) malloc(sizeof (EphyrPriv));
- if (!priv)
- return FALSE;
-
- if (!ephyrInitialize (card, priv))
- {
- free(priv);
- return FALSE;
+ EphyrPriv *priv;
+
+ priv = (EphyrPriv *) malloc(sizeof(EphyrPriv));
+ if (!priv)
+ return FALSE;
+
+ if (!ephyrInitialize(card, priv)) {
+ free(priv);
+ return FALSE;
}
- card->driver = priv;
-
- return TRUE;
+ card->driver = priv;
+
+ return TRUE;
}
Bool
-ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
+ephyrScreenInitialize(KdScreenInfo * screen, EphyrScrPriv * scrpriv)
{
- int width = 640, height = 480;
- CARD32 redMask, greenMask, blueMask;
-
- if (hostx_want_screen_size(screen, &width, &height)
- || !screen->width || !screen->height)
- {
- screen->width = width;
- screen->height = height;
+ int width = 640, height = 480;
+ CARD32 redMask, greenMask, blueMask;
+
+ if (hostx_want_screen_size(screen, &width, &height)
+ || !screen->width || !screen->height) {
+ screen->width = width;
+ screen->height = height;
}
- if (EphyrWantGrayScale)
- screen->fb.depth = 8;
-
- if (screen->fb.depth && screen->fb.depth != hostx_get_depth())
- {
- if (screen->fb.depth < hostx_get_depth()
- && (screen->fb.depth == 24 || screen->fb.depth == 16
- || screen->fb.depth == 8))
- {
- hostx_set_server_depth(screen, screen->fb.depth);
- }
- else
- ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
+ if (EphyrWantGrayScale)
+ screen->fb.depth = 8;
+
+ if (screen->fb.depth && screen->fb.depth != hostx_get_depth()) {
+ if (screen->fb.depth < hostx_get_depth()
+ && (screen->fb.depth == 24 || screen->fb.depth == 16
+ || screen->fb.depth == 8)) {
+ hostx_set_server_depth(screen, screen->fb.depth);
+ }
+ else
+ ErrorF
+ ("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
}
-
- screen->fb.depth = hostx_get_server_depth(screen);
- screen->rate = 72;
-
- if (screen->fb.depth <= 8)
- {
- if (EphyrWantGrayScale)
- screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale));
- else
- screen->fb.visuals = ((1 << StaticGray) |
- (1 << GrayScale) |
- (1 << StaticColor) |
- (1 << PseudoColor) |
- (1 << TrueColor) |
- (1 << DirectColor));
-
- screen->fb.redMask = 0x00;
- screen->fb.greenMask = 0x00;
- screen->fb.blueMask = 0x00;
- screen->fb.depth = 8;
- screen->fb.bitsPerPixel = 8;
+
+ screen->fb.depth = hostx_get_server_depth(screen);
+ screen->rate = 72;
+
+ if (screen->fb.depth <= 8) {
+ if (EphyrWantGrayScale)
+ screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale));
+ else
+ screen->fb.visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) | (1 << DirectColor));
+
+ screen->fb.redMask = 0x00;
+ screen->fb.greenMask = 0x00;
+ screen->fb.blueMask = 0x00;
+ screen->fb.depth = 8;
+ screen->fb.bitsPerPixel = 8;
}
- else
- {
- screen->fb.visuals = (1 << TrueColor);
-
- if (screen->fb.depth <= 15)
- {
- screen->fb.depth = 15;
- screen->fb.bitsPerPixel = 16;
- }
- else if (screen->fb.depth <= 16)
- {
- screen->fb.depth = 16;
- screen->fb.bitsPerPixel = 16;
- }
- else if (screen->fb.depth <= 24)
- {
- screen->fb.depth = 24;
- screen->fb.bitsPerPixel = 32;
- }
- else if (screen->fb.depth <= 30)
- {
- screen->fb.depth = 30;
- screen->fb.bitsPerPixel = 32;
- }
- else
- {
- ErrorF("\nXephyr: Unsupported screen depth %d\n",
- screen->fb.depth);
- return FALSE;
- }
-
- hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
-
- screen->fb.redMask = (Pixel) redMask;
- screen->fb.greenMask = (Pixel) greenMask;
- screen->fb.blueMask = (Pixel) blueMask;
+ else {
+ screen->fb.visuals = (1 << TrueColor);
+
+ if (screen->fb.depth <= 15) {
+ screen->fb.depth = 15;
+ screen->fb.bitsPerPixel = 16;
+ }
+ else if (screen->fb.depth <= 16) {
+ screen->fb.depth = 16;
+ screen->fb.bitsPerPixel = 16;
+ }
+ else if (screen->fb.depth <= 24) {
+ screen->fb.depth = 24;
+ screen->fb.bitsPerPixel = 32;
+ }
+ else if (screen->fb.depth <= 30) {
+ screen->fb.depth = 30;
+ screen->fb.bitsPerPixel = 32;
+ }
+ else {
+ ErrorF("\nXephyr: Unsupported screen depth %d\n", screen->fb.depth);
+ return FALSE;
+ }
+
+ hostx_get_visual_masks(screen, &redMask, &greenMask, &blueMask);
+
+ screen->fb.redMask = (Pixel) redMask;
+ screen->fb.greenMask = (Pixel) greenMask;
+ screen->fb.blueMask = (Pixel) blueMask;
}
-
- scrpriv->randr = screen->randr;
- return ephyrMapFramebuffer (screen);
+ scrpriv->randr = screen->randr;
+
+ return ephyrMapFramebuffer(screen);
}
Bool
-ephyrScreenInit (KdScreenInfo *screen)
+ephyrScreenInit(KdScreenInfo * screen)
{
- EphyrScrPriv *scrpriv;
-
- scrpriv = calloc(1, sizeof (EphyrScrPriv));
+ EphyrScrPriv *scrpriv;
- if (!scrpriv)
- return FALSE;
+ scrpriv = calloc(1, sizeof(EphyrScrPriv));
+
+ if (!scrpriv)
+ return FALSE;
- screen->driver = scrpriv;
+ screen->driver = scrpriv;
- if (!ephyrScreenInitialize (screen, scrpriv))
- {
- screen->driver = 0;
- free(scrpriv);
- return FALSE;
+ if (!ephyrScreenInitialize(screen, scrpriv)) {
+ screen->driver = 0;
+ free(scrpriv);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
-
-void*
-ephyrWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure)
+
+void *
+ephyrWindowLinear(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset, int mode, CARD32 *size, void *closure)
{
- KdScreenPriv(pScreen);
- EphyrPriv *priv = pScreenPriv->card->driver;
-
- if (!pScreenPriv->enabled)
- return 0;
-
- *size = priv->bytes_per_line;
- return priv->base + row * priv->bytes_per_line + offset;
+ KdScreenPriv(pScreen);
+ EphyrPriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+
+ *size = priv->bytes_per_line;
+ return priv->base + row * priv->bytes_per_line + offset;
}
/**
@@ -228,529 +212,509 @@ ephyrWindowLinear (ScreenPtr pScreen,
* buffer so that fakexa has space to put offscreen pixmaps.
*/
int
-ephyrBufferHeight(KdScreenInfo *screen)
+ephyrBufferHeight(KdScreenInfo * screen)
{
int buffer_height;
+
if (ephyrFuncs.initAccel == NULL)
- buffer_height = screen->height;
+ buffer_height = screen->height;
else
- buffer_height = 3 * screen->height;
+ buffer_height = 3 * screen->height;
return buffer_height;
}
-
Bool
-ephyrMapFramebuffer (KdScreenInfo *screen)
+ephyrMapFramebuffer(KdScreenInfo * screen)
{
- EphyrScrPriv *scrpriv = screen->driver;
- EphyrPriv *priv = screen->card->driver;
- KdPointerMatrix m;
- int buffer_height;
-
- EPHYR_LOG("screen->width: %d, screen->height: %d index=%d",
- screen->width, screen->height, screen->mynum);
-
- /*
- * Use the rotation last applied to ourselves (in the Xephyr case the fb
- * coordinate system moves independently of the pointer coordiante system).
- */
- KdComputePointerMatrix (&m, ephyrRandr, screen->width, screen->height);
- KdSetPointerMatrix (&m);
-
- priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
-
- buffer_height = ephyrBufferHeight(screen);
-
- priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
-
- if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
- {
- scrpriv->shadow = FALSE;
-
- screen->fb.byteStride = priv->bytes_per_line;
- screen->fb.pixelStride = screen->width;
- screen->fb.frameBuffer = (CARD8 *) (priv->base);
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrPriv *priv = screen->card->driver;
+ KdPointerMatrix m;
+ int buffer_height;
+
+ EPHYR_LOG("screen->width: %d, screen->height: %d index=%d",
+ screen->width, screen->height, screen->mynum);
+
+ /*
+ * Use the rotation last applied to ourselves (in the Xephyr case the fb
+ * coordinate system moves independently of the pointer coordiante system).
+ */
+ KdComputePointerMatrix(&m, ephyrRandr, screen->width, screen->height);
+ KdSetPointerMatrix(&m);
+
+ priv->bytes_per_line =
+ ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
+
+ buffer_height = ephyrBufferHeight(screen);
+
+ priv->base =
+ hostx_screen_init(screen, screen->width, screen->height, buffer_height);
+
+ if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All)) {
+ scrpriv->shadow = FALSE;
+
+ screen->fb.byteStride = priv->bytes_per_line;
+ screen->fb.pixelStride = screen->width;
+ screen->fb.frameBuffer = (CARD8 *) (priv->base);
}
- else
- {
- /* Rotated/Reflected so we need to use shadow fb */
- scrpriv->shadow = TRUE;
-
- EPHYR_LOG("allocing shadow");
-
- KdShadowFbAlloc (screen,
- scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
+ else {
+ /* Rotated/Reflected so we need to use shadow fb */
+ scrpriv->shadow = TRUE;
+
+ EPHYR_LOG("allocing shadow");
+
+ KdShadowFbAlloc(screen,
+ scrpriv->randr & (RR_Rotate_90 | RR_Rotate_270));
}
-
- return TRUE;
+
+ return TRUE;
}
void
-ephyrSetScreenSizes (ScreenPtr pScreen)
+ephyrSetScreenSizes(ScreenPtr pScreen)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
-
- if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- pScreen->width = screen->width;
- pScreen->height = screen->height;
- pScreen->mmWidth = screen->width_mm;
- pScreen->mmHeight = screen->height_mm;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0 | RR_Rotate_180)) {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
}
- else
- {
- pScreen->width = screen->height;
- pScreen->height = screen->width;
- pScreen->mmWidth = screen->height_mm;
- pScreen->mmHeight = screen->width_mm;
+ else {
+ pScreen->width = screen->height;
+ pScreen->height = screen->width;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
}
}
Bool
-ephyrUnmapFramebuffer (KdScreenInfo *screen)
+ephyrUnmapFramebuffer(KdScreenInfo * screen)
{
- EphyrScrPriv *scrpriv = screen->driver;
-
- if (scrpriv->shadow)
- KdShadowFbFree (screen);
-
- /* Note, priv->base will get freed when XImage recreated */
-
- return TRUE;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->shadow)
+ KdShadowFbFree(screen);
+
+ /* Note, priv->base will get freed when XImage recreated */
+
+ return TRUE;
}
-void
-ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
+void
+ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
-
- EPHYR_LOG("slow paint");
-
- /* FIXME: Slow Rotated/Reflected updates could be much
- * much faster efficiently updating via tranforming
- * pBuf->pDamage regions
- */
- shadowUpdateRotatePacked(pScreen, pBuf);
- hostx_paint_rect(screen, 0,0,0,0, screen->width, screen->height);
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+
+ EPHYR_LOG("slow paint");
+
+ /* FIXME: Slow Rotated/Reflected updates could be much
+ * much faster efficiently updating via tranforming
+ * pBuf->pDamage regions
+ */
+ shadowUpdateRotatePacked(pScreen, pBuf);
+ hostx_paint_rect(screen, 0, 0, 0, 0, screen->width, screen->height);
}
static void
-ephyrInternalDamageRedisplay (ScreenPtr pScreen)
+ephyrInternalDamageRedisplay(ScreenPtr pScreen)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- RegionPtr pRegion;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ RegionPtr pRegion;
- if (!scrpriv || !scrpriv->pDamage)
- return;
+ if (!scrpriv || !scrpriv->pDamage)
+ return;
- pRegion = DamageRegion (scrpriv->pDamage);
+ pRegion = DamageRegion(scrpriv->pDamage);
- if (RegionNotEmpty(pRegion))
- {
- int nbox;
- BoxPtr pbox;
+ if (RegionNotEmpty(pRegion)) {
+ int nbox;
+ BoxPtr pbox;
- nbox = RegionNumRects (pRegion);
- pbox = RegionRects (pRegion);
+ nbox = RegionNumRects(pRegion);
+ pbox = RegionRects(pRegion);
- while (nbox--)
- {
- hostx_paint_rect(screen,
- pbox->x1, pbox->y1,
- pbox->x1, pbox->y1,
- pbox->x2 - pbox->x1,
- pbox->y2 - pbox->y1);
- pbox++;
+ while (nbox--) {
+ hostx_paint_rect(screen,
+ pbox->x1, pbox->y1,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
+ pbox++;
}
- DamageEmpty (scrpriv->pDamage);
+ DamageEmpty(scrpriv->pDamage);
}
}
static void
-ephyrInternalDamageBlockHandler (pointer data,
- OSTimePtr pTimeout,
- pointer pRead)
+ephyrInternalDamageBlockHandler(pointer data, OSTimePtr pTimeout, pointer pRead)
{
- ScreenPtr pScreen = (ScreenPtr) data;
-
- ephyrInternalDamageRedisplay (pScreen);
+ ScreenPtr pScreen = (ScreenPtr) data;
+
+ ephyrInternalDamageRedisplay(pScreen);
}
static void
-ephyrInternalDamageWakeupHandler (pointer data, int i, pointer LastSelectMask)
+ephyrInternalDamageWakeupHandler(pointer data, int i, pointer LastSelectMask)
{
- /* FIXME: Not needed ? */
+ /* FIXME: Not needed ? */
}
Bool
-ephyrSetInternalDamage (ScreenPtr pScreen)
+ephyrSetInternalDamage(ScreenPtr pScreen)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- PixmapPtr pPixmap = NULL;
-
- scrpriv->pDamage = DamageCreate ((DamageReportFunc) 0,
- (DamageDestroyFunc) 0,
- DamageReportNone,
- TRUE,
- pScreen,
- pScreen);
-
- if (!RegisterBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
- ephyrInternalDamageWakeupHandler,
- (pointer) pScreen))
- return FALSE;
-
- pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
-
- DamageRegister (&pPixmap->drawable, scrpriv->pDamage);
-
- return TRUE;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ PixmapPtr pPixmap = NULL;
+
+ scrpriv->pDamage = DamageCreate((DamageReportFunc) 0,
+ (DamageDestroyFunc) 0,
+ DamageReportNone, TRUE, pScreen, pScreen);
+
+ if (!RegisterBlockAndWakeupHandlers(ephyrInternalDamageBlockHandler,
+ ephyrInternalDamageWakeupHandler,
+ (pointer) pScreen))
+ return FALSE;
+
+ pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ DamageRegister(&pPixmap->drawable, scrpriv->pDamage);
+
+ return TRUE;
}
void
-ephyrUnsetInternalDamage (ScreenPtr pScreen)
+ephyrUnsetInternalDamage(ScreenPtr pScreen)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- PixmapPtr pPixmap = NULL;
-
- pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
- DamageUnregister (&pPixmap->drawable, scrpriv->pDamage);
- DamageDestroy (scrpriv->pDamage);
-
- RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
- ephyrInternalDamageWakeupHandler,
- (pointer) pScreen);
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ PixmapPtr pPixmap = NULL;
+
+ pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+ DamageUnregister(&pPixmap->drawable, scrpriv->pDamage);
+ DamageDestroy(scrpriv->pDamage);
+
+ RemoveBlockAndWakeupHandlers(ephyrInternalDamageBlockHandler,
+ ephyrInternalDamageWakeupHandler,
+ (pointer) pScreen);
}
#ifdef RANDR
Bool
-ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+ephyrRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- RRScreenSizePtr pSize;
- Rotation randr;
- int n = 0;
-
- struct { int width, height; } sizes[] =
- {
- { 1600, 1200 },
- { 1400, 1050 },
- { 1280, 960 },
- { 1280, 1024 },
- { 1152, 864 },
- { 1024, 768 },
- { 832, 624 },
- { 800, 600 },
- { 720, 400 },
- { 480, 640 },
- { 640, 480 },
- { 640, 400 },
- { 320, 240 },
- { 240, 320 },
- { 160, 160 },
- { 0, 0 }
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n = 0;
+
+ struct {
+ int width, height;
+ } sizes[] = {
+ {
+ 1600, 1200}, {
+ 1400, 1050}, {
+ 1280, 960}, {
+ 1280, 1024}, {
+ 1152, 864}, {
+ 1024, 768}, {
+ 832, 624}, {
+ 800, 600}, {
+ 720, 400}, {
+ 480, 640}, {
+ 640, 480}, {
+ 640, 400}, {
+ 320, 240}, {
+ 240, 320}, {
+ 160, 160}, {
+ 0, 0}
};
- EPHYR_LOG("mark");
-
- *rotations = RR_Rotate_All|RR_Reflect_All;
-
- if (!hostx_want_preexisting_window (screen)
- && !hostx_want_fullscreen ()) /* only if no -parent switch */
- {
- while (sizes[n].width != 0 && sizes[n].height != 0)
- {
- RRRegisterSize (pScreen,
- sizes[n].width,
- sizes[n].height,
- (sizes[n].width * screen->width_mm)/screen->width,
- (sizes[n].height *screen->height_mm)/screen->height
- );
- n++;
- }
+ EPHYR_LOG("mark");
+
+ *rotations = RR_Rotate_All | RR_Reflect_All;
+
+ if (!hostx_want_preexisting_window(screen)
+ && !hostx_want_fullscreen()) { /* only if no -parent switch */
+ while (sizes[n].width != 0 && sizes[n].height != 0) {
+ RRRegisterSize(pScreen,
+ sizes[n].width,
+ sizes[n].height,
+ (sizes[n].width * screen->width_mm) / screen->width,
+ (sizes[n].height * screen->height_mm) /
+ screen->height);
+ n++;
+ }
}
-
- pSize = RRRegisterSize (pScreen,
- screen->width,
- screen->height,
- screen->width_mm,
- screen->height_mm);
-
- randr = KdSubRotation (scrpriv->randr, screen->randr);
-
- RRSetCurrentConfig (pScreen, randr, 0, pSize);
-
- return TRUE;
+
+ pSize = RRRegisterSize(pScreen,
+ screen->width,
+ screen->height, screen->width_mm, screen->height_mm);
+
+ randr = KdSubRotation(scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig(pScreen, randr, 0, pSize);
+
+ return TRUE;
}
Bool
-ephyrRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize)
+ephyrRandRSetConfig(ScreenPtr pScreen,
+ Rotation randr, int rate, RRScreenSizePtr pSize)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
- Bool wasEnabled = pScreenPriv->enabled;
- EphyrScrPriv oldscr;
- int oldwidth, oldheight, oldmmwidth, oldmmheight;
- Bool oldshadow;
- int newwidth, newheight;
-
- if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- newwidth = pSize->width;
- newheight = pSize->height;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ EphyrScrPriv oldscr;
+ int oldwidth, oldheight, oldmmwidth, oldmmheight;
+ Bool oldshadow;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0 | RR_Rotate_180)) {
+ newwidth = pSize->width;
+ newheight = pSize->height;
}
- else
- {
- newwidth = pSize->height;
- newheight = pSize->width;
+ else {
+ newwidth = pSize->height;
+ newheight = pSize->width;
}
-
- if (wasEnabled)
- KdDisableScreen (pScreen);
-
- oldscr = *scrpriv;
-
- oldwidth = screen->width;
- oldheight = screen->height;
- oldmmwidth = pScreen->mmWidth;
- oldmmheight = pScreen->mmHeight;
- oldshadow = scrpriv->shadow;
-
- /*
- * Set new configuration
- */
-
- /*
- * We need to store the rotation value for pointer coords transformation;
- * though initially the pointer and fb rotation are identical, when we map
- * the fb, the screen will be reinitialized and return into an unrotated
- * state (presumably the HW is taking care of the rotation of the fb), but the
- * pointer still needs to be transformed.
- */
- ephyrRandr = KdAddRotation (screen->randr, randr);
- scrpriv->randr = ephyrRandr;
-
- ephyrUnmapFramebuffer (screen);
-
- screen->width = newwidth;
- screen->height = newheight;
-
- if (!ephyrMapFramebuffer (screen))
- goto bail4;
-
- /* FIXME below should go in own call */
-
- if (oldshadow)
- KdShadowUnset (screen->pScreen);
- else
- ephyrUnsetInternalDamage(screen->pScreen);
-
- if (scrpriv->shadow)
- {
- if (!KdShadowSet (screen->pScreen,
- scrpriv->randr,
- ephyrShadowUpdate,
- ephyrWindowLinear))
- goto bail4;
+
+ if (wasEnabled)
+ KdDisableScreen(pScreen);
+
+ oldscr = *scrpriv;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+ oldshadow = scrpriv->shadow;
+
+ /*
+ * Set new configuration
+ */
+
+ /*
+ * We need to store the rotation value for pointer coords transformation;
+ * though initially the pointer and fb rotation are identical, when we map
+ * the fb, the screen will be reinitialized and return into an unrotated
+ * state (presumably the HW is taking care of the rotation of the fb), but the
+ * pointer still needs to be transformed.
+ */
+ ephyrRandr = KdAddRotation(screen->randr, randr);
+ scrpriv->randr = ephyrRandr;
+
+ ephyrUnmapFramebuffer(screen);
+
+ screen->width = newwidth;
+ screen->height = newheight;
+
+ if (!ephyrMapFramebuffer(screen))
+ goto bail4;
+
+ /* FIXME below should go in own call */
+
+ if (oldshadow)
+ KdShadowUnset(screen->pScreen);
+ else
+ ephyrUnsetInternalDamage(screen->pScreen);
+
+ if (scrpriv->shadow) {
+ if (!KdShadowSet(screen->pScreen,
+ scrpriv->randr, ephyrShadowUpdate, ephyrWindowLinear))
+ goto bail4;
}
- else
- {
- /* Without shadow fb ( non rotated ) we need
- * to use damage to efficiently update display
- * via signal regions what to copy from 'fb'.
- */
- if (!ephyrSetInternalDamage(screen->pScreen))
- goto bail4;
+ else {
+ /* Without shadow fb ( non rotated ) we need
+ * to use damage to efficiently update display
+ * via signal regions what to copy from 'fb'.
+ */
+ if (!ephyrSetInternalDamage(screen->pScreen))
+ goto bail4;
}
-
- ephyrSetScreenSizes (screen->pScreen);
-
- /*
- * Set frame buffer mapping
- */
- (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
- pScreen->width,
- pScreen->height,
- screen->fb.depth,
- screen->fb.bitsPerPixel,
- screen->fb.byteStride,
- screen->fb.frameBuffer);
-
- /* set the subpixel order */
-
- KdSetSubpixelOrder (pScreen, scrpriv->randr);
-
- if (wasEnabled)
- KdEnableScreen (pScreen);
-
- return TRUE;
-
+
+ ephyrSetScreenSizes(screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap(pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb.depth,
+ screen->fb.bitsPerPixel,
+ screen->fb.byteStride,
+ screen->fb.frameBuffer);
+
+ /* set the subpixel order */
+
+ KdSetSubpixelOrder(pScreen, scrpriv->randr);
+
+ if (wasEnabled)
+ KdEnableScreen(pScreen);
+
+ return TRUE;
+
bail4:
- EPHYR_LOG("bailed");
-
- ephyrUnmapFramebuffer (screen);
- *scrpriv = oldscr;
- (void) ephyrMapFramebuffer (screen);
-
- pScreen->width = oldwidth;
- pScreen->height = oldheight;
- pScreen->mmWidth = oldmmwidth;
- pScreen->mmHeight = oldmmheight;
-
- if (wasEnabled)
- KdEnableScreen (pScreen);
- return FALSE;
+ EPHYR_LOG("bailed");
+
+ ephyrUnmapFramebuffer(screen);
+ *scrpriv = oldscr;
+ (void) ephyrMapFramebuffer(screen);
+
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+ if (wasEnabled)
+ KdEnableScreen(pScreen);
+ return FALSE;
}
Bool
-ephyrRandRInit (ScreenPtr pScreen)
+ephyrRandRInit(ScreenPtr pScreen)
{
- rrScrPrivPtr pScrPriv;
-
- if (!RRScreenInit (pScreen))
- return FALSE;
-
- pScrPriv = rrGetScrPriv(pScreen);
- pScrPriv->rrGetInfo = ephyrRandRGetInfo;
- pScrPriv->rrSetConfig = ephyrRandRSetConfig;
- return TRUE;
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit(pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = ephyrRandRGetInfo;
+ pScrPriv->rrSetConfig = ephyrRandRSetConfig;
+ return TRUE;
}
#endif
Bool
-ephyrCreateColormap (ColormapPtr pmap)
+ephyrCreateColormap(ColormapPtr pmap)
{
- return fbInitializeColormap (pmap);
+ return fbInitializeColormap(pmap);
}
Bool
-ephyrInitScreen (ScreenPtr pScreen)
+ephyrInitScreen(ScreenPtr pScreen)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
- EPHYR_LOG ("pScreen->myNum:%d\n", pScreen->myNum) ;
- hostx_set_screen_number (screen, pScreen->myNum);
- hostx_set_win_title (screen, "(ctrl+shift grabs mouse and keyboard)") ;
- pScreen->CreateColormap = ephyrCreateColormap;
+ EPHYR_LOG("pScreen->myNum:%d\n", pScreen->myNum);
+ hostx_set_screen_number(screen, pScreen->myNum);
+ hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
+ pScreen->CreateColormap = ephyrCreateColormap;
#ifdef XV
- if (!ephyrNoXV) {
- if (!ephyrInitVideo (pScreen)) {
- EPHYR_LOG_ERROR ("failed to initialize xvideo\n") ;
- } else {
- EPHYR_LOG ("initialized xvideo okay\n") ;
- }
- }
+ if (!ephyrNoXV) {
+ if (!ephyrInitVideo(pScreen)) {
+ EPHYR_LOG_ERROR("failed to initialize xvideo\n");
+ }
+ else {
+ EPHYR_LOG("initialized xvideo okay\n");
+ }
+ }
#endif /*XV*/
-
#ifdef XF86DRI
- if (!ephyrNoDRI && !hostx_has_dri ()) {
- EPHYR_LOG ("host x does not support DRI. Disabling DRI forwarding\n") ;
- ephyrNoDRI = TRUE ;
+ if (!ephyrNoDRI && !hostx_has_dri()) {
+ EPHYR_LOG("host x does not support DRI. Disabling DRI forwarding\n");
+ ephyrNoDRI = TRUE;
#ifdef GLXEXT
- noGlxVisualInit = FALSE ;
+ noGlxVisualInit = FALSE;
#endif
- }
- if (!ephyrNoDRI) {
- ephyrDRIExtensionInit (pScreen) ;
- ephyrHijackGLXExtension () ;
- }
+ }
+ if (!ephyrNoDRI) {
+ ephyrDRIExtensionInit(pScreen);
+ ephyrHijackGLXExtension();
+ }
#endif
#ifdef GLXEXT
- if (ephyrNoDRI) {
- noGlxVisualInit = FALSE ;
- }
+ if (ephyrNoDRI) {
+ noGlxVisualInit = FALSE;
+ }
#endif
- return TRUE;
+ return TRUE;
}
Bool
-ephyrFinishInitScreen (ScreenPtr pScreen)
+ephyrFinishInitScreen(ScreenPtr pScreen)
{
- /* FIXME: Calling this even if not using shadow.
- * Seems harmless enough. But may be safer elsewhere.
- */
- if (!shadowSetup (pScreen))
- return FALSE;
+ /* FIXME: Calling this even if not using shadow.
+ * Seems harmless enough. But may be safer elsewhere.
+ */
+ if (!shadowSetup(pScreen))
+ return FALSE;
#ifdef RANDR
- if (!ephyrRandRInit (pScreen))
- return FALSE;
+ if (!ephyrRandRInit(pScreen))
+ return FALSE;
#endif
- return TRUE;
+ return TRUE;
}
Bool
-ephyrCreateResources (ScreenPtr pScreen)
+ephyrCreateResources(ScreenPtr pScreen)
{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- EphyrScrPriv *scrpriv = screen->driver;
-
- EPHYR_LOG("mark pScreen=%p mynum=%d shadow=%d",
- pScreen, pScreen->myNum, scrpriv->shadow);
-
- if (scrpriv->shadow)
- return KdShadowSet (pScreen,
- scrpriv->randr,
- ephyrShadowUpdate,
- ephyrWindowLinear);
- else
- return ephyrSetInternalDamage(pScreen);
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ EPHYR_LOG("mark pScreen=%p mynum=%d shadow=%d",
+ pScreen, pScreen->myNum, scrpriv->shadow);
+
+ if (scrpriv->shadow)
+ return KdShadowSet(pScreen,
+ scrpriv->randr,
+ ephyrShadowUpdate, ephyrWindowLinear);
+ else
+ return ephyrSetInternalDamage(pScreen);
}
void
-ephyrPreserve (KdCardInfo *card)
+ephyrPreserve(KdCardInfo * card)
{
}
Bool
-ephyrEnable (ScreenPtr pScreen)
+ephyrEnable(ScreenPtr pScreen)
{
- return TRUE;
+ return TRUE;
}
Bool
-ephyrDPMS (ScreenPtr pScreen, int mode)
+ephyrDPMS(ScreenPtr pScreen, int mode)
{
- return TRUE;
+ return TRUE;
}
void
-ephyrDisable (ScreenPtr pScreen)
+ephyrDisable(ScreenPtr pScreen)
{
}
void
-ephyrRestore (KdCardInfo *card)
+ephyrRestore(KdCardInfo * card)
{
}
void
-ephyrScreenFini (KdScreenInfo *screen)
+ephyrScreenFini(KdScreenInfo * screen)
{
- EphyrScrPriv *scrpriv = screen->driver;
+ EphyrScrPriv *scrpriv = screen->driver;
+
if (scrpriv->shadow) {
- KdShadowFbFree (screen);
+ KdShadowFbFree(screen);
}
free(screen->driver);
screen->driver = NULL;
@@ -764,99 +728,99 @@ void
ephyrUpdateModifierState(unsigned int state)
{
- DeviceIntPtr pDev = inputInfo.keyboard;
- KeyClassPtr keyc = pDev->key;
- int i;
- CARD8 mask;
- int xkb_state;
-
- if (!pDev)
- return;
+ DeviceIntPtr pDev = inputInfo.keyboard;
+ KeyClassPtr keyc = pDev->key;
+ int i;
+ CARD8 mask;
+ int xkb_state;
- xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
- state = state & 0xff;
+ if (!pDev)
+ return;
- if (xkb_state == state)
- return;
-
- for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
- int key;
+ xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
+ state = state & 0xff;
- /* Modifier is down, but shouldn't be
- */
- if ((xkb_state & mask) && !(state & mask)) {
- int count = keyc->modifierKeyCount[i];
+ if (xkb_state == state)
+ return;
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- if (key_is_down(pDev, key, KEY_PROCESSED))
- KdEnqueueKeyboardEvent (ephyrKbd, key, TRUE);
+ for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
+ int key;
- if (--count == 0)
- break;
- }
- }
+ /* Modifier is down, but shouldn't be
+ */
+ if ((xkb_state & mask) && !(state & mask)) {
+ int count = keyc->modifierKeyCount[i];
- /* Modifier shoud be down, but isn't
- */
- if (!(xkb_state & mask) && (state & mask))
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- KdEnqueueKeyboardEvent (ephyrKbd, key, FALSE);
- break;
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
+ if (key_is_down(pDev, key, KEY_PROCESSED))
+ KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE);
+
+ if (--count == 0)
+ break;
+ }
}
- }
+
+ /* Modifier shoud be down, but isn't
+ */
+ if (!(xkb_state & mask) && (state & mask))
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
+ KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE);
+ break;
+ }
+ }
}
static void
-ephyrBlockSigio (void)
+ephyrBlockSigio(void)
{
sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, 0);
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_BLOCK, &set, 0);
}
static void
-ephyrUnblockSigio (void)
+ephyrUnblockSigio(void)
{
sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, 0);
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_UNBLOCK, &set, 0);
}
static Bool
ephyrCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
{
- return FALSE;
+ return FALSE;
}
static void
-ephyrCrossScreen (ScreenPtr pScreen, Bool entering)
+ephyrCrossScreen(ScreenPtr pScreen, Bool entering)
{
}
-int ephyrCurScreen; /*current event screen*/
+int ephyrCurScreen; /*current event screen */
static void
-ephyrWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+ephyrWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- ephyrBlockSigio ();
+ ephyrBlockSigio();
ephyrCurScreen = pScreen->myNum;
- miPointerWarpCursor (inputInfo.pointer, pScreen, x, y);
- ephyrUnblockSigio ();
+ miPointerWarpCursor(inputInfo.pointer, pScreen, x, y);
+
+ ephyrUnblockSigio();
}
-miPointerScreenFuncRec ephyrPointerScreenFuncs =
-{
- ephyrCursorOffScreen,
- ephyrCrossScreen,
- ephyrWarpCursor,
- NULL,
- NULL
+miPointerScreenFuncRec ephyrPointerScreenFuncs = {
+ ephyrCursorOffScreen,
+ ephyrCrossScreen,
+ ephyrWarpCursor,
+ NULL,
+ NULL
};
#ifdef XF86DRI
@@ -875,198 +839,192 @@ miPointerScreenFuncRec ephyrPointerScreenFuncs =
* expose events and send those events to clients.
*/
static void
-ephyrExposePairedWindow (int a_remote)
+ephyrExposePairedWindow(int a_remote)
{
EphyrWindowPair *pair = NULL;
RegionRec reg;
ScreenPtr screen;
- if (!findWindowPairFromRemote (a_remote, &pair)) {
- EPHYR_LOG ("did not find a pair for this window\n");
- return;
+ if (!findWindowPairFromRemote(a_remote, &pair)) {
+ EPHYR_LOG("did not find a pair for this window\n");
+ return;
}
screen = pair->local->drawable.pScreen;
RegionNull(&reg);
RegionCopy(&reg, &pair->local->clipList);
- screen->WindowExposures (pair->local, &reg, NullRegion);
+ screen->WindowExposures(pair->local, &reg, NullRegion);
RegionUninit(&reg);
}
-#endif /* XF86DRI */
+#endif /* XF86DRI */
void
ephyrPoll(void)
{
- EphyrHostXEvent ev;
+ EphyrHostXEvent ev;
- while (hostx_get_event(&ev))
- {
- switch (ev.type)
- {
+ while (hostx_get_event(&ev)) {
+ switch (ev.type) {
case EPHYR_EV_MOUSE_MOTION:
- if (!ephyrMouse ||
- !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
- EPHYR_LOG ("skipping mouse motion:%d\n", ephyrCurScreen) ;
- continue;
- }
- {
- if (ev.data.mouse_motion.screen >=0
- && (ephyrCurScreen != ev.data.mouse_motion.screen))
- {
- EPHYR_LOG ("warping mouse cursor. "
- "cur_screen%d, motion_screen:%d\n",
- ephyrCurScreen, ev.data.mouse_motion.screen) ;
- if (ev.data.mouse_motion.screen >= 0)
- {
- ephyrWarpCursor
- (inputInfo.pointer, screenInfo.screens[ev.data.mouse_motion.screen],
- ev.data.mouse_motion.x,
- ev.data.mouse_motion.y );
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *) ephyrMouse->driverPrivate)->enabled) {
+ EPHYR_LOG("skipping mouse motion:%d\n", ephyrCurScreen);
+ continue;
+ }
+ {
+ if (ev.data.mouse_motion.screen >= 0
+ && (ephyrCurScreen != ev.data.mouse_motion.screen)) {
+ EPHYR_LOG("warping mouse cursor. "
+ "cur_screen%d, motion_screen:%d\n",
+ ephyrCurScreen, ev.data.mouse_motion.screen);
+ if (ev.data.mouse_motion.screen >= 0) {
+ ephyrWarpCursor
+ (inputInfo.pointer,
+ screenInfo.screens[ev.data.mouse_motion.screen],
+ ev.data.mouse_motion.x, ev.data.mouse_motion.y);
}
- }
- else
- {
- int x=0, y=0;
+ }
+ else {
+ int x = 0, y = 0;
+
#ifdef XF86DRI
- EphyrWindowPair *pair = NULL;
+ EphyrWindowPair *pair = NULL;
#endif
- EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ;
- x = ev.data.mouse_motion.x;
- y = ev.data.mouse_motion.y;
- EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ;
+ EPHYR_LOG("enqueuing mouse motion:%d\n", ephyrCurScreen);
+ x = ev.data.mouse_motion.x;
+ y = ev.data.mouse_motion.y;
+ EPHYR_LOG("initial (x,y):(%d,%d)\n", x, y);
#ifdef XF86DRI
- EPHYR_LOG ("is this window peered by a gl drawable ?\n") ;
- if (findWindowPairFromRemote (ev.data.mouse_motion.window,
- &pair))
- {
- EPHYR_LOG ("yes, it is peered\n") ;
+ EPHYR_LOG("is this window peered by a gl drawable ?\n");
+ if (findWindowPairFromRemote(ev.data.mouse_motion.window,
+ &pair)) {
+ EPHYR_LOG("yes, it is peered\n");
x += pair->local->drawable.x;
y += pair->local->drawable.y;
}
- else
- {
- EPHYR_LOG ("no, it is not peered\n") ;
+ else {
+ EPHYR_LOG("no, it is not peered\n");
}
- EPHYR_LOG ("final (x,y):(%d,%d)\n", x, y) ;
+ EPHYR_LOG("final (x,y):(%d,%d)\n", x, y);
#endif
- KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0);
- }
- }
- break;
+ KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0);
+ }
+ }
+ break;
case EPHYR_EV_MOUSE_PRESS:
- if (!ephyrMouse ||
- !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
- EPHYR_LOG ("skipping mouse press:%d\n", ephyrCurScreen) ;
- continue;
- }
- EPHYR_LOG ("enqueuing mouse press:%d\n", ephyrCurScreen) ;
- ephyrUpdateModifierState(ev.key_state);
- mouseState |= ev.data.mouse_down.button_num;
- KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
- break;
-
- case EPHYR_EV_MOUSE_RELEASE:
- if (!ephyrMouse ||
- !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
- continue;
- ephyrUpdateModifierState(ev.key_state);
- mouseState &= ~ev.data.mouse_up.button_num;
- EPHYR_LOG ("enqueuing mouse release:%d\n", ephyrCurScreen) ;
- KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
- break;
-
- case EPHYR_EV_KEY_PRESS:
- if (!ephyrKbd ||
- !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
- continue;
- ephyrUpdateModifierState(ev.key_state);
- KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE);
- break;
-
- case EPHYR_EV_KEY_RELEASE:
- if (!ephyrKbd ||
- !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
- continue;
- ephyrUpdateModifierState(ev.key_state);
- KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
- break;
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *) ephyrMouse->driverPrivate)->enabled) {
+ EPHYR_LOG("skipping mouse press:%d\n", ephyrCurScreen);
+ continue;
+ }
+ EPHYR_LOG("enqueuing mouse press:%d\n", ephyrCurScreen);
+ ephyrUpdateModifierState(ev.key_state);
+ mouseState |= ev.data.mouse_down.button_num;
+ KdEnqueuePointerEvent(ephyrMouse, mouseState | KD_MOUSE_DELTA, 0, 0,
+ 0);
+ break;
+
+ case EPHYR_EV_MOUSE_RELEASE:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *) ephyrMouse->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ mouseState &= ~ev.data.mouse_up.button_num;
+ EPHYR_LOG("enqueuing mouse release:%d\n", ephyrCurScreen);
+ KdEnqueuePointerEvent(ephyrMouse, mouseState | KD_MOUSE_DELTA, 0, 0,
+ 0);
+ break;
+
+ case EPHYR_EV_KEY_PRESS:
+ if (!ephyrKbd ||
+ !((EphyrKbdPrivate *) ephyrKbd->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ KdEnqueueKeyboardEvent(ephyrKbd, ev.data.key_down.scancode, FALSE);
+ break;
+
+ case EPHYR_EV_KEY_RELEASE:
+ if (!ephyrKbd ||
+ !((EphyrKbdPrivate *) ephyrKbd->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ KdEnqueueKeyboardEvent(ephyrKbd, ev.data.key_up.scancode, TRUE);
+ break;
#ifdef XF86DRI
- case EPHYR_EV_EXPOSE:
- /*
- * We only receive expose events when the expose event have
- * be generated for a drawable that is a host X window managed
- * by Xephyr. Host X windows managed by Xephyr exists for instance
- * when Xephyr is asked to create a GL drawable in a DRI environment.
- */
- ephyrExposePairedWindow (ev.data.expose.window);
- break;
-#endif /* XF86DRI */
-
- default:
- break;
- }
+ case EPHYR_EV_EXPOSE:
+ /*
+ * We only receive expose events when the expose event have
+ * be generated for a drawable that is a host X window managed
+ * by Xephyr. Host X windows managed by Xephyr exists for instance
+ * when Xephyr is asked to create a GL drawable in a DRI environment.
+ */
+ ephyrExposePairedWindow(ev.data.expose.window);
+ break;
+#endif /* XF86DRI */
+
+ default:
+ break;
+ }
}
}
void
-ephyrCardFini (KdCardInfo *card)
+ephyrCardFini(KdCardInfo * card)
{
- EphyrPriv *priv = card->driver;
- free(priv);
+ EphyrPriv *priv = card->driver;
+
+ free(priv);
}
void
-ephyrGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
+ephyrGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
{
- /* XXX Not sure if this is right */
-
- EPHYR_LOG("mark");
-
- while (n--)
- {
- pdefs->red = 0;
- pdefs->green = 0;
- pdefs->blue = 0;
- pdefs++;
+ /* XXX Not sure if this is right */
+
+ EPHYR_LOG("mark");
+
+ while (n--) {
+ pdefs->red = 0;
+ pdefs->green = 0;
+ pdefs->blue = 0;
+ pdefs++;
}
}
void
-ephyrPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
+ephyrPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
{
- int min, max, p;
-
- /* XXX Not sure if this is right */
-
- min = 256;
- max = 0;
-
- while (n--)
- {
- p = pdefs->pixel;
- if (p < min)
- min = p;
- if (p > max)
- max = p;
-
- hostx_set_cmap_entry(p,
- pdefs->red >> 8,
- pdefs->green >> 8,
- pdefs->blue >> 8);
- pdefs++;
+ int min, max, p;
+
+ /* XXX Not sure if this is right */
+
+ min = 256;
+ max = 0;
+
+ while (n--) {
+ p = pdefs->pixel;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+
+ hostx_set_cmap_entry(p,
+ pdefs->red >> 8,
+ pdefs->green >> 8, pdefs->blue >> 8);
+ pdefs++;
}
}
/* Mouse calls */
static Status
-MouseInit (KdPointerInfo *pi)
+MouseInit(KdPointerInfo * pi)
{
pi->driverPrivate = (EphyrPointerPrivate *)
- calloc(sizeof(EphyrPointerPrivate), 1);
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ calloc(sizeof(EphyrPointerPrivate), 1);
+ ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE;
pi->nAxes = 3;
pi->nButtons = 32;
free(pi->name);
@@ -1084,23 +1042,23 @@ MouseInit (KdPointerInfo *pi)
}
static Status
-MouseEnable (KdPointerInfo *pi)
+MouseEnable(KdPointerInfo * pi)
{
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
+ ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = TRUE;
return Success;
}
static void
-MouseDisable (KdPointerInfo *pi)
+MouseDisable(KdPointerInfo * pi)
{
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ ((EphyrPointerPrivate *) pi->driverPrivate)->enabled = FALSE;
return;
}
static void
-MouseFini (KdPointerInfo *pi)
+MouseFini(KdPointerInfo * pi)
{
- ephyrMouse = NULL;
+ ephyrMouse = NULL;
return;
}
@@ -1116,55 +1074,54 @@ KdPointerDriver EphyrMouseDriver = {
/* Keyboard */
static Status
-EphyrKeyboardInit (KdKeyboardInfo *ki)
+EphyrKeyboardInit(KdKeyboardInfo * ki)
{
- ki->driverPrivate = (EphyrKbdPrivate *)
- calloc(sizeof(EphyrKbdPrivate), 1);
- hostx_load_keymap();
- if (!ephyrKeySyms.map) {
- ErrorF("Couldn't load keymap from host\n");
- return BadAlloc;
- }
- ki->minScanCode = ephyrKeySyms.minKeyCode;
- ki->maxScanCode = ephyrKeySyms.maxKeyCode;
- free(ki->name);
- ki->name = strdup("Xephyr virtual keyboard");
- ephyrKbd = ki;
- return Success;
+ ki->driverPrivate = (EphyrKbdPrivate *)
+ calloc(sizeof(EphyrKbdPrivate), 1);
+ hostx_load_keymap();
+ if (!ephyrKeySyms.map) {
+ ErrorF("Couldn't load keymap from host\n");
+ return BadAlloc;
+ }
+ ki->minScanCode = ephyrKeySyms.minKeyCode;
+ ki->maxScanCode = ephyrKeySyms.maxKeyCode;
+ free(ki->name);
+ ki->name = strdup("Xephyr virtual keyboard");
+ ephyrKbd = ki;
+ return Success;
}
static Status
-EphyrKeyboardEnable (KdKeyboardInfo *ki)
+EphyrKeyboardEnable(KdKeyboardInfo * ki)
{
- ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
+ ((EphyrKbdPrivate *) ki->driverPrivate)->enabled = TRUE;
return Success;
}
static void
-EphyrKeyboardDisable (KdKeyboardInfo *ki)
+EphyrKeyboardDisable(KdKeyboardInfo * ki)
{
- ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE;
+ ((EphyrKbdPrivate *) ki->driverPrivate)->enabled = FALSE;
}
static void
-EphyrKeyboardFini (KdKeyboardInfo *ki)
+EphyrKeyboardFini(KdKeyboardInfo * ki)
{
ephyrKbd = NULL;
return;
}
static void
-EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds)
+EphyrKeyboardLeds(KdKeyboardInfo * ki, int leds)
{
}
static void
-EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
+EphyrKeyboardBell(KdKeyboardInfo * ki, int volume, int frequency, int duration)
{
}
-
KdKeyboardDriver EphyrKeyboardDriver = {
"ephyr",
EphyrKeyboardInit,
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.h b/xorg-server/hw/kdrive/ephyr/ephyr.h
index 23848004c..be910c19e 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -30,7 +30,7 @@
#include <signal.h>
#include <libgen.h>
-#include "os.h" /* for OsSignal() */
+#include "os.h" /* for OsSignal() */
#include "kdrive.h"
#include "hostx.h"
#include "exa.h"
@@ -42,8 +42,8 @@
#include "damage.h"
typedef struct _ephyrPriv {
- CARD8 *base;
- int bytes_per_line;
+ CARD8 *base;
+ int bytes_per_line;
} EphyrPriv;
typedef struct _ephyrFakexaPriv {
@@ -61,9 +61,9 @@ typedef struct _ephyrFakexaPriv {
} EphyrFakexaPriv;
typedef struct _ephyrScrPriv {
- Rotation randr;
- Bool shadow;
- DamagePtr pDamage;
+ Rotation randr;
+ Bool shadow;
+ DamagePtr pDamage;
EphyrFakexaPriv *fakexa;
} EphyrScrPriv;
@@ -74,130 +74,125 @@ extern KdPointerInfo *ephyrMouse;
extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
Bool
-ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
+ ephyrInitialize(KdCardInfo * card, EphyrPriv * priv);
Bool
-ephyrCardInit (KdCardInfo *card);
+ ephyrCardInit(KdCardInfo * card);
Bool
-ephyrScreenInit (KdScreenInfo *screen);
+ ephyrScreenInit(KdScreenInfo * screen);
Bool
-ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv);
-
+ ephyrScreenInitialize(KdScreenInfo * screen, EphyrScrPriv * scrpriv);
+
Bool
-ephyrInitScreen (ScreenPtr pScreen);
+ ephyrInitScreen(ScreenPtr pScreen);
Bool
-ephyrFinishInitScreen (ScreenPtr pScreen);
+ ephyrFinishInitScreen(ScreenPtr pScreen);
Bool
-ephyrCreateResources (ScreenPtr pScreen);
+ ephyrCreateResources(ScreenPtr pScreen);
void
-ephyrPreserve (KdCardInfo *card);
+ ephyrPreserve(KdCardInfo * card);
Bool
-ephyrEnable (ScreenPtr pScreen);
+ ephyrEnable(ScreenPtr pScreen);
Bool
-ephyrDPMS (ScreenPtr pScreen, int mode);
+ ephyrDPMS(ScreenPtr pScreen, int mode);
void
-ephyrDisable (ScreenPtr pScreen);
+ ephyrDisable(ScreenPtr pScreen);
void
-ephyrRestore (KdCardInfo *card);
+ ephyrRestore(KdCardInfo * card);
void
-ephyrScreenFini (KdScreenInfo *screen);
+ ephyrScreenFini(KdScreenInfo * screen);
void
-ephyrCardFini (KdCardInfo *card);
+ ephyrCardFini(KdCardInfo * card);
void
-ephyrGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+ ephyrGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs);
void
-ephyrPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+ ephyrPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs);
Bool
-ephyrMapFramebuffer (KdScreenInfo *screen);
+ ephyrMapFramebuffer(KdScreenInfo * screen);
-void *
-ephyrWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure);
+void *ephyrWindowLinear(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset, int mode, CARD32 *size, void *closure);
void
-ephyrSetScreenSizes (ScreenPtr pScreen);
+ ephyrSetScreenSizes(ScreenPtr pScreen);
Bool
-ephyrUnmapFramebuffer (KdScreenInfo *screen);
+ ephyrUnmapFramebuffer(KdScreenInfo * screen);
void
-ephyrUnsetInternalDamage (ScreenPtr pScreen);
+ ephyrUnsetInternalDamage(ScreenPtr pScreen);
Bool
-ephyrSetInternalDamage (ScreenPtr pScreen);
+ ephyrSetInternalDamage(ScreenPtr pScreen);
Bool
-ephyrCreateColormap (ColormapPtr pmap);
+ ephyrCreateColormap(ColormapPtr pmap);
void
-ephyrPoll(void);
-
+ ephyrPoll(void);
+
#ifdef RANDR
Bool
-ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+ ephyrRandRGetInfo(ScreenPtr pScreen, Rotation * rotations);
Bool
-ephyrRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize);
+
+ephyrRandRSetConfig(ScreenPtr pScreen,
+ Rotation randr, int rate, RRScreenSizePtr pSize);
Bool
-ephyrRandRInit (ScreenPtr pScreen);
+ ephyrRandRInit(ScreenPtr pScreen);
-void
-ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
+void
+ ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf);
#endif
void
-ephyrUpdateModifierState(unsigned int state);
+ ephyrUpdateModifierState(unsigned int state);
extern KdPointerDriver EphyrMouseDriver;
-extern KdKeyboardDriver EphyrKeyboardDriver;
+extern KdKeyboardDriver EphyrKeyboardDriver;
-extern KdOsFuncs EphyrOsFuncs;
+extern KdOsFuncs EphyrOsFuncs;
extern Bool ephyrCursorInit(ScreenPtr pScreen);
extern void ephyrCursorEnable(ScreenPtr pScreen);
-extern int ephyrBufferHeight(KdScreenInfo *screen);
+extern int ephyrBufferHeight(KdScreenInfo * screen);
/* ephyr_draw.c */
Bool
-ephyrDrawInit(ScreenPtr pScreen);
+ ephyrDrawInit(ScreenPtr pScreen);
void
-ephyrDrawEnable(ScreenPtr pScreen);
+ ephyrDrawEnable(ScreenPtr pScreen);
void
-ephyrDrawDisable(ScreenPtr pScreen);
+ ephyrDrawDisable(ScreenPtr pScreen);
void
-ephyrDrawFini(ScreenPtr pScreen);
+ ephyrDrawFini(ScreenPtr pScreen);
/*ephyvideo.c*/
-Bool ephyrInitVideo(ScreenPtr pScreen) ;
+Bool ephyrInitVideo(ScreenPtr pScreen);
#endif
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr_draw.c b/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
index cf5f55394..5b8a1d504 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
@@ -64,7 +64,7 @@ ephyrPreparePipelinedAccess(PixmapPtr pPix, int index)
fakexa->saved_ptrs[index] = pPix->devPrivate.ptr;
if (pPix->devPrivate.ptr != NULL)
- return;
+ return;
pPix->devPrivate.ptr = fakexa->exa->memoryBase + exaGetPixmapOffset(pPix);
}
@@ -93,6 +93,7 @@ static Bool
ephyrPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
+
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
@@ -107,7 +108,8 @@ ephyrPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
tmpval[0].val = alu;
tmpval[1].val = pm;
tmpval[2].val = fg;
- ChangeGC(NullClient, fakexa->pGC, GCFunction | GCPlaneMask | GCForeground, tmpval);
+ ChangeGC(NullClient, fakexa->pGC, GCFunction | GCPlaneMask | GCForeground,
+ tmpval);
ValidateGC(&pPix->drawable, fakexa->pGC);
@@ -123,6 +125,7 @@ static void
ephyrSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
+
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
@@ -138,6 +141,7 @@ static void
ephyrDoneSolid(PixmapPtr pPix)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
+
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
@@ -154,9 +158,10 @@ ephyrDoneSolid(PixmapPtr pPix)
*/
static Bool
ephyrPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu,
- Pixel pm)
+ Pixel pm)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
+
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
@@ -172,7 +177,7 @@ ephyrPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu,
tmpval[0].val = alu;
tmpval[1].val = pm;
- ChangeGC (NullClient, fakexa->pGC, GCFunction | GCPlaneMask, tmpval);
+ ChangeGC(NullClient, fakexa->pGC, GCFunction | GCPlaneMask, tmpval);
ValidateGC(&pDst->drawable, fakexa->pGC);
@@ -188,13 +193,14 @@ static void
ephyrCopy(PixmapPtr pDst, int srcX, int srcY, int dstX, int dstY, int w, int h)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
+
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
EphyrFakexaPriv *fakexa = scrpriv->fakexa;
fbCopyArea(&fakexa->pSrc->drawable, &fakexa->pDst->drawable, fakexa->pGC,
- srcX, srcY, w, h, dstX, dstY);
+ srcX, srcY, w, h, dstX, dstY);
}
/**
@@ -204,12 +210,13 @@ static void
ephyrDoneCopy(PixmapPtr pDst)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
+
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EphyrScrPriv *scrpriv = screen->driver;
EphyrFakexaPriv *fakexa = scrpriv->fakexa;
- FreeScratchGC (fakexa->pGC);
+ FreeScratchGC(fakexa->pGC);
ephyrFinishPipelinedAccess(fakexa->pSrc, EXA_PREPARE_SRC);
ephyrFinishPipelinedAccess(fakexa->pDst, EXA_PREPARE_DEST);
@@ -222,13 +229,13 @@ ephyrDoneCopy(PixmapPtr pDst)
*/
static Bool
ephyrCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
- PicturePtr pDstPicture)
+ PicturePtr pDstPicture)
{
/* Exercise the component alpha helper, so fail on this case like a normal
* driver
*/
if (pMaskPicture && pMaskPicture->componentAlpha && op == PictOpOver)
- return FALSE;
+ return FALSE;
return TRUE;
}
@@ -238,8 +245,8 @@ ephyrCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
*/
static Bool
ephyrPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
- PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask,
- PixmapPtr pDst)
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask,
+ PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
@@ -249,7 +256,7 @@ ephyrPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST);
ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC);
if (pMask != NULL)
- ephyrPreparePipelinedAccess(pMask, EXA_PREPARE_MASK);
+ ephyrPreparePipelinedAccess(pMask, EXA_PREPARE_MASK);
fakexa->op = op;
fakexa->pSrcPicture = pSrcPicture;
@@ -269,7 +276,7 @@ ephyrPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
*/
static void
ephyrComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
- int dstX, int dstY, int w, int h)
+ int dstX, int dstY, int w, int h)
{
KdScreenPriv(pDst->drawable.pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
@@ -277,8 +284,8 @@ ephyrComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
EphyrFakexaPriv *fakexa = scrpriv->fakexa;
fbComposite(fakexa->op, fakexa->pSrcPicture, fakexa->pMaskPicture,
- fakexa->pDstPicture, srcX, srcY, maskX, maskY, dstX, dstY,
- w, h);
+ fakexa->pDstPicture, srcX, srcY, maskX, maskY, dstX, dstY,
+ w, h);
}
static void
@@ -290,7 +297,7 @@ ephyrDoneComposite(PixmapPtr pDst)
EphyrFakexaPriv *fakexa = scrpriv->fakexa;
if (fakexa->pMask != NULL)
- ephyrFinishPipelinedAccess(fakexa->pMask, EXA_PREPARE_MASK);
+ ephyrFinishPipelinedAccess(fakexa->pMask, EXA_PREPARE_MASK);
ephyrFinishPipelinedAccess(fakexa->pSrc, EXA_PREPARE_SRC);
ephyrFinishPipelinedAccess(fakexa->pDst, EXA_PREPARE_DEST);
}
@@ -300,7 +307,7 @@ ephyrDoneComposite(PixmapPtr pDst)
*/
static Bool
ephyrDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst,
- int dst_pitch)
+ int dst_pitch)
{
KdScreenPriv(pSrc->drawable.pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
@@ -310,7 +317,7 @@ ephyrDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst,
int src_pitch, cpp;
if (pSrc->drawable.bitsPerPixel < 8)
- return FALSE;
+ return FALSE;
ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC);
@@ -320,9 +327,9 @@ ephyrDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst,
src += y * src_pitch + x * cpp;
for (; h > 0; h--) {
- memcpy(dst, src, w * cpp);
- dst += dst_pitch;
- src += src_pitch;
+ memcpy(dst, src, w * cpp);
+ dst += dst_pitch;
+ src += src_pitch;
}
exaMarkSync(pSrc->drawable.pScreen);
@@ -337,7 +344,7 @@ ephyrDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst,
*/
static Bool
ephyrUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
- int src_pitch)
+ int src_pitch)
{
KdScreenPriv(pDst->drawable.pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
@@ -347,7 +354,7 @@ ephyrUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
int dst_pitch, cpp;
if (pDst->drawable.bitsPerPixel < 8)
- return FALSE;
+ return FALSE;
ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST);
@@ -357,9 +364,9 @@ ephyrUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
dst += y * dst_pitch + x * cpp;
for (; h > 0; h--) {
- memcpy(dst, src, w * cpp);
- dst += dst_pitch;
- src += src_pitch;
+ memcpy(dst, src, w * cpp);
+ dst += dst_pitch;
+ src += src_pitch;
}
exaMarkSync(pDst->drawable.pScreen);
@@ -433,12 +440,12 @@ ephyrDrawInit(ScreenPtr pScreen)
fakexa = calloc(1, sizeof(*fakexa));
if (fakexa == NULL)
- return FALSE;
+ return FALSE;
fakexa->exa = exaDriverAlloc();
if (fakexa->exa == NULL) {
- free(fakexa);
- return FALSE;
+ free(fakexa);
+ return FALSE;
}
fakexa->exa->memoryBase = (CARD8 *) (priv->base);
@@ -482,12 +489,13 @@ ephyrDrawInit(ScreenPtr pScreen)
success = exaDriverInit(pScreen, fakexa->exa);
if (success) {
- ErrorF("Initialized fake EXA acceleration\n");
- scrpriv->fakexa = fakexa;
- } else {
- ErrorF("Failed to initialize EXA\n");
- free(fakexa->exa);
- free(fakexa);
+ ErrorF("Initialized fake EXA acceleration\n");
+ scrpriv->fakexa = fakexa;
+ }
+ else {
+ ErrorF("Failed to initialize EXA\n");
+ free(fakexa->exa);
+ free(fakexa);
}
return success;
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdri.c b/xorg-server/hw/kdrive/ephyr/ephyrdri.c
index 932e46886..50554364c 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdri.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdri.c
@@ -43,244 +43,228 @@
#ifndef TRUE
#define TRUE 1
#endif /*TRUE*/
-
#ifndef FALSE
#define FALSE 0
#endif /*FALSE*/
-
-Bool
-ephyrDRIQueryDirectRenderingCapable (int a_screen, Bool *a_is_capable)
+ Bool
+ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable)
{
- Display *dpy=hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
- EPHYR_RETURN_VAL_IF_FAIL (a_is_capable, FALSE) ;
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRIQueryDirectRenderingCapable (dpy, DefaultScreen (dpy),
- a_is_capable) ;
- EPHYR_LOG ("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_is_capable, FALSE);
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRIQueryDirectRenderingCapable(dpy, DefaultScreen(dpy),
+ a_is_capable);
+ EPHYR_LOG("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok);
- return is_ok ;
+ return is_ok;
}
Bool
-ephyrDRIOpenConnection (int a_screen,
- drm_handle_t *a_sarea,
- char **a_bus_id_string)
+ephyrDRIOpenConnection(int a_screen,
+ drm_handle_t * a_sarea, char **a_bus_id_string)
{
- Display *dpy = hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
- EPHYR_RETURN_VAL_IF_FAIL (a_bus_id_string, FALSE) ;
- EPHYR_LOG ("enter. screen:%d\n", a_screen) ;
- is_ok = XF86DRIOpenConnection (dpy, DefaultScreen (dpy),
- a_sarea,
- a_bus_id_string) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_bus_id_string, FALSE);
+ EPHYR_LOG("enter. screen:%d\n", a_screen);
+ is_ok = XF86DRIOpenConnection(dpy, DefaultScreen(dpy),
+ a_sarea, a_bus_id_string);
if (*a_bus_id_string) {
- EPHYR_LOG ("leave. bus_id_string:%s, is_ok:%d\n",
- *a_bus_id_string, is_ok) ;
- } else {
- EPHYR_LOG ("leave. bus_id_string:null, is_ok:%d\n",
- is_ok) ;
+ EPHYR_LOG("leave. bus_id_string:%s, is_ok:%d\n",
+ *a_bus_id_string, is_ok);
+ }
+ else {
+ EPHYR_LOG("leave. bus_id_string:null, is_ok:%d\n", is_ok);
}
- return is_ok ;
+ return is_ok;
}
Bool
-ephyrDRIAuthConnection (int a_screen, drm_magic_t a_magic)
+ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic)
{
- Display *dpy = hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRIAuthConnection (dpy, DefaultScreen (dpy), a_magic) ;
- EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
- return is_ok ;
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRIAuthConnection(dpy, DefaultScreen(dpy), a_magic);
+ EPHYR_LOG("leave. is_ok:%d\n", is_ok);
+ return is_ok;
}
Bool
-ephyrDRICloseConnection (int a_screen)
+ephyrDRICloseConnection(int a_screen)
{
- Display *dpy = hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRICloseConnection (dpy, DefaultScreen (dpy)) ;
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRICloseConnection(dpy, DefaultScreen(dpy));
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
Bool
-ephyrDRIGetClientDriverName (int a_screen,
- int *a_ddx_driver_major_version,
- int *a_ddx_driver_minor_version,
- int *a_ddx_driver_patch_version,
- char ** a_client_driver_name)
+ephyrDRIGetClientDriverName(int a_screen,
+ int *a_ddx_driver_major_version,
+ int *a_ddx_driver_minor_version,
+ int *a_ddx_driver_patch_version,
+ char **a_client_driver_name)
{
- Display *dpy = hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
- EPHYR_RETURN_VAL_IF_FAIL (a_ddx_driver_major_version
- && a_ddx_driver_minor_version
- && a_ddx_driver_patch_version
- && a_client_driver_name,
- FALSE);
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRIGetClientDriverName (dpy, DefaultScreen (dpy),
- a_ddx_driver_major_version,
- a_ddx_driver_minor_version,
- a_ddx_driver_patch_version,
- a_client_driver_name) ;
- EPHYR_LOG ("major:%d, minor:%d, patch:%d, name:%s\n",
- *a_ddx_driver_major_version,
- *a_ddx_driver_minor_version,
- *a_ddx_driver_patch_version,
- *a_client_driver_name) ;
- EPHYR_LOG ("leave:%d\n", is_ok) ;
- return is_ok ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_ddx_driver_major_version
+ && a_ddx_driver_minor_version
+ && a_ddx_driver_patch_version
+ && a_client_driver_name, FALSE);
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRIGetClientDriverName(dpy, DefaultScreen(dpy),
+ a_ddx_driver_major_version,
+ a_ddx_driver_minor_version,
+ a_ddx_driver_patch_version,
+ a_client_driver_name);
+ EPHYR_LOG("major:%d, minor:%d, patch:%d, name:%s\n",
+ *a_ddx_driver_major_version,
+ *a_ddx_driver_minor_version,
+ *a_ddx_driver_patch_version, *a_client_driver_name);
+ EPHYR_LOG("leave:%d\n", is_ok);
+ return is_ok;
}
Bool
-ephyrDRICreateContext (int a_screen,
- int a_visual_id,
- XID *a_returned_ctxt_id,
- drm_context_t *a_hw_ctxt)
+ephyrDRICreateContext(int a_screen,
+ int a_visual_id,
+ XID *a_returned_ctxt_id, drm_context_t * a_hw_ctxt)
{
- Display *dpy = hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
Visual v;
- EPHYR_LOG ("enter. screen:%d, visual:%d\n", a_screen, a_visual_id) ;
- memset (&v, 0, sizeof (v)) ;
- v.visualid = a_visual_id ;
- is_ok = XF86DRICreateContext (dpy,
- DefaultScreen (dpy),
- &v,
- a_returned_ctxt_id,
- a_hw_ctxt) ;
- EPHYR_LOG ("leave:%d\n", is_ok) ;
- return is_ok ;
+ EPHYR_LOG("enter. screen:%d, visual:%d\n", a_screen, a_visual_id);
+ memset(&v, 0, sizeof(v));
+ v.visualid = a_visual_id;
+ is_ok = XF86DRICreateContext(dpy,
+ DefaultScreen(dpy),
+ &v, a_returned_ctxt_id, a_hw_ctxt);
+ EPHYR_LOG("leave:%d\n", is_ok);
+ return is_ok;
}
Bool
-ephyrDRIDestroyContext (int a_screen,
- int a_context_id)
+ephyrDRIDestroyContext(int a_screen, int a_context_id)
{
- Display *dpy = hostx_get_display () ;
- Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = FALSE;
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRIDestroyContext (dpy, DefaultScreen (dpy), a_context_id) ;
- EPHYR_LOG ("leave:%d\n", is_ok) ;
- return is_ok ;
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRIDestroyContext(dpy, DefaultScreen(dpy), a_context_id);
+ EPHYR_LOG("leave:%d\n", is_ok);
+ return is_ok;
}
Bool
-ephyrDRICreateDrawable (int a_screen,
- int a_drawable,
- drm_drawable_t *a_hw_drawable)
+ephyrDRICreateDrawable(int a_screen,
+ int a_drawable, drm_drawable_t * a_hw_drawable)
{
- Bool is_ok=FALSE;
- Display *dpy=hostx_get_display () ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRICreateDrawable (dpy, DefaultScreen (dpy),
- a_drawable, a_hw_drawable) ;
- EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
- return is_ok ;
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRICreateDrawable(dpy, DefaultScreen(dpy),
+ a_drawable, a_hw_drawable);
+ EPHYR_LOG("leave. is_ok:%d\n", is_ok);
+ return is_ok;
}
Bool
-ephyrDRIDestroyDrawable (int a_screen, int a_drawable)
+ephyrDRIDestroyDrawable(int a_screen, int a_drawable)
{
- EPHYR_LOG ("enter\n") ;
- EPHYR_LOG_ERROR ("not implemented yet\n") ;
- EPHYR_LOG ("leave\n") ;
- return FALSE ;
+ EPHYR_LOG("enter\n");
+ EPHYR_LOG_ERROR("not implemented yet\n");
+ EPHYR_LOG("leave\n");
+ return FALSE;
}
Bool
-ephyrDRIGetDrawableInfo (int a_screen,
- int a_drawable,
- unsigned int *a_index,
- unsigned int *a_stamp,
- int *a_x,
- int *a_y,
- int *a_w,
- int *a_h,
- int *a_num_clip_rects,
- drm_clip_rect_t **a_clip_rects,
- int *a_back_x,
- int *a_back_y,
- int *a_num_back_clip_rects,
- drm_clip_rect_t **a_back_clip_rects)
+ephyrDRIGetDrawableInfo(int a_screen,
+ int a_drawable,
+ unsigned int *a_index,
+ unsigned int *a_stamp,
+ int *a_x,
+ int *a_y,
+ int *a_w,
+ int *a_h,
+ int *a_num_clip_rects,
+ drm_clip_rect_t ** a_clip_rects,
+ int *a_back_x,
+ int *a_back_y,
+ int *a_num_back_clip_rects,
+ drm_clip_rect_t ** a_back_clip_rects)
{
- Bool is_ok=FALSE;
- Display *dpy=hostx_get_display () ;
- EphyrHostWindowAttributes attrs ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ EphyrHostWindowAttributes attrs;
- EPHYR_RETURN_VAL_IF_FAIL (a_x && a_y && a_w && a_h
- && a_num_clip_rects,
- FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_x && a_y && a_w && a_h
+ && a_num_clip_rects, FALSE);
- EPHYR_LOG ("enter\n") ;
- memset (&attrs, 0, sizeof (attrs)) ;
- if (!hostx_get_window_attributes (a_drawable, &attrs)) {
- EPHYR_LOG_ERROR ("failed to query host window attributes\n") ;
+ EPHYR_LOG("enter\n");
+ memset(&attrs, 0, sizeof(attrs));
+ if (!hostx_get_window_attributes(a_drawable, &attrs)) {
+ EPHYR_LOG_ERROR("failed to query host window attributes\n");
goto out;
}
- if (!XF86DRIGetDrawableInfo (dpy, DefaultScreen (dpy), a_drawable,
- a_index, a_stamp,
- a_x, a_y,
- a_w, a_h,
- a_num_clip_rects, a_clip_rects,
- a_back_x, a_back_y,
- a_num_back_clip_rects,
- a_back_clip_rects)) {
- EPHYR_LOG_ERROR ("XF86DRIGetDrawableInfo ()\n") ;
- goto out ;
+ if (!XF86DRIGetDrawableInfo(dpy, DefaultScreen(dpy), a_drawable,
+ a_index, a_stamp,
+ a_x, a_y,
+ a_w, a_h,
+ a_num_clip_rects, a_clip_rects,
+ a_back_x, a_back_y,
+ a_num_back_clip_rects, a_back_clip_rects)) {
+ EPHYR_LOG_ERROR("XF86DRIGetDrawableInfo ()\n");
+ goto out;
}
- EPHYR_LOG ("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h) ;
+ EPHYR_LOG("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h);
if (*a_num_clip_rects) {
- free (*a_back_clip_rects) ;
- *a_back_clip_rects = calloc (*a_num_clip_rects,
- sizeof (drm_clip_rect_t)) ;
- memmove (*a_back_clip_rects,
- *a_clip_rects,
- *a_num_clip_rects * sizeof (drm_clip_rect_t)) ;
+ free(*a_back_clip_rects);
+ *a_back_clip_rects = calloc(*a_num_clip_rects, sizeof(drm_clip_rect_t));
+ memmove(*a_back_clip_rects,
+ *a_clip_rects, *a_num_clip_rects * sizeof(drm_clip_rect_t));
*a_num_back_clip_rects = *a_num_clip_rects;
}
- EPHYR_LOG ("num back clip rects:%d, num clip rects:%d\n",
- *a_num_clip_rects, *a_num_back_clip_rects) ;
- *a_back_x = *a_x ;
- *a_back_y = *a_y ;
+ EPHYR_LOG("num back clip rects:%d, num clip rects:%d\n",
+ *a_num_clip_rects, *a_num_back_clip_rects);
+ *a_back_x = *a_x;
+ *a_back_y = *a_y;
*a_w = attrs.width;
*a_h = attrs.height;
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n",
- *a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h) ;
- return is_ok ;
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n",
+ *a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h);
+ return is_ok;
}
Bool
-ephyrDRIGetDeviceInfo (int a_screen,
- drm_handle_t *a_frame_buffer,
- int *a_fb_origin,
- int *a_fb_size,
- int *a_fb_stride,
- int *a_dev_private_size,
- void **a_dev_private)
+ephyrDRIGetDeviceInfo(int a_screen,
+ drm_handle_t * a_frame_buffer,
+ int *a_fb_origin,
+ int *a_fb_size,
+ int *a_fb_stride,
+ int *a_dev_private_size, void **a_dev_private)
{
- Bool is_ok = FALSE ;
- Display *dpy = hostx_get_display () ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
- EPHYR_LOG ("enter\n") ;
- is_ok = XF86DRIGetDeviceInfo (dpy, DefaultScreen (dpy), a_frame_buffer,
- a_fb_origin, a_fb_size, a_fb_stride,
- a_dev_private_size, a_dev_private) ;
- EPHYR_LOG ("leave:%d\n", is_ok) ;
- return is_ok ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
+ EPHYR_LOG("enter\n");
+ is_ok = XF86DRIGetDeviceInfo(dpy, DefaultScreen(dpy), a_frame_buffer,
+ a_fb_origin, a_fb_size, a_fb_stride,
+ a_dev_private_size, a_dev_private);
+ EPHYR_LOG("leave:%d\n", is_ok);
+ return is_ok;
}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdri.h b/xorg-server/hw/kdrive/ephyr/ephyrdri.h
index 28ae8eae0..d28910f29 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdri.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdri.h
@@ -31,45 +31,40 @@
#include <xf86drm.h>
-Bool ephyrDRIQueryDirectRenderingCapable (int a_screen, Bool *a_is_capable) ;
-Bool ephyrDRIOpenConnection (int screen, drm_handle_t *a_sarea, char **a_bus_id_string) ;
-Bool ephyrDRIAuthConnection (int a_screen, drm_magic_t a_magic) ;
-Bool ephyrDRICloseConnection (int a_screen) ;
-Bool ephyrDRIGetClientDriverName (int a_screen,
- int *a_ddx_driver_major_version,
- int *a_ddx_driver_minor_version,
- int *a_ddx_driver_patch_version,
- char ** a_client_driver_name) ;
-Bool ephyrDRICreateContext (int a_screen,
- int a_visual_id,
- XID *a_returned_ctx_id,
- drm_context_t *a_hw_ctx) ;
-Bool ephyrDRIDestroyContext (int a_screen,
- int a_context_id) ;
-Bool ephyrDRICreateDrawable (int a_screen,
- int a_drawable,
- drm_drawable_t *a_hw_drawable) ;
-Bool ephyrDRIDestroyDrawable (int a_screen, int a_drawable) ;
-Bool ephyrDRIGetDrawableInfo (int a_screen,
- int /*Drawable*/a_drawable,
- unsigned int *a_index,
- unsigned int *a_stamp,
- int *a_x,
- int *a_y,
- int *a_w,
- int *a_h,
- int *a_num_clip_rects,
- drm_clip_rect_t **a_clip_rects,
- int *a_back_x,
- int *a_back_y,
- int *num_back_clip_rects,
- drm_clip_rect_t **a_back_clip_rects) ;
-Bool ephyrDRIGetDeviceInfo (int a_screen,
- drm_handle_t *a_frame_buffer,
- int *a_fb_origin,
- int *a_fb_size,
- int *a_fb_stride,
- int *a_dev_private_size,
- void **a_dev_private) ;
+Bool ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable);
+Bool ephyrDRIOpenConnection(int screen, drm_handle_t * a_sarea,
+ char **a_bus_id_string);
+Bool ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic);
+Bool ephyrDRICloseConnection(int a_screen);
+Bool ephyrDRIGetClientDriverName(int a_screen,
+ int *a_ddx_driver_major_version,
+ int *a_ddx_driver_minor_version,
+ int *a_ddx_driver_patch_version,
+ char **a_client_driver_name);
+Bool ephyrDRICreateContext(int a_screen,
+ int a_visual_id,
+ XID *a_returned_ctx_id, drm_context_t * a_hw_ctx);
+Bool ephyrDRIDestroyContext(int a_screen, int a_context_id);
+Bool ephyrDRICreateDrawable(int a_screen,
+ int a_drawable, drm_drawable_t * a_hw_drawable);
+Bool ephyrDRIDestroyDrawable(int a_screen, int a_drawable);
+Bool ephyrDRIGetDrawableInfo(int a_screen, int /*Drawable */ a_drawable,
+ unsigned int *a_index,
+ unsigned int *a_stamp,
+ int *a_x,
+ int *a_y,
+ int *a_w,
+ int *a_h,
+ int *a_num_clip_rects,
+ drm_clip_rect_t ** a_clip_rects,
+ int *a_back_x,
+ int *a_back_y,
+ int *num_back_clip_rects,
+ drm_clip_rect_t ** a_back_clip_rects);
+Bool ephyrDRIGetDeviceInfo(int a_screen,
+ drm_handle_t * a_frame_buffer,
+ int *a_fb_origin,
+ int *a_fb_size,
+ int *a_fb_stride,
+ int *a_dev_private_size, void **a_dev_private);
#endif /*__EPHYRDRI_H__*/
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
index 0741a7294..28486f516 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
@@ -59,43 +59,40 @@
typedef struct {
int foo;
} EphyrDRIWindowPrivRec;
-typedef EphyrDRIWindowPrivRec* EphyrDRIWindowPrivPtr;
+typedef EphyrDRIWindowPrivRec *EphyrDRIWindowPrivPtr;
typedef struct {
- CreateWindowProcPtr CreateWindow ;
- DestroyWindowProcPtr DestroyWindow ;
- MoveWindowProcPtr MoveWindow ;
- PositionWindowProcPtr PositionWindow ;
- ClipNotifyProcPtr ClipNotify ;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ MoveWindowProcPtr MoveWindow;
+ PositionWindowProcPtr PositionWindow;
+ ClipNotifyProcPtr ClipNotify;
} EphyrDRIScreenPrivRec;
-typedef EphyrDRIScreenPrivRec* EphyrDRIScreenPrivPtr;
+typedef EphyrDRIScreenPrivRec *EphyrDRIScreenPrivPtr;
static int DRIErrorBase;
+static Bool ephyrDRIScreenInit(ScreenPtr a_screen);
+static Bool ephyrDRICreateWindow(WindowPtr a_win);
+static Bool ephyrDRIDestroyWindow(WindowPtr a_win);
+static void ephyrDRIMoveWindow(WindowPtr a_win,
+ int a_x, int a_y,
+ WindowPtr a_siblings, VTKind a_kind);
+static Bool ephyrDRIPositionWindow(WindowPtr a_win, int x, int y);
+static void ephyrDRIClipNotify(WindowPtr a_win, int a_x, int a_y);
-
-static Bool ephyrDRIScreenInit (ScreenPtr a_screen) ;
-static Bool ephyrDRICreateWindow (WindowPtr a_win) ;
-static Bool ephyrDRIDestroyWindow (WindowPtr a_win) ;
-static void ephyrDRIMoveWindow (WindowPtr a_win,
- int a_x, int a_y,
- WindowPtr a_siblings,
- VTKind a_kind);
-static Bool ephyrDRIPositionWindow (WindowPtr a_win,
- int x, int y) ;
-static void ephyrDRIClipNotify (WindowPtr a_win,
- int a_x, int a_y) ;
-
-static Bool EphyrMirrorHostVisuals (ScreenPtr a_screen) ;
-static Bool destroyHostPeerWindow (const WindowPtr a_win) ;
-static Bool findWindowPairFromLocal (WindowPtr a_local,
- EphyrWindowPair **a_pair);
+static Bool EphyrMirrorHostVisuals(ScreenPtr a_screen);
+static Bool destroyHostPeerWindow(const WindowPtr a_win);
+static Bool findWindowPairFromLocal(WindowPtr a_local,
+ EphyrWindowPair ** a_pair);
static unsigned char DRIReqCode = 0;
static DevPrivateKeyRec ephyrDRIWindowKeyRec;
+
#define ephyrDRIWindowKey (&ephyrDRIWindowKeyRec)
static DevPrivateKeyRec ephyrDRIScreenKeyRec;
+
#define ephyrDRIScreenKey (&ephyrDRIScreenKeyRec)
#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
@@ -104,251 +101,239 @@ static DevPrivateKeyRec ephyrDRIScreenKeyRec;
dixLookupPrivate(&(screen)->devPrivates, ephyrDRIScreenKey))
static Bool
-ephyrDRIScreenInit (ScreenPtr a_screen)
+ephyrDRIScreenInit(ScreenPtr a_screen)
{
- Bool is_ok=FALSE ;
- EphyrDRIScreenPrivPtr screen_priv=NULL ;
+ Bool is_ok = FALSE;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
- EPHYR_RETURN_VAL_IF_FAIL (a_screen, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_screen, FALSE);
- screen_priv=GET_EPHYR_DRI_SCREEN_PRIV (a_screen) ;
- EPHYR_RETURN_VAL_IF_FAIL (screen_priv, FALSE) ;
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(a_screen);
+ EPHYR_RETURN_VAL_IF_FAIL(screen_priv, FALSE);
- screen_priv->CreateWindow = a_screen->CreateWindow ;
- screen_priv->DestroyWindow = a_screen->DestroyWindow ;
- screen_priv->MoveWindow = a_screen->MoveWindow ;
- screen_priv->PositionWindow = a_screen->PositionWindow ;
- screen_priv->ClipNotify = a_screen->ClipNotify ;
+ screen_priv->CreateWindow = a_screen->CreateWindow;
+ screen_priv->DestroyWindow = a_screen->DestroyWindow;
+ screen_priv->MoveWindow = a_screen->MoveWindow;
+ screen_priv->PositionWindow = a_screen->PositionWindow;
+ screen_priv->ClipNotify = a_screen->ClipNotify;
- a_screen->CreateWindow = ephyrDRICreateWindow ;
- a_screen->DestroyWindow = ephyrDRIDestroyWindow ;
- a_screen->MoveWindow = ephyrDRIMoveWindow ;
- a_screen->PositionWindow = ephyrDRIPositionWindow ;
- a_screen->ClipNotify = ephyrDRIClipNotify ;
+ a_screen->CreateWindow = ephyrDRICreateWindow;
+ a_screen->DestroyWindow = ephyrDRIDestroyWindow;
+ a_screen->MoveWindow = ephyrDRIMoveWindow;
+ a_screen->PositionWindow = ephyrDRIPositionWindow;
+ a_screen->ClipNotify = ephyrDRIClipNotify;
- is_ok = TRUE ;
+ is_ok = TRUE;
- return is_ok ;
+ return is_ok;
}
static Bool
-ephyrDRICreateWindow (WindowPtr a_win)
+ephyrDRICreateWindow(WindowPtr a_win)
{
- Bool is_ok=FALSE ;
- ScreenPtr screen=NULL ;
- EphyrDRIScreenPrivPtr screen_priv =NULL;
+ Bool is_ok = FALSE;
+ ScreenPtr screen = NULL;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
- EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
- screen = a_win->drawable.pScreen ;
- EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
- EPHYR_RETURN_VAL_IF_FAIL (screen_priv
- && screen_priv->CreateWindow,
- FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
+ screen = a_win->drawable.pScreen;
+ EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
+ EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->CreateWindow, FALSE);
- EPHYR_LOG ("enter. win:%p\n", a_win) ;
+ EPHYR_LOG("enter. win:%p\n", a_win);
- screen->CreateWindow = screen_priv->CreateWindow ;
- is_ok = (*screen->CreateWindow) (a_win) ;
- screen->CreateWindow = ephyrDRICreateWindow ;
+ screen->CreateWindow = screen_priv->CreateWindow;
+ is_ok = (*screen->CreateWindow) (a_win);
+ screen->CreateWindow = ephyrDRICreateWindow;
if (is_ok) {
- dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
+ dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
}
- return is_ok ;
+ return is_ok;
}
static Bool
-ephyrDRIDestroyWindow (WindowPtr a_win)
+ephyrDRIDestroyWindow(WindowPtr a_win)
{
- Bool is_ok=FALSE ;
- ScreenPtr screen=NULL ;
- EphyrDRIScreenPrivPtr screen_priv =NULL;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
- screen = a_win->drawable.pScreen ;
- EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
- EPHYR_RETURN_VAL_IF_FAIL (screen_priv
- && screen_priv->DestroyWindow,
- FALSE) ;
-
- screen->DestroyWindow = screen_priv->DestroyWindow ;
+ Bool is_ok = FALSE;
+ ScreenPtr screen = NULL;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
+ screen = a_win->drawable.pScreen;
+ EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
+ EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->DestroyWindow, FALSE);
+
+ screen->DestroyWindow = screen_priv->DestroyWindow;
if (screen->DestroyWindow) {
- is_ok = (*screen->DestroyWindow) (a_win) ;
+ is_ok = (*screen->DestroyWindow) (a_win);
}
- screen->DestroyWindow = ephyrDRIDestroyWindow ;
+ screen->DestroyWindow = ephyrDRIDestroyWindow;
if (is_ok) {
- EphyrDRIWindowPrivPtr win_priv=GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ EphyrDRIWindowPrivPtr win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
+
if (win_priv) {
- destroyHostPeerWindow (a_win) ;
- free(win_priv) ;
- dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
- EPHYR_LOG ("destroyed the remote peer window\n") ;
+ destroyHostPeerWindow(a_win);
+ free(win_priv);
+ dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
+ EPHYR_LOG("destroyed the remote peer window\n");
}
}
- return is_ok ;
+ return is_ok;
}
static void
-ephyrDRIMoveWindow (WindowPtr a_win,
- int a_x, int a_y,
- WindowPtr a_siblings,
- VTKind a_kind)
+ephyrDRIMoveWindow(WindowPtr a_win,
+ int a_x, int a_y, WindowPtr a_siblings, VTKind a_kind)
{
- Bool is_ok=FALSE ;
- ScreenPtr screen=NULL ;
- EphyrDRIScreenPrivPtr screen_priv =NULL;
- EphyrDRIWindowPrivPtr win_priv=NULL ;
- EphyrWindowPair *pair=NULL ;
+ Bool is_ok = FALSE;
+ ScreenPtr screen = NULL;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
+ EphyrDRIWindowPrivPtr win_priv = NULL;
+ EphyrWindowPair *pair = NULL;
EphyrBox geo;
- int x=0,y=0;/*coords relative to parent window*/
+ int x = 0, y = 0; /*coords relative to parent window */
- EPHYR_RETURN_IF_FAIL (a_win) ;
+ EPHYR_RETURN_IF_FAIL(a_win);
- EPHYR_LOG ("enter\n") ;
- screen = a_win->drawable.pScreen ;
- EPHYR_RETURN_IF_FAIL (screen) ;
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
- EPHYR_RETURN_IF_FAIL (screen_priv
- && screen_priv->MoveWindow) ;
+ EPHYR_LOG("enter\n");
+ screen = a_win->drawable.pScreen;
+ EPHYR_RETURN_IF_FAIL(screen);
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
+ EPHYR_RETURN_IF_FAIL(screen_priv && screen_priv->MoveWindow);
- screen->MoveWindow = screen_priv->MoveWindow ;
+ screen->MoveWindow = screen_priv->MoveWindow;
if (screen->MoveWindow) {
- (*screen->MoveWindow) (a_win, a_x, a_y, a_siblings, a_kind) ;
+ (*screen->MoveWindow) (a_win, a_x, a_y, a_siblings, a_kind);
}
- screen->MoveWindow = ephyrDRIMoveWindow ;
+ screen->MoveWindow = ephyrDRIMoveWindow;
- EPHYR_LOG ("window: %p\n", a_win) ;
+ EPHYR_LOG("window: %p\n", a_win);
if (!a_win->parent) {
- EPHYR_LOG ("cannot move root window\n") ;
- is_ok = TRUE ;
- goto out ;
+ EPHYR_LOG("cannot move root window\n");
+ is_ok = TRUE;
+ goto out;
}
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
if (!win_priv) {
- EPHYR_LOG ("not a DRI peered window\n") ;
- is_ok = TRUE ;
- goto out ;
- }
- if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR ("failed to get window pair\n") ;
- goto out ;
- }
- /*compute position relative to parent window*/
- x = a_win->drawable.x - a_win->parent->drawable.x ;
- y = a_win->drawable.y - a_win->parent->drawable.y ;
- /*set the geometry to pass to hostx_set_window_geometry*/
- memset (&geo, 0, sizeof (geo)) ;
- geo.x = x ;
- geo.y = y ;
- geo.width = a_win->drawable.width ;
- geo.height = a_win->drawable.height ;
- hostx_set_window_geometry (pair->remote, &geo) ;
- is_ok = TRUE ;
-
-out:
- EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
- /*do cleanup here*/
+ EPHYR_LOG("not a DRI peered window\n");
+ is_ok = TRUE;
+ goto out;
+ }
+ if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR("failed to get window pair\n");
+ goto out;
+ }
+ /*compute position relative to parent window */
+ x = a_win->drawable.x - a_win->parent->drawable.x;
+ y = a_win->drawable.y - a_win->parent->drawable.y;
+ /*set the geometry to pass to hostx_set_window_geometry */
+ memset(&geo, 0, sizeof(geo));
+ geo.x = x;
+ geo.y = y;
+ geo.width = a_win->drawable.width;
+ geo.height = a_win->drawable.height;
+ hostx_set_window_geometry(pair->remote, &geo);
+ is_ok = TRUE;
+
+ out:
+ EPHYR_LOG("leave. is_ok:%d\n", is_ok);
+ /*do cleanup here */
}
static Bool
-ephyrDRIPositionWindow (WindowPtr a_win,
- int a_x, int a_y)
+ephyrDRIPositionWindow(WindowPtr a_win, int a_x, int a_y)
{
- Bool is_ok=FALSE ;
- ScreenPtr screen=NULL ;
- EphyrDRIScreenPrivPtr screen_priv =NULL;
- EphyrDRIWindowPrivPtr win_priv=NULL ;
- EphyrWindowPair *pair=NULL ;
+ Bool is_ok = FALSE;
+ ScreenPtr screen = NULL;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
+ EphyrDRIWindowPrivPtr win_priv = NULL;
+ EphyrWindowPair *pair = NULL;
EphyrBox geo;
- EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
- EPHYR_LOG ("enter\n") ;
- screen = a_win->drawable.pScreen ;
- EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
- EPHYR_RETURN_VAL_IF_FAIL (screen_priv
- && screen_priv->PositionWindow,
- FALSE) ;
+ EPHYR_LOG("enter\n");
+ screen = a_win->drawable.pScreen;
+ EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
+ EPHYR_RETURN_VAL_IF_FAIL(screen_priv && screen_priv->PositionWindow, FALSE);
- screen->PositionWindow = screen_priv->PositionWindow ;
+ screen->PositionWindow = screen_priv->PositionWindow;
if (screen->PositionWindow) {
- (*screen->PositionWindow) (a_win, a_x, a_y) ;
+ (*screen->PositionWindow) (a_win, a_x, a_y);
}
- screen->PositionWindow = ephyrDRIPositionWindow ;
+ screen->PositionWindow = ephyrDRIPositionWindow;
- EPHYR_LOG ("window: %p\n", a_win) ;
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ EPHYR_LOG("window: %p\n", a_win);
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
if (!win_priv) {
- EPHYR_LOG ("not a DRI peered window\n") ;
- is_ok = TRUE ;
- goto out ;
- }
- if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR ("failed to get window pair\n") ;
- goto out ;
- }
- /*set the geometry to pass to hostx_set_window_geometry*/
- memset (&geo, 0, sizeof (geo)) ;
- geo.x = a_x ;
- geo.y = a_y ;
- geo.width = a_win->drawable.width ;
- geo.height = a_win->drawable.height ;
- hostx_set_window_geometry (pair->remote, &geo) ;
- is_ok = TRUE ;
-
-out:
- EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
- /*do cleanup here*/
- return is_ok ;
+ EPHYR_LOG("not a DRI peered window\n");
+ is_ok = TRUE;
+ goto out;
+ }
+ if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR("failed to get window pair\n");
+ goto out;
+ }
+ /*set the geometry to pass to hostx_set_window_geometry */
+ memset(&geo, 0, sizeof(geo));
+ geo.x = a_x;
+ geo.y = a_y;
+ geo.width = a_win->drawable.width;
+ geo.height = a_win->drawable.height;
+ hostx_set_window_geometry(pair->remote, &geo);
+ is_ok = TRUE;
+
+ out:
+ EPHYR_LOG("leave. is_ok:%d\n", is_ok);
+ /*do cleanup here */
+ return is_ok;
}
static void
-ephyrDRIClipNotify (WindowPtr a_win,
- int a_x, int a_y)
+ephyrDRIClipNotify(WindowPtr a_win, int a_x, int a_y)
{
- Bool is_ok=FALSE ;
- ScreenPtr screen=NULL ;
- EphyrDRIScreenPrivPtr screen_priv =NULL;
- EphyrDRIWindowPrivPtr win_priv=NULL ;
- EphyrWindowPair *pair=NULL ;
- EphyrRect *rects=NULL;
- int i=0 ;
-
- EPHYR_RETURN_IF_FAIL (a_win) ;
-
- EPHYR_LOG ("enter\n") ;
- screen = a_win->drawable.pScreen ;
- EPHYR_RETURN_IF_FAIL (screen) ;
- screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
- EPHYR_RETURN_IF_FAIL (screen_priv && screen_priv->ClipNotify) ;
-
- screen->ClipNotify = screen_priv->ClipNotify ;
+ Bool is_ok = FALSE;
+ ScreenPtr screen = NULL;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
+ EphyrDRIWindowPrivPtr win_priv = NULL;
+ EphyrWindowPair *pair = NULL;
+ EphyrRect *rects = NULL;
+ int i = 0;
+
+ EPHYR_RETURN_IF_FAIL(a_win);
+
+ EPHYR_LOG("enter\n");
+ screen = a_win->drawable.pScreen;
+ EPHYR_RETURN_IF_FAIL(screen);
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV(screen);
+ EPHYR_RETURN_IF_FAIL(screen_priv && screen_priv->ClipNotify);
+
+ screen->ClipNotify = screen_priv->ClipNotify;
if (screen->ClipNotify) {
- (*screen->ClipNotify) (a_win, a_x, a_y) ;
+ (*screen->ClipNotify) (a_win, a_x, a_y);
}
- screen->ClipNotify = ephyrDRIClipNotify ;
+ screen->ClipNotify = ephyrDRIClipNotify;
- EPHYR_LOG ("window: %p\n", a_win) ;
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ EPHYR_LOG("window: %p\n", a_win);
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV(a_win);
if (!win_priv) {
- EPHYR_LOG ("not a DRI peered window\n") ;
- is_ok = TRUE ;
- goto out ;
- }
- if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR ("failed to get window pair\n") ;
- goto out ;
- }
- rects = calloc(RegionNumRects (&a_win->clipList),
- sizeof (EphyrRect)) ;
- for (i=0; i < RegionNumRects (&a_win->clipList); i++) {
- memmove (&rects[i],
- &RegionRects (&a_win->clipList)[i],
- sizeof (EphyrRect)) ;
+ EPHYR_LOG("not a DRI peered window\n");
+ is_ok = TRUE;
+ goto out;
+ }
+ if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR("failed to get window pair\n");
+ goto out;
+ }
+ rects = calloc(RegionNumRects(&a_win->clipList), sizeof(EphyrRect));
+ for (i = 0; i < RegionNumRects(&a_win->clipList); i++) {
+ memmove(&rects[i],
+ &RegionRects(&a_win->clipList)[i], sizeof(EphyrRect));
rects[i].x1 -= a_win->drawable.x;
rects[i].x2 -= a_win->drawable.x;
rects[i].y1 -= a_win->drawable.y;
@@ -359,17 +344,15 @@ ephyrDRIClipNotify (WindowPtr a_win,
* to the peer window in the host
*/
is_ok = hostx_set_window_bounding_rectangles
- (pair->remote,
- rects,
- RegionNumRects (&a_win->clipList)) ;
- is_ok = TRUE ;
+ (pair->remote, rects, RegionNumRects(&a_win->clipList));
+ is_ok = TRUE;
-out:
- free(rects) ;
- rects = NULL ;
+ out:
+ free(rects);
+ rects = NULL;
- EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
- /*do cleanup here*/
+ EPHYR_LOG("leave. is_ok:%d\n", is_ok);
+ /*do cleanup here */
}
/**
@@ -382,119 +365,115 @@ out:
* of the screen.
*/
static Bool
-EphyrDuplicateVisual (unsigned int a_screen,
- short a_depth,
- short a_class,
- short a_bits_per_rgb_values,
- short a_colormap_entries,
- unsigned int a_red_mask,
- unsigned int a_green_mask,
- unsigned int a_blue_mask,
- unsigned int a_new_id)
+EphyrDuplicateVisual(unsigned int a_screen,
+ short a_depth,
+ short a_class,
+ short a_bits_per_rgb_values,
+ short a_colormap_entries,
+ unsigned int a_red_mask,
+ unsigned int a_green_mask,
+ unsigned int a_blue_mask, unsigned int a_new_id)
{
- Bool is_ok = FALSE, found_visual=FALSE, found_depth=FALSE ;
- ScreenPtr screen=NULL ;
- VisualRec new_visual, *new_visuals=NULL ;
- int i=0 ;
+ Bool is_ok = FALSE, found_visual = FALSE, found_depth = FALSE;
+ ScreenPtr screen = NULL;
+ VisualRec new_visual, *new_visuals = NULL;
+ int i = 0;
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (a_screen >= screenInfo.numScreens) {
- EPHYR_LOG_ERROR ("bad screen number\n") ;
+ EPHYR_LOG_ERROR("bad screen number\n");
goto out;
}
- memset (&new_visual, 0, sizeof (VisualRec)) ;
+ memset(&new_visual, 0, sizeof(VisualRec));
- /*get the screen pointed to by a_screen*/
- screen = screenInfo.screens[a_screen] ;
- EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
+ /*get the screen pointed to by a_screen */
+ screen = screenInfo.screens[a_screen];
+ EPHYR_RETURN_VAL_IF_FAIL(screen, FALSE);
/*
* In that screen, first look for an existing visual that has the
* same characteristics as those passed in parameter
* to this function and copy it.
*/
- for (i=0; i < screen->numVisuals; i++) {
+ for (i = 0; i < screen->numVisuals; i++) {
if (screen->visuals[i].bitsPerRGBValue == a_bits_per_rgb_values &&
- screen->visuals[i].ColormapEntries == a_colormap_entries ) {
- /*copy the visual found*/
- memcpy (&new_visual, &screen->visuals[i], sizeof (new_visual)) ;
- new_visual.vid = a_new_id ;
- new_visual.class = a_class ;
- new_visual.redMask = a_red_mask ;
- new_visual.greenMask = a_green_mask ;
- new_visual.blueMask = a_blue_mask ;
- found_visual = TRUE ;
- EPHYR_LOG ("found a visual that matches visual id: %d\n",
- a_new_id) ;
+ screen->visuals[i].ColormapEntries == a_colormap_entries) {
+ /*copy the visual found */
+ memcpy(&new_visual, &screen->visuals[i], sizeof(new_visual));
+ new_visual.vid = a_new_id;
+ new_visual.class = a_class;
+ new_visual.redMask = a_red_mask;
+ new_visual.greenMask = a_green_mask;
+ new_visual.blueMask = a_blue_mask;
+ found_visual = TRUE;
+ EPHYR_LOG("found a visual that matches visual id: %d\n", a_new_id);
break;
}
}
if (!found_visual) {
- EPHYR_LOG ("did not find any visual matching %d\n", a_new_id) ;
- goto out ;
+ EPHYR_LOG("did not find any visual matching %d\n", a_new_id);
+ goto out;
}
/*
* be prepare to extend screen->visuals to add new_visual to it
*/
- new_visuals = calloc(screen->numVisuals+1, sizeof (VisualRec)) ;
- memmove (new_visuals,
- screen->visuals,
- screen->numVisuals*sizeof (VisualRec)) ;
- memmove (&new_visuals[screen->numVisuals],
- &new_visual,
- sizeof (VisualRec)) ;
+ new_visuals = calloc(screen->numVisuals + 1, sizeof(VisualRec));
+ memmove(new_visuals,
+ screen->visuals, screen->numVisuals * sizeof(VisualRec));
+ memmove(&new_visuals[screen->numVisuals], &new_visual, sizeof(VisualRec));
/*
* Now, in that same screen, update the screen->allowedDepths member.
* In that array, each element represents the visuals applicable to
* a given depth. So we need to add an entry matching the new visual
* that we are going to add to screen->visuals
*/
- for (i=0; i<screen->numDepths; i++) {
- VisualID *vids=NULL;
- DepthPtr cur_depth=NULL ;
- /*find the entry matching a_depth*/
+ for (i = 0; i < screen->numDepths; i++) {
+ VisualID *vids = NULL;
+ DepthPtr cur_depth = NULL;
+
+ /*find the entry matching a_depth */
if (screen->allowedDepths[i].depth != a_depth)
- continue ;
+ continue;
cur_depth = &screen->allowedDepths[i];
/*
* extend the list of visual IDs in that entry,
* so to add a_new_id in there.
*/
vids = realloc(cur_depth->vids,
- (cur_depth->numVids+1)*sizeof (VisualID));
+ (cur_depth->numVids + 1) * sizeof(VisualID));
if (!vids) {
- EPHYR_LOG_ERROR ("failed to realloc numids\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to realloc numids\n");
+ goto out;
}
- vids[cur_depth->numVids] = a_new_id ;
+ vids[cur_depth->numVids] = a_new_id;
/*
* Okay now commit our change.
* Do really update screen->allowedDepths[i]
*/
- cur_depth->numVids++ ;
- cur_depth->vids = vids ;
- found_depth=TRUE;
+ cur_depth->numVids++;
+ cur_depth->vids = vids;
+ found_depth = TRUE;
}
if (!found_depth) {
- EPHYR_LOG_ERROR ("failed to update screen[%d]->allowedDepth\n",
- a_screen) ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to update screen[%d]->allowedDepth\n",
+ a_screen);
+ goto out;
}
/*
* Commit our change to screen->visuals
*/
- free(screen->visuals) ;
- screen->visuals = new_visuals ;
- screen->numVisuals++ ;
- new_visuals = NULL ;
-
- is_ok = TRUE ;
-out:
- free(new_visuals) ;
- new_visuals = NULL ;
-
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ free(screen->visuals);
+ screen->visuals = new_visuals;
+ screen->numVisuals++;
+ new_visuals = NULL;
+
+ is_ok = TRUE;
+ out:
+ free(new_visuals);
+ new_visuals = NULL;
+
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
/**
@@ -504,46 +483,45 @@ out:
* GLX.
*/
static Bool
-EphyrMirrorHostVisuals (ScreenPtr a_screen)
+EphyrMirrorHostVisuals(ScreenPtr a_screen)
{
- Bool is_ok=FALSE;
- EphyrHostVisualInfo *visuals=NULL;
- int nb_visuals=0, i=0;
-
- EPHYR_LOG ("enter\n") ;
- if (!hostx_get_visuals_info (&visuals, &nb_visuals)) {
- EPHYR_LOG_ERROR ("failed to get host visuals\n") ;
- goto out ;
- }
- for (i=0; i<nb_visuals; i++) {
- if (!EphyrDuplicateVisual (a_screen->myNum,
- visuals[i].depth,
- visuals[i].class,
- visuals[i].bits_per_rgb,
- visuals[i].colormap_size,
- visuals[i].red_mask,
- visuals[i].green_mask,
- visuals[i].blue_mask,
- visuals[i].visualid)) {
- EPHYR_LOG_ERROR ("failed to duplicate host visual %d\n",
- (int)visuals[i].visualid) ;
+ Bool is_ok = FALSE;
+ EphyrHostVisualInfo *visuals = NULL;
+ int nb_visuals = 0, i = 0;
+
+ EPHYR_LOG("enter\n");
+ if (!hostx_get_visuals_info(&visuals, &nb_visuals)) {
+ EPHYR_LOG_ERROR("failed to get host visuals\n");
+ goto out;
+ }
+ for (i = 0; i < nb_visuals; i++) {
+ if (!EphyrDuplicateVisual(a_screen->myNum,
+ visuals[i].depth,
+ visuals[i].class,
+ visuals[i].bits_per_rgb,
+ visuals[i].colormap_size,
+ visuals[i].red_mask,
+ visuals[i].green_mask,
+ visuals[i].blue_mask, visuals[i].visualid)) {
+ EPHYR_LOG_ERROR("failed to duplicate host visual %d\n",
+ (int) visuals[i].visualid);
}
}
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("leave\n") ;
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave\n");
return is_ok;
}
-
static int
-ProcXF86DRIQueryVersion (register ClientPtr client)
+ProcXF86DRIQueryVersion(register ClientPtr client)
{
xXF86DRIQueryVersionReply rep;
+
REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
rep.type = X_Reply;
rep.length = 0;
@@ -552,72 +530,73 @@ ProcXF86DRIQueryVersion (register ClientPtr client)
rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
- swaps(&rep.majorVersion);
- swaps(&rep.minorVersion);
- swapl(&rep.patchVersion);
- }
- WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
- EPHYR_LOG ("leave\n") ;
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swaps(&rep.majorVersion);
+ swaps(&rep.minorVersion);
+ swapl(&rep.patchVersion);
+ }
+ WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *) &rep);
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
+ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
{
- xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReply rep;
Bool isCapable;
+
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if (!ephyrDRIQueryDirectRenderingCapable (stuff->screen, &isCapable)) {
+ if (!ephyrDRIQueryDirectRenderingCapable(stuff->screen, &isCapable)) {
return BadValue;
}
rep.isCapable = isCapable;
if (!LocalClient(client) || client->swapped)
- rep.isCapable = 0;
+ rep.isCapable = 0;
if (client->swapped) {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
}
- WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
- EPHYR_LOG ("leave\n") ;
+ WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply),
+ (char *) &rep);
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIOpenConnection (register ClientPtr client)
+ProcXF86DRIOpenConnection(register ClientPtr client)
{
xXF86DRIOpenConnectionReply rep;
- drm_handle_t hSAREA;
- char* busIdString = NULL;
+ drm_handle_t hSAREA;
+ char *busIdString = NULL;
+
REQUEST(xXF86DRIOpenConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
- if (!ephyrDRIOpenConnection(stuff->screen,
- &hSAREA,
- &busIdString)) {
+ if (!ephyrDRIOpenConnection(stuff->screen, &hSAREA, &busIdString)) {
return BadValue;
}
@@ -625,36 +604,39 @@ ProcXF86DRIOpenConnection (register ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.busIdStringLength = 0;
if (busIdString)
- rep.busIdStringLength = strlen(busIdString);
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
- pad_to_int32(rep.busIdStringLength));
+ rep.busIdStringLength = strlen(busIdString);
+ rep.length =
+ bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.busIdStringLength));
- rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
+ rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff);
#if defined(LONG64) && !defined(__linux__)
- rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
+ rep.hSAREAHigh = (CARD32) (hSAREA >> 32);
#else
rep.hSAREAHigh = 0;
#endif
- WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *) &rep);
if (rep.busIdStringLength)
WriteToClient(client, rep.busIdStringLength, busIdString);
free(busIdString);
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIAuthConnection (register ClientPtr client)
+ProcXF86DRIAuthConnection(register ClientPtr client)
{
xXF86DRIAuthConnectionReply rep;
+
REQUEST(xXF86DRIAuthConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
@@ -662,88 +644,88 @@ ProcXF86DRIAuthConnection (register ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.authenticated = 1;
- if (!ephyrDRIAuthConnection (stuff->screen, stuff->magic)) {
- ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
+ if (!ephyrDRIAuthConnection(stuff->screen, stuff->magic)) {
+ ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
rep.authenticated = 0;
}
- WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
- EPHYR_LOG ("leave\n") ;
+ WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *) &rep);
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRICloseConnection (register ClientPtr client)
+ProcXF86DRICloseConnection(register ClientPtr client)
{
REQUEST(xXF86DRICloseConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
client->errorValue = stuff->screen;
return BadValue;
}
/*
- DRICloseConnection( screenInfo.screens[stuff->screen]);
- */
+ DRICloseConnection( screenInfo.screens[stuff->screen]);
+ */
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIGetClientDriverName (register ClientPtr client)
+ProcXF86DRIGetClientDriverName(register ClientPtr client)
{
- xXF86DRIGetClientDriverNameReply rep;
- char* clientDriverName;
+ xXF86DRIGetClientDriverNameReply rep;
+ char *clientDriverName;
+
REQUEST(xXF86DRIGetClientDriverNameReq);
REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
- ephyrDRIGetClientDriverName (stuff->screen,
- (int *)&rep.ddxDriverMajorVersion,
- (int *)&rep.ddxDriverMinorVersion,
- (int *)&rep.ddxDriverPatchVersion,
- &clientDriverName);
+ ephyrDRIGetClientDriverName(stuff->screen,
+ (int *) &rep.ddxDriverMajorVersion,
+ (int *) &rep.ddxDriverMinorVersion,
+ (int *) &rep.ddxDriverPatchVersion,
+ &clientDriverName);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.clientDriverNameLength = 0;
if (clientDriverName)
- rep.clientDriverNameLength = strlen(clientDriverName);
+ rep.clientDriverNameLength = strlen(clientDriverName);
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.clientDriverNameLength));
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.clientDriverNameLength));
- WriteToClient(client,
- sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
+ WriteToClient(client,
+ sizeof(xXF86DRIGetClientDriverNameReply), (char *) &rep);
if (rep.clientDriverNameLength)
- WriteToClient(client,
- rep.clientDriverNameLength,
- clientDriverName);
- EPHYR_LOG ("leave\n") ;
+ WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRICreateContext (register ClientPtr client)
+ProcXF86DRICreateContext(register ClientPtr client)
{
- xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReply rep;
ScreenPtr pScreen;
VisualPtr visual;
- int i=0;
- unsigned long context_id=0;
+ int i = 0;
+ unsigned long context_id = 0;
+
REQUEST(xXF86DRICreateContextReq);
REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
+ client->errorValue = stuff->screen;
+ return BadValue;
}
rep.type = X_Reply;
@@ -755,205 +737,196 @@ ProcXF86DRICreateContext (register ClientPtr client)
/* Find the requested X visual */
for (i = 0; i < pScreen->numVisuals; i++, visual++)
- if (visual->vid == stuff->visual)
- break;
+ if (visual->vid == stuff->visual)
+ break;
if (i == pScreen->numVisuals) {
- /* No visual found */
- return BadValue;
+ /* No visual found */
+ return BadValue;
}
- context_id = stuff->context ;
- if (!ephyrDRICreateContext (stuff->screen,
- stuff->visual,
- &context_id,
- (drm_context_t *)&rep.hHWContext)) {
+ context_id = stuff->context;
+ if (!ephyrDRICreateContext(stuff->screen,
+ stuff->visual,
+ &context_id,
+ (drm_context_t *) & rep.hHWContext)) {
return BadValue;
}
- WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
- EPHYR_LOG ("leave\n") ;
+ WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *) &rep);
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIDestroyContext (register ClientPtr client)
+ProcXF86DRIDestroyContext(register ClientPtr client)
{
REQUEST(xXF86DRIDestroyContextReq);
REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
client->errorValue = stuff->screen;
return BadValue;
}
- if (!ephyrDRIDestroyContext (stuff->screen, stuff->context)) {
- return BadValue;
- }
+ if (!ephyrDRIDestroyContext(stuff->screen, stuff->context)) {
+ return BadValue;
+ }
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return Success;
}
static Bool
-getWindowVisual (const WindowPtr a_win,
- VisualPtr *a_visual)
+getWindowVisual(const WindowPtr a_win, VisualPtr * a_visual)
{
- int i=0, visual_id=0 ;
- EPHYR_RETURN_VAL_IF_FAIL (a_win
- && a_win->drawable.pScreen
- && a_win->drawable.pScreen->visuals,
- FALSE) ;
-
- visual_id = wVisual (a_win) ;
- for (i=0; i < a_win->drawable.pScreen->numVisuals; i++) {
+ int i = 0, visual_id = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_win
+ && a_win->drawable.pScreen
+ && a_win->drawable.pScreen->visuals, FALSE);
+
+ visual_id = wVisual(a_win);
+ for (i = 0; i < a_win->drawable.pScreen->numVisuals; i++) {
if (a_win->drawable.pScreen->visuals[i].vid == visual_id) {
- *a_visual = &a_win->drawable.pScreen->visuals[i] ;
- return TRUE ;
+ *a_visual = &a_win->drawable.pScreen->visuals[i];
+ return TRUE;
}
}
- return FALSE ;
+ return FALSE;
}
-
#define NUM_WINDOW_PAIRS 256
-static EphyrWindowPair window_pairs[NUM_WINDOW_PAIRS] ;
+static EphyrWindowPair window_pairs[NUM_WINDOW_PAIRS];
static Bool
-appendWindowPairToList (WindowPtr a_local,
- int a_remote)
+appendWindowPairToList(WindowPtr a_local, int a_remote)
{
- int i=0 ;
+ int i = 0;
- EPHYR_RETURN_VAL_IF_FAIL (a_local, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_local, FALSE);
- EPHYR_LOG ("(local,remote):(%p, %d)\n", a_local, a_remote) ;
+ EPHYR_LOG("(local,remote):(%p, %d)\n", a_local, a_remote);
- for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
if (window_pairs[i].local == NULL) {
- window_pairs[i].local = a_local ;
- window_pairs[i].remote = a_remote ;
- return TRUE ;
+ window_pairs[i].local = a_local;
+ window_pairs[i].remote = a_remote;
+ return TRUE;
}
}
- return FALSE ;
+ return FALSE;
}
static Bool
-findWindowPairFromLocal (WindowPtr a_local,
- EphyrWindowPair **a_pair)
+findWindowPairFromLocal(WindowPtr a_local, EphyrWindowPair ** a_pair)
{
- int i=0 ;
+ int i = 0;
- EPHYR_RETURN_VAL_IF_FAIL (a_pair && a_local, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_pair && a_local, FALSE);
- for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
if (window_pairs[i].local == a_local) {
- *a_pair = &window_pairs[i] ;
- EPHYR_LOG ("found (%p, %d)\n",
- (*a_pair)->local,
- (*a_pair)->remote) ;
- return TRUE ;
+ *a_pair = &window_pairs[i];
+ EPHYR_LOG("found (%p, %d)\n", (*a_pair)->local, (*a_pair)->remote);
+ return TRUE;
}
}
- return FALSE ;
+ return FALSE;
}
Bool
-findWindowPairFromRemote (int a_remote,
- EphyrWindowPair **a_pair)
+findWindowPairFromRemote(int a_remote, EphyrWindowPair ** a_pair)
{
- int i=0 ;
+ int i = 0;
- EPHYR_RETURN_VAL_IF_FAIL (a_pair, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_pair, FALSE);
- for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ for (i = 0; i < NUM_WINDOW_PAIRS; i++) {
if (window_pairs[i].remote == a_remote) {
- *a_pair = &window_pairs[i] ;
- EPHYR_LOG ("found (%p, %d)\n",
- (*a_pair)->local,
- (*a_pair)->remote) ;
- return TRUE ;
+ *a_pair = &window_pairs[i];
+ EPHYR_LOG("found (%p, %d)\n", (*a_pair)->local, (*a_pair)->remote);
+ return TRUE;
}
}
- return FALSE ;
+ return FALSE;
}
static Bool
-createHostPeerWindow (const WindowPtr a_win,
- int *a_peer_win)
+createHostPeerWindow(const WindowPtr a_win, int *a_peer_win)
{
- Bool is_ok=FALSE ;
- VisualPtr visual=NULL;
- EphyrBox geo ;
+ Bool is_ok = FALSE;
+ VisualPtr visual = NULL;
+ EphyrBox geo;
- EPHYR_RETURN_VAL_IF_FAIL (a_win && a_peer_win, FALSE) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_win->drawable.pScreen,
- FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_win && a_peer_win, FALSE);
+ EPHYR_RETURN_VAL_IF_FAIL(a_win->drawable.pScreen, FALSE);
- EPHYR_LOG ("enter. a_win '%p'\n", a_win) ;
- if (!getWindowVisual (a_win, &visual)) {
- EPHYR_LOG_ERROR ("failed to get window visual\n") ;
- goto out ;
+ EPHYR_LOG("enter. a_win '%p'\n", a_win);
+ if (!getWindowVisual(a_win, &visual)) {
+ EPHYR_LOG_ERROR("failed to get window visual\n");
+ goto out;
}
if (!visual) {
- EPHYR_LOG_ERROR ("failed to create visual\n") ;
- goto out ;
- }
- memset (&geo, 0, sizeof (geo)) ;
- geo.x = a_win->drawable.x ;
- geo.y = a_win->drawable.y ;
- geo.width = a_win->drawable.width ;
- geo.height = a_win->drawable.height ;
- if (!hostx_create_window (a_win->drawable.pScreen->myNum,
- &geo, visual->vid, a_peer_win)) {
- EPHYR_LOG_ERROR ("failed to create host peer window\n") ;
- goto out ;
- }
- if (!appendWindowPairToList (a_win, *a_peer_win)) {
- EPHYR_LOG_ERROR ("failed to append window to pair list\n") ;
- goto out ;
- }
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("leave:remote win%d\n", *a_peer_win) ;
- return is_ok ;
+ EPHYR_LOG_ERROR("failed to create visual\n");
+ goto out;
+ }
+ memset(&geo, 0, sizeof(geo));
+ geo.x = a_win->drawable.x;
+ geo.y = a_win->drawable.y;
+ geo.width = a_win->drawable.width;
+ geo.height = a_win->drawable.height;
+ if (!hostx_create_window(a_win->drawable.pScreen->myNum,
+ &geo, visual->vid, a_peer_win)) {
+ EPHYR_LOG_ERROR("failed to create host peer window\n");
+ goto out;
+ }
+ if (!appendWindowPairToList(a_win, *a_peer_win)) {
+ EPHYR_LOG_ERROR("failed to append window to pair list\n");
+ goto out;
+ }
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave:remote win%d\n", *a_peer_win);
+ return is_ok;
}
static Bool
-destroyHostPeerWindow (const WindowPtr a_win)
+destroyHostPeerWindow(const WindowPtr a_win)
{
- Bool is_ok = FALSE ;
- EphyrWindowPair *pair=NULL ;
- EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
+ Bool is_ok = FALSE;
+ EphyrWindowPair *pair = NULL;
- EPHYR_LOG ("enter\n") ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_win, FALSE);
- if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
- EPHYR_LOG_ERROR ("failed to find peer to local window\n") ;
+ EPHYR_LOG("enter\n");
+
+ if (!findWindowPairFromLocal(a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR("failed to find peer to local window\n");
goto out;
}
- hostx_destroy_window (pair->remote) ;
- is_ok = TRUE ;
+ hostx_destroy_window(pair->remote);
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
+ out:
+ EPHYR_LOG("leave\n");
return is_ok;
}
static int
-ProcXF86DRICreateDrawable (ClientPtr client)
+ProcXF86DRICreateDrawable(ClientPtr client)
{
- xXF86DRICreateDrawableReply rep;
- DrawablePtr drawable=NULL;
- WindowPtr window=NULL ;
- EphyrWindowPair *pair=NULL ;
- EphyrDRIWindowPrivPtr win_priv=NULL;
- int rc=0, remote_win=0;
+ xXF86DRICreateDrawableReply rep;
+ DrawablePtr drawable = NULL;
+ WindowPtr window = NULL;
+ EphyrWindowPair *pair = NULL;
+ EphyrDRIWindowPrivPtr win_priv = NULL;
+ int rc = 0, remote_win = 0;
+
REQUEST(xXF86DRICreateDrawableReq);
REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
client->errorValue = stuff->screen;
return BadValue;
@@ -963,108 +936,107 @@ ProcXF86DRICreateDrawable (ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- rc = dixLookupDrawable (&drawable, stuff->drawable, client, 0,
- DixReadAccess);
+ rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
+ DixReadAccess);
if (rc != Success)
return rc;
if (drawable->type != DRAWABLE_WINDOW) {
- EPHYR_LOG_ERROR ("non drawable windows are not yet supported\n") ;
- return BadImplementation ;
- }
- EPHYR_LOG ("lookedup drawable %p\n", drawable) ;
- window = (WindowPtr)drawable;
- if (findWindowPairFromLocal (window, &pair) && pair) {
- remote_win = pair->remote ;
- EPHYR_LOG ("found window '%p' paire with remote '%d'\n",
- window, remote_win) ;
- } else if (!createHostPeerWindow (window, &remote_win)) {
- EPHYR_LOG_ERROR ("failed to create host peer window\n") ;
- return BadAlloc ;
- }
-
- if (!ephyrDRICreateDrawable (stuff->screen,
- remote_win,
- (drm_drawable_t *)&rep.hHWDrawable)) {
- EPHYR_LOG_ERROR ("failed to create dri drawable\n") ;
+ EPHYR_LOG_ERROR("non drawable windows are not yet supported\n");
+ return BadImplementation;
+ }
+ EPHYR_LOG("lookedup drawable %p\n", drawable);
+ window = (WindowPtr) drawable;
+ if (findWindowPairFromLocal(window, &pair) && pair) {
+ remote_win = pair->remote;
+ EPHYR_LOG("found window '%p' paire with remote '%d'\n",
+ window, remote_win);
+ }
+ else if (!createHostPeerWindow(window, &remote_win)) {
+ EPHYR_LOG_ERROR("failed to create host peer window\n");
+ return BadAlloc;
+ }
+
+ if (!ephyrDRICreateDrawable(stuff->screen,
+ remote_win,
+ (drm_drawable_t *) & rep.hHWDrawable)) {
+ EPHYR_LOG_ERROR("failed to create dri drawable\n");
return BadValue;
}
- win_priv = GET_EPHYR_DRI_WINDOW_PRIV (window) ;
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV(window);
if (!win_priv) {
- win_priv = calloc(1, sizeof (EphyrDRIWindowPrivRec)) ;
+ win_priv = calloc(1, sizeof(EphyrDRIWindowPrivRec));
if (!win_priv) {
- EPHYR_LOG_ERROR ("failed to allocate window private\n") ;
- return BadAlloc ;
+ EPHYR_LOG_ERROR("failed to allocate window private\n");
+ return BadAlloc;
}
- dixSetPrivate(&window->devPrivates, ephyrDRIWindowKey, win_priv);
- EPHYR_LOG ("paired window '%p' with remote '%d'\n",
- window, remote_win) ;
+ dixSetPrivate(&window->devPrivates, ephyrDRIWindowKey, win_priv);
+ EPHYR_LOG("paired window '%p' with remote '%d'\n", window, remote_win);
}
- WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
- EPHYR_LOG ("leave\n") ;
+ WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *) &rep);
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIDestroyDrawable (register ClientPtr client)
+ProcXF86DRIDestroyDrawable(register ClientPtr client)
{
- DrawablePtr drawable=NULL;
- WindowPtr window=NULL;
- EphyrWindowPair *pair=NULL;
- int rc=0;
+ DrawablePtr drawable = NULL;
+ WindowPtr window = NULL;
+ EphyrWindowPair *pair = NULL;
+ int rc = 0;
+
REQUEST(xXF86DRIDestroyDrawableReq);
REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
client->errorValue = stuff->screen;
return BadValue;
}
rc = dixLookupDrawable(&drawable,
- stuff->drawable,
- client,
- 0,
- DixReadAccess);
+ stuff->drawable, client, 0, DixReadAccess);
if (rc != Success)
return rc;
if (drawable->type != DRAWABLE_WINDOW) {
- EPHYR_LOG_ERROR ("non drawable windows are not yet supported\n") ;
- return BadImplementation ;
+ EPHYR_LOG_ERROR("non drawable windows are not yet supported\n");
+ return BadImplementation;
}
- window = (WindowPtr)drawable;
- if (!findWindowPairFromLocal (window, &pair) && pair) {
- EPHYR_LOG_ERROR ("failed to find pair window\n") ;
+ window = (WindowPtr) drawable;
+ if (!findWindowPairFromLocal(window, &pair) && pair) {
+ EPHYR_LOG_ERROR("failed to find pair window\n");
return BadImplementation;
}
if (!ephyrDRIDestroyDrawable(stuff->screen,
- pair->remote/*drawable in host x*/)) {
- EPHYR_LOG_ERROR ("failed to destroy dri drawable\n") ;
+ pair->remote /*drawable in host x */ )) {
+ EPHYR_LOG_ERROR("failed to destroy dri drawable\n");
return BadImplementation;
}
- pair->local=NULL ;
- pair->remote=0;
+ pair->local = NULL;
+ pair->remote = 0;
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIGetDrawableInfo (register ClientPtr client)
+ProcXF86DRIGetDrawableInfo(register ClientPtr client)
{
xXF86DRIGetDrawableInfoReply rep;
DrawablePtr drawable;
- WindowPtr window=NULL;
- EphyrWindowPair *pair=NULL;
- int X=0, Y=0, W=0, H=0, backX=0, backY=0, rc=0, i=0;
- drm_clip_rect_t *clipRects=NULL;
- drm_clip_rect_t *backClipRects=NULL;
+ WindowPtr window = NULL;
+ EphyrWindowPair *pair = NULL;
+ int X = 0, Y = 0, W = 0, H = 0, backX = 0, backY = 0, rc = 0, i = 0;
+ drm_clip_rect_t *clipRects = NULL;
+ drm_clip_rect_t *backClipRects = NULL;
+
REQUEST(xXF86DRIGetDrawableInfoReq);
REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
- EPHYR_LOG ("enter\n") ;
- memset (&rep, 0, sizeof (rep)) ;
+ EPHYR_LOG("enter\n");
+ memset(&rep, 0, sizeof(rep));
if (stuff->screen >= screenInfo.numScreens) {
client->errorValue = stuff->screen;
return BadValue;
@@ -1077,123 +1049,125 @@ ProcXF86DRIGetDrawableInfo (register ClientPtr client)
rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
DixReadAccess);
if (rc != Success || !drawable) {
- EPHYR_LOG_ERROR ("could not get drawable\n") ;
+ EPHYR_LOG_ERROR("could not get drawable\n");
return rc;
}
if (drawable->type != DRAWABLE_WINDOW) {
- EPHYR_LOG_ERROR ("non windows type drawables are not yes supported\n") ;
- return BadImplementation ;
- }
- window = (WindowPtr)drawable ;
- memset (&pair, 0, sizeof (pair)) ;
- if (!findWindowPairFromLocal (window, &pair) || !pair) {
- EPHYR_LOG_ERROR ("failed to find remote peer drawable\n") ;
- return BadMatch ;
- }
- EPHYR_LOG ("clip list of xephyr gl drawable:\n") ;
- for (i=0; i < RegionNumRects (&window->clipList); i++) {
- EPHYR_LOG ("x1:%d, y1:%d, x2:%d, y2:%d\n",
- RegionRects (&window->clipList)[i].x1,
- RegionRects (&window->clipList)[i].y1,
- RegionRects (&window->clipList)[i].x2,
- RegionRects (&window->clipList)[i].y2) ;
- }
-
- if (!ephyrDRIGetDrawableInfo (stuff->screen,
- pair->remote/*the drawable in hostx*/,
- (unsigned int*)&rep.drawableTableIndex,
- (unsigned int*)&rep.drawableTableStamp,
- (int*)&X,
- (int*)&Y,
- (int*)&W,
- (int*)&H,
- (int*)&rep.numClipRects,
- &clipRects,
- &backX,
- &backY,
- (int*)&rep.numBackClipRects,
- &backClipRects)) {
+ EPHYR_LOG_ERROR("non windows type drawables are not yes supported\n");
+ return BadImplementation;
+ }
+ window = (WindowPtr) drawable;
+ memset(&pair, 0, sizeof(pair));
+ if (!findWindowPairFromLocal(window, &pair) || !pair) {
+ EPHYR_LOG_ERROR("failed to find remote peer drawable\n");
+ return BadMatch;
+ }
+ EPHYR_LOG("clip list of xephyr gl drawable:\n");
+ for (i = 0; i < RegionNumRects(&window->clipList); i++) {
+ EPHYR_LOG("x1:%d, y1:%d, x2:%d, y2:%d\n",
+ RegionRects(&window->clipList)[i].x1,
+ RegionRects(&window->clipList)[i].y1,
+ RegionRects(&window->clipList)[i].x2,
+ RegionRects(&window->clipList)[i].y2);
+ }
+
+ if (!ephyrDRIGetDrawableInfo(stuff->screen,
+ pair->remote /*the drawable in hostx */ ,
+ (unsigned int *) &rep.drawableTableIndex,
+ (unsigned int *) &rep.drawableTableStamp,
+ (int *) &X,
+ (int *) &Y,
+ (int *) &W,
+ (int *) &H,
+ (int *) &rep.numClipRects,
+ &clipRects,
+ &backX,
+ &backY,
+ (int *) &rep.numBackClipRects,
+ &backClipRects)) {
return BadValue;
}
- EPHYR_LOG ("num clip rects:%d, num back clip rects:%d\n",
- (int)rep.numClipRects, (int)rep.numBackClipRects) ;
+ EPHYR_LOG("num clip rects:%d, num back clip rects:%d\n",
+ (int) rep.numClipRects, (int) rep.numBackClipRects);
rep.drawableX = X;
rep.drawableY = Y;
rep.drawableWidth = W;
rep.drawableHeight = H;
- rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
- SIZEOF(xGenericReply));
+ rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply));
rep.backX = backX;
rep.backY = backY;
-
if (rep.numClipRects) {
if (clipRects) {
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
- int i=0;
- EPHYR_LOG ("clip list of host gl drawable:\n") ;
+ int i = 0;
+
+ EPHYR_LOG("clip list of host gl drawable:\n");
for (i = 0; i < rep.numClipRects; i++) {
- clipRects[i].x1 = max (clipRects[i].x1, 0);
- clipRects[i].y1 = max (clipRects[i].y1, 0);
- clipRects[i].x2 = min (clipRects[i].x2,
- pScreen->width + clipRects[i].x1) ;
- clipRects[i].y2 = min (clipRects[i].y2,
- pScreen->width + clipRects[i].y1) ;
-
- EPHYR_LOG ("x1:%d, y1:%d, x2:%d, y2:%d\n",
- clipRects[i].x1, clipRects[i].y1,
- clipRects[i].x2, clipRects[i].y2) ;
+ clipRects[i].x1 = max(clipRects[i].x1, 0);
+ clipRects[i].y1 = max(clipRects[i].y1, 0);
+ clipRects[i].x2 = min(clipRects[i].x2,
+ pScreen->width + clipRects[i].x1);
+ clipRects[i].y2 = min(clipRects[i].y2,
+ pScreen->width + clipRects[i].y1);
+
+ EPHYR_LOG("x1:%d, y1:%d, x2:%d, y2:%d\n",
+ clipRects[i].x1, clipRects[i].y1,
+ clipRects[i].x2, clipRects[i].y2);
}
- } else {
+ }
+ else {
rep.numClipRects = 0;
}
- } else {
- EPHYR_LOG ("got zero host gl drawable clipping rects\n") ;
+ }
+ else {
+ EPHYR_LOG("got zero host gl drawable clipping rects\n");
}
rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
- backClipRects = clipRects ;
- rep.numBackClipRects = rep.numClipRects ;
+ backClipRects = clipRects;
+ rep.numBackClipRects = rep.numClipRects;
if (rep.numBackClipRects)
rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
- EPHYR_LOG ("num host clip rects:%d\n", (int)rep.numClipRects) ;
- EPHYR_LOG ("num host back clip rects:%d\n", (int)rep.numBackClipRects) ;
+ EPHYR_LOG("num host clip rects:%d\n", (int) rep.numClipRects);
+ EPHYR_LOG("num host back clip rects:%d\n", (int) rep.numBackClipRects);
rep.length = bytes_to_int32(rep.length);
- WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *) &rep);
if (rep.numClipRects) {
WriteToClient(client,
sizeof(drm_clip_rect_t) * rep.numClipRects,
- (char *)clipRects);
+ (char *) clipRects);
}
if (rep.numBackClipRects) {
WriteToClient(client,
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
- (char *)backClipRects);
+ (char *) backClipRects);
}
free(clipRects);
- clipRects = NULL ;
+ clipRects = NULL;
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIGetDeviceInfo (register ClientPtr client)
+ProcXF86DRIGetDeviceInfo(register ClientPtr client)
{
- xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReply rep;
drm_handle_t hFrameBuffer;
void *pDevPrivate;
+
REQUEST(xXF86DRIGetDeviceInfoReq);
REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (stuff->screen >= screenInfo.numScreens) {
client->errorValue = stuff->screen;
return BadValue;
@@ -1203,19 +1177,18 @@ ProcXF86DRIGetDeviceInfo (register ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- if (!ephyrDRIGetDeviceInfo (stuff->screen,
- &hFrameBuffer,
- (int*)&rep.framebufferOrigin,
- (int*)&rep.framebufferSize,
- (int*)&rep.framebufferStride,
- (int*)&rep.devPrivateSize,
- &pDevPrivate)) {
+ if (!ephyrDRIGetDeviceInfo(stuff->screen,
+ &hFrameBuffer,
+ (int *) &rep.framebufferOrigin,
+ (int *) &rep.framebufferSize,
+ (int *) &rep.framebufferStride,
+ (int *) &rep.devPrivateSize, &pDevPrivate)) {
return BadValue;
}
- rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
+ rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
#if defined(LONG64) && !defined(__linux__)
- rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
+ rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
#else
rep.hFrameBufferHigh = 0;
#endif
@@ -1223,91 +1196,89 @@ ProcXF86DRIGetDeviceInfo (register ClientPtr client)
rep.length = 0;
if (rep.devPrivateSize) {
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.devPrivateSize));
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.devPrivateSize));
}
- WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
+ WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *) &rep);
if (rep.length) {
- WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
+ WriteToClient(client, rep.devPrivateSize, (char *) pDevPrivate);
}
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return Success;
}
static int
-ProcXF86DRIDispatch (register ClientPtr client)
+ProcXF86DRIDispatch(register ClientPtr client)
{
REQUEST(xReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
- switch (stuff->data)
- {
- case X_XF86DRIQueryVersion: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIQueryVersion(client);
- }
- case X_XF86DRIQueryDirectRenderingCapable: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIQueryDirectRenderingCapable(client);
- }
+ switch (stuff->data) {
+ case X_XF86DRIQueryVersion:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIQueryVersion(client);
+ }
+ case X_XF86DRIQueryDirectRenderingCapable:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
+ }
}
if (!LocalClient(client))
return DRIErrorBase + XF86DRIClientNotLocal;
- switch (stuff->data)
- {
- case X_XF86DRIOpenConnection: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIOpenConnection(client);
- }
- case X_XF86DRICloseConnection: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRICloseConnection(client);
- }
- case X_XF86DRIGetClientDriverName: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIGetClientDriverName(client);
- }
- case X_XF86DRICreateContext: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRICreateContext(client);
- }
- case X_XF86DRIDestroyContext: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIDestroyContext(client);
- }
- case X_XF86DRICreateDrawable: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRICreateDrawable(client);
- }
- case X_XF86DRIDestroyDrawable: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIDestroyDrawable(client);
- }
- case X_XF86DRIGetDrawableInfo: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIGetDrawableInfo(client);
- }
- case X_XF86DRIGetDeviceInfo: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIGetDeviceInfo(client);
- }
- case X_XF86DRIAuthConnection: {
- EPHYR_LOG ("leave\n") ;
- return ProcXF86DRIAuthConnection(client);
- }
- /* {Open,Close}FullScreen are deprecated now */
- default: {
- EPHYR_LOG ("leave\n") ;
- return BadRequest;
- }
+ switch (stuff->data) {
+ case X_XF86DRIOpenConnection:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIOpenConnection(client);
+ }
+ case X_XF86DRICloseConnection:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRICloseConnection(client);
+ }
+ case X_XF86DRIGetClientDriverName:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIGetClientDriverName(client);
+ }
+ case X_XF86DRICreateContext:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRICreateContext(client);
+ }
+ case X_XF86DRIDestroyContext:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIDestroyContext(client);
+ }
+ case X_XF86DRICreateDrawable:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRICreateDrawable(client);
+ }
+ case X_XF86DRIDestroyDrawable:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIDestroyDrawable(client);
+ }
+ case X_XF86DRIGetDrawableInfo:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIGetDrawableInfo(client);
+ }
+ case X_XF86DRIGetDeviceInfo:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIGetDeviceInfo(client);
+ }
+ case X_XF86DRIAuthConnection:{
+ EPHYR_LOG("leave\n");
+ return ProcXF86DRIAuthConnection(client);
+ }
+ /* {Open,Close}FullScreen are deprecated now */
+ default:{
+ EPHYR_LOG("leave\n");
+ return BadRequest;
+ }
}
}
static int
-SProcXF86DRIQueryVersion (register ClientPtr client)
+SProcXF86DRIQueryVersion(register ClientPtr client)
{
REQUEST(xXF86DRIQueryVersionReq);
swaps(&stuff->length);
@@ -1315,7 +1286,7 @@ SProcXF86DRIQueryVersion (register ClientPtr client)
}
static int
-SProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
+SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
{
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
swaps(&stuff->length);
@@ -1324,90 +1295,89 @@ SProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
}
static int
-SProcXF86DRIDispatch (register ClientPtr client)
+SProcXF86DRIDispatch(register ClientPtr client)
{
REQUEST(xReq);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
/*
* Only local clients are allowed DRI access, but remote clients still need
* these requests to find out cleanly.
*/
- switch (stuff->data)
- {
- case X_XF86DRIQueryVersion: {
- EPHYR_LOG ("leave\n") ;
- return SProcXF86DRIQueryVersion(client);
- }
- case X_XF86DRIQueryDirectRenderingCapable: {
- EPHYR_LOG ("leave\n") ;
- return SProcXF86DRIQueryDirectRenderingCapable(client);
- }
- default: {
- EPHYR_LOG ("leave\n") ;
- return DRIErrorBase + XF86DRIClientNotLocal;
- }
+ switch (stuff->data) {
+ case X_XF86DRIQueryVersion:{
+ EPHYR_LOG("leave\n");
+ return SProcXF86DRIQueryVersion(client);
+ }
+ case X_XF86DRIQueryDirectRenderingCapable:{
+ EPHYR_LOG("leave\n");
+ return SProcXF86DRIQueryDirectRenderingCapable(client);
+ }
+ default:{
+ EPHYR_LOG("leave\n");
+ return DRIErrorBase + XF86DRIClientNotLocal;
+ }
}
}
Bool
-ephyrDRIExtensionInit (ScreenPtr a_screen)
+ephyrDRIExtensionInit(ScreenPtr a_screen)
{
- Bool is_ok=FALSE ;
- ExtensionEntry* extEntry=NULL;
- EphyrDRIScreenPrivPtr screen_priv=NULL ;
+ Bool is_ok = FALSE;
+ ExtensionEntry *extEntry = NULL;
+ EphyrDRIScreenPrivPtr screen_priv = NULL;
- EPHYR_LOG ("enter\n") ;
- if (!hostx_has_dri ()) {
- EPHYR_LOG ("host does not have DRI extension\n") ;
- goto out ;
+ EPHYR_LOG("enter\n");
+ if (!hostx_has_dri()) {
+ EPHYR_LOG("host does not have DRI extension\n");
+ goto out;
}
- EPHYR_LOG ("host X does have DRI extension\n") ;
- if (!hostx_has_xshape ()) {
- EPHYR_LOG ("host does not have XShape extension\n") ;
- goto out ;
+ EPHYR_LOG("host X does have DRI extension\n");
+ if (!hostx_has_xshape()) {
+ EPHYR_LOG("host does not have XShape extension\n");
+ goto out;
}
- EPHYR_LOG ("host X does have XShape extension\n") ;
+ EPHYR_LOG("host X does have XShape extension\n");
#ifdef XF86DRI_EVENTS
- EventType = CreateNewResourceType (XF86DRIFreeEvents, "DRIEvents");
+ EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvents");
if (!EventType) {
- EPHYR_LOG_ERROR ("failed to register DRI event resource type\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to register DRI event resource type\n");
+ goto out;
}
#endif
if ((extEntry = AddExtension(XF86DRINAME,
- XF86DRINumberEvents,
- XF86DRINumberErrors,
- ProcXF86DRIDispatch,
- SProcXF86DRIDispatch,
- NULL,
- StandardMinorOpcode))) {
- DRIReqCode = (unsigned char)extEntry->base;
- DRIErrorBase = extEntry->errorBase;
- } else {
- EPHYR_LOG_ERROR ("failed to register DRI extension\n") ;
- goto out ;
+ XF86DRINumberEvents,
+ XF86DRINumberErrors,
+ ProcXF86DRIDispatch,
+ SProcXF86DRIDispatch,
+ NULL, StandardMinorOpcode))) {
+ DRIReqCode = (unsigned char) extEntry->base;
+ DRIErrorBase = extEntry->errorBase;
+ }
+ else {
+ EPHYR_LOG_ERROR("failed to register DRI extension\n");
+ goto out;
}
if (!dixRegisterPrivateKey(&ephyrDRIScreenKeyRec, PRIVATE_SCREEN, 0))
- goto out ;
+ goto out;
if (!dixRegisterPrivateKey(&ephyrDRIWindowKeyRec, PRIVATE_WINDOW, 0))
- goto out ;
- screen_priv = calloc(1, sizeof (EphyrDRIScreenPrivRec)) ;
+ goto out;
+ screen_priv = calloc(1, sizeof(EphyrDRIScreenPrivRec));
if (!screen_priv) {
- EPHYR_LOG_ERROR ("failed to allocate screen_priv\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to allocate screen_priv\n");
+ goto out;
}
dixSetPrivate(&a_screen->devPrivates, ephyrDRIScreenKey, screen_priv);
- if (!ephyrDRIScreenInit (a_screen)) {
- EPHYR_LOG_ERROR ("ephyrDRIScreenInit() failed\n") ;
- goto out ;
+ if (!ephyrDRIScreenInit(a_screen)) {
+ EPHYR_LOG_ERROR("ephyrDRIScreenInit() failed\n");
+ goto out;
}
- EphyrMirrorHostVisuals (a_screen) ;
- is_ok=TRUE ;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ EphyrMirrorHostVisuals(a_screen);
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.h b/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
index 01c9421fb..5808576fe 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
@@ -29,14 +29,12 @@
#define __EPHYRDRIEXT_H__
typedef struct {
- WindowPtr local ;
- int remote ;
+ WindowPtr local;
+ int remote;
} EphyrWindowPair;
-Bool ephyrDRIExtensionInit (ScreenPtr a_screen) ;
+Bool ephyrDRIExtensionInit(ScreenPtr a_screen);
-Bool findWindowPairFromRemote (int a_remote,
- EphyrWindowPair **a_pair);
+Bool findWindowPairFromRemote(int a_remote, EphyrWindowPair ** a_pair);
#endif /*__EPHYRDRIEXT_H__*/
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
index d6b8ca66d..dab028bf3 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
@@ -1,723 +1,711 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include "extnsionst.h"
-#include "ephyrglxext.h"
-#include "ephyrhostglx.h"
-#define _HAVE_XALLOC_DECLS
-#include "ephyrlog.h"
-#include <GL/glxproto.h>
-#include "glx/glxserver.h"
-#include "glx/indirect_table.h"
-#include "glx/indirect_util.h"
-#include "glx/unpack.h"
-#include "hostx.h"
-
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-
-int ephyrGLXQueryVersion (__GLXclientState *cl, GLbyte *pc) ;
-int ephyrGLXQueryVersionSwap (__GLXclientState *cl, GLbyte *pc) ;
-int ephyrGLXGetVisualConfigs (__GLXclientState *cl, GLbyte *pc) ;
-int ephyrGLXGetVisualConfigsSwap (__GLXclientState *cl, GLbyte *pc) ;
-int ephyrGLXClientInfo(__GLXclientState *cl, GLbyte *pc) ;
-int ephyrGLXClientInfoSwap(__GLXclientState *cl, GLbyte *pc) ;
-int ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXQueryServerStringSwap(__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXGetFBConfigsSGIX (__GLXclientState *a_cl, GLbyte *a_pc);
-int ephyrGLXGetFBConfigsSGIXSwap (__GLXclientState *a_cl, GLbyte *a_pc);
-int ephyrGLXCreateContext (__GLXclientState *a_cl, GLbyte *a_pc);
-int ephyrGLXCreateContextSwap (__GLXclientState *a_cl, GLbyte *a_pc);
-int ephyrGLXDestroyContext (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXDestroyContextSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXMakeCurrent (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXMakeCurrentSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXGetString (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXGetStringSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXGetIntegerv (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXGetIntegervSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXIsDirect (__GLXclientState *a_cl, GLbyte *a_pc) ;
-int ephyrGLXIsDirectSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
-
-Bool
-ephyrHijackGLXExtension (void)
-{
- const void *(*dispatch_functions)[2];
-
- if (!hostx_has_glx ()) {
- EPHYR_LOG ("host X does not have GLX\n") ;
- return FALSE ;
- }
- EPHYR_LOG ("host X does have GLX\n") ;
-
- if (!Single_dispatch_info.dispatch_functions) {
- EPHYR_LOG_ERROR ("could not get dispatch functions table\n") ;
- return FALSE ;
- }
- /*
- * hijack some single entry point dispatch functions
- */
- dispatch_functions = Single_dispatch_info.dispatch_functions ;
- EPHYR_RETURN_VAL_IF_FAIL (dispatch_functions, FALSE) ;
-
- dispatch_functions[X_GLXQueryVersion][0] = ephyrGLXQueryVersion ;
- dispatch_functions[X_GLXQueryVersion][1] = ephyrGLXQueryVersionSwap ;
-
- dispatch_functions[X_GLXGetVisualConfigs][0] = ephyrGLXGetVisualConfigs ;
- dispatch_functions[X_GLXGetVisualConfigs][1] = ephyrGLXGetVisualConfigsSwap ;
- dispatch_functions[X_GLXClientInfo][0] = ephyrGLXClientInfo ;
- dispatch_functions[X_GLXClientInfo][1] = ephyrGLXClientInfoSwap ;
-
- dispatch_functions[X_GLXQueryServerString][0] = ephyrGLXQueryServerString ;
- dispatch_functions[X_GLXQueryServerString][1] =
- ephyrGLXQueryServerStringSwap ;
-
- dispatch_functions[X_GLXCreateContext][0] = ephyrGLXCreateContext ;
- dispatch_functions[X_GLXCreateContext][1] = ephyrGLXCreateContextSwap ;
-
- dispatch_functions[X_GLXDestroyContext][0] = ephyrGLXDestroyContext ;
- dispatch_functions[X_GLXDestroyContext][1] = ephyrGLXDestroyContextSwap ;
-
- dispatch_functions[X_GLXMakeCurrent][0] = ephyrGLXMakeCurrent ;
- dispatch_functions[X_GLXMakeCurrent][1] = ephyrGLXMakeCurrentSwap ;
-
- dispatch_functions[X_GLXIsDirect][0] = ephyrGLXIsDirect ;
- dispatch_functions[X_GLXIsDirect][1] = ephyrGLXIsDirectSwap ;
-
- dispatch_functions[73][0] = ephyrGLXGetString ;
- dispatch_functions[73][1] = ephyrGLXGetStringSwap ;
-
- dispatch_functions[61][0] = ephyrGLXGetIntegerv ;
- dispatch_functions[61][1] = ephyrGLXGetIntegervSwap ;
-
- /*
- * hijack some vendor priv entry point dispatch functions
- */
- dispatch_functions = VendorPriv_dispatch_info.dispatch_functions ;
- dispatch_functions[92][0] = ephyrGLXGetFBConfigsSGIX;
- dispatch_functions[92][1] = ephyrGLXGetFBConfigsSGIXSwap;
- EPHYR_LOG ("hijacked glx entry points to forward requests to host X\n") ;
-
- return TRUE ;
-}
-
-/*********************
- * implementation of
- * hijacked GLX entry
- * points
- ********************/
-
-int
-ephyrGLXQueryVersion(__GLXclientState *a_cl, GLbyte *a_pc)
-{
- ClientPtr client = a_cl->client;
- xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
- xGLXQueryVersionReply reply;
- int major, minor;
- int res = BadImplementation ;
-
- EPHYR_LOG ("enter\n") ;
-
- major = req->majorVersion ;
- minor = req->minorVersion ;
-
- if (!ephyrHostGLXQueryVersion (&major, &minor)) {
- EPHYR_LOG_ERROR ("ephyrHostGLXQueryVersion() failed\n") ;
- goto out ;
- }
- EPHYR_LOG ("major:%d, minor:%d\n",
- major, minor);
- reply.majorVersion = major ;
- reply.minorVersion = minor ;
- reply.length = 0 ;
- reply.type = X_Reply ;
- reply.sequenceNumber = client->sequence ;
-
- if (client->swapped) {
- __glXSwapQueryVersionReply(client, &reply);
- } else {
- WriteToClient(client, sz_xGLXQueryVersionReply, (char *)&reply);
- }
-
- res = Success ;
-out:
- EPHYR_LOG ("leave\n") ;
- return res;
-}
-
-int
-ephyrGLXQueryVersionSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_SHORT (&req->length);
- __GLX_SWAP_INT (&req->majorVersion);
- __GLX_SWAP_INT (&req->minorVersion);
- return ephyrGLXQueryVersion (a_cl, a_pc) ;
-}
-
-static int
-ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl,
- GLbyte *a_pc,
- Bool a_do_swap)
-{
- xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
- ClientPtr client = a_cl->client;
- xGLXGetVisualConfigsReply reply;
- int32_t *props_buf=NULL, num_visuals=0,
- num_props=0, res=BadImplementation, i=0,
- props_per_visual_size=0,
- props_buf_size=0;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!ephyrHostGLXGetVisualConfigs (req->screen,
- &num_visuals,
- &num_props,
- &props_buf_size,
- &props_buf)) {
- EPHYR_LOG_ERROR ("ephyrHostGLXGetVisualConfigs() failed\n") ;
- goto out ;
- }
- EPHYR_LOG ("num_visuals:%d, num_props:%d\n", num_visuals, num_props) ;
-
- reply.numVisuals = num_visuals;
- reply.numProps = num_props;
- reply.length = (num_visuals *__GLX_SIZE_CARD32 * num_props) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.numVisuals);
- __GLX_SWAP_INT(&reply.numProps);
- __GLX_SWAP_INT_ARRAY (props_buf, num_props) ;
- }
- WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char*)&reply);
- props_per_visual_size = props_buf_size/num_visuals ;
- for (i=0; i < num_visuals; i++) {
- WriteToClient (client,
- props_per_visual_size,
- (char*)props_buf +i*props_per_visual_size);
- }
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- free(props_buf) ;
- props_buf = NULL ;
-
- return res ;
-}
-
-static int
-ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
- GLbyte *a_pc,
- Bool a_do_swap)
-{
- xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)a_pc;
- ClientPtr client = a_cl->client;
- xGLXGetVisualConfigsReply reply;
- int32_t *props_buf=NULL, num_visuals=0,
- num_props=0, res=BadImplementation, i=0,
- props_per_visual_size=0,
- props_buf_size=0;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX (req->screen,
- &num_visuals,
- &num_props,
- &props_buf_size,
- &props_buf)) {
- EPHYR_LOG_ERROR ("ephyrHostGLXGetVisualConfigs() failed\n") ;
- goto out ;
- }
- EPHYR_LOG ("num_visuals:%d, num_props:%d\n", num_visuals, num_props) ;
-
- reply.numVisuals = num_visuals;
- reply.numProps = num_props;
- reply.length = props_buf_size >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.numVisuals);
- __GLX_SWAP_INT(&reply.numProps);
- __GLX_SWAP_INT_ARRAY (props_buf, num_props) ;
- }
- WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char*)&reply);
- props_per_visual_size = props_buf_size/num_visuals ;
- for (i=0; i < num_visuals; i++) {
- WriteToClient (client,
- props_per_visual_size,
- &((char*)props_buf)[i*props_per_visual_size]);
- }
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- free(props_buf) ;
- props_buf = NULL ;
-
- return res ;
-}
-
-int
-ephyrGLXGetVisualConfigs (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetVisualConfigsReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXGetVisualConfigsSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetVisualConfigsReal (a_cl, a_pc, TRUE) ;
-}
-
-
-int
-ephyrGLXClientInfo(__GLXclientState *a_cl, GLbyte *a_pc)
-{
- int res=BadImplementation ;
- xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
-
- EPHYR_LOG ("enter\n") ;
- if (!ephyrHostGLXSendClientInfo (req->major, req->minor, (char*)req+1)) {
- EPHYR_LOG_ERROR ("failed to send client info to host\n") ;
- goto out ;
- }
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXClientInfoSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- xGLXClientInfoReq *req = (xGLXClientInfoReq *)a_pc;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_SHORT (&req->length);
- __GLX_SWAP_INT (&req->major);
- __GLX_SWAP_INT (&req->minor);
- __GLX_SWAP_INT (&req->numbytes);
-
- return ephyrGLXClientInfo (a_cl, a_pc) ;
-}
-
-int
-ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
-{
- int res = BadImplementation ;
- ClientPtr client = a_cl->client;
- xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
- xGLXQueryServerStringReply reply;
- char *server_string=NULL, *buf=NULL;
- int length=0 ;
-
- EPHYR_LOG ("enter\n") ;
- if (!ephyrHostGLXGetStringFromServer (req->screen,
- req->name,
- EPHYR_HOST_GLX_QueryServerString,
- &server_string)) {
- EPHYR_LOG_ERROR ("failed to query string from host\n") ;
- goto out ;
- }
- EPHYR_LOG ("string: %s\n", server_string) ;
- length= strlen (server_string) + 1;
- reply.type = X_Reply ;
- reply.sequenceNumber = client->sequence ;
- reply.length = __GLX_PAD (length) >> 2 ;
- reply.n = length ;
- buf = calloc(reply.length << 2, 1);
- if (!buf) {
- EPHYR_LOG_ERROR ("failed to allocate string\n;");
- return BadAlloc;
- }
- memcpy (buf, server_string, length);
-
- WriteToClient(client, sz_xGLXQueryServerStringReply, (char*)&reply);
- WriteToClient(client, (int)(reply.length << 2), server_string);
-
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- free(server_string) ;
- server_string = NULL;
-
- free(buf);
- buf = NULL;
-
- return res ;
-}
-
-int
-ephyrGLXQueryServerStringSwap(__GLXclientState *a_cl, GLbyte *a_pc)
-{
- EPHYR_LOG_ERROR ("not yet implemented\n") ;
- return BadImplementation ;
-}
-
-
-int
-ephyrGLXGetFBConfigsSGIX (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetFBConfigsSGIXReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXGetFBConfigsSGIXSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetFBConfigsSGIXReal (a_cl, a_pc, TRUE) ;
-}
-
-static int
-ephyrGLXCreateContextReal (xGLXCreateContextReq *a_req, Bool a_do_swap)
-{
- int res=BadImplementation;
- EphyrHostWindowAttributes host_w_attrs ;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_req, BadValue) ;
- EPHYR_LOG ("enter\n") ;
-
- if (a_do_swap) {
- __GLX_SWAP_SHORT(&a_req->length);
- __GLX_SWAP_INT(&a_req->context);
- __GLX_SWAP_INT(&a_req->visual);
- __GLX_SWAP_INT(&a_req->screen);
- __GLX_SWAP_INT(&a_req->shareList);
- }
-
- EPHYR_LOG ("context creation requested. localid:%d, "
- "screen:%d, visual:%d, direct:%d\n",
- (int)a_req->context, (int)a_req->screen,
- (int)a_req->visual, (int)a_req->isDirect) ;
-
- memset (&host_w_attrs, 0, sizeof (host_w_attrs)) ;
- if (!hostx_get_window_attributes (hostx_get_window (a_req->screen),
- &host_w_attrs)) {
- EPHYR_LOG_ERROR ("failed to get host window attrs\n") ;
- goto out ;
- }
-
- EPHYR_LOG ("host window visual id: %d\n", host_w_attrs.visualid) ;
-
- if (!ephyrHostGLXCreateContext (a_req->screen,
- host_w_attrs.visualid,
- a_req->context,
- a_req->shareList,
- a_req->isDirect)) {
- EPHYR_LOG_ERROR ("ephyrHostGLXCreateContext() failed\n") ;
- goto out ;
- }
- res = Success;
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXCreateContext (__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
-
- return ephyrGLXCreateContextReal (req, FALSE) ;
-}
-
-int ephyrGLXCreateContextSwap (__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
- return ephyrGLXCreateContextReal (req, TRUE) ;
-}
-
-static int
-ephyrGLXDestroyContextReal (__GLXclientState *a_cl,
- GLbyte *a_pc,
- Bool a_do_swap)
-{
- int res=BadImplementation;
- ClientPtr client = a_cl->client;
- xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) a_pc;
-
- EPHYR_LOG ("enter. id:%d\n", (int)req->context) ;
- if (!ephyrHostDestroyContext (req->context)) {
- EPHYR_LOG_ERROR ("ephyrHostDestroyContext() failed\n") ;
- client->errorValue = req->context ;
- goto out ;
- }
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXDestroyContext (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXDestroyContextReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXDestroyContextSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXDestroyContextReal (a_cl, a_pc, TRUE) ;
-}
-
-static int
-ephyrGLXMakeCurrentReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
-{
- int res=BadImplementation;
- xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
- xGLXMakeCurrentReply reply ;
- DrawablePtr drawable=NULL;
- int rc=0;
-
- EPHYR_LOG ("enter\n") ;
- rc = dixLookupDrawable (&drawable,
- req->drawable,
- a_cl->client,
- 0,
- DixReadAccess);
- EPHYR_RETURN_VAL_IF_FAIL (drawable, BadValue) ;
- EPHYR_RETURN_VAL_IF_FAIL (drawable->pScreen, BadValue) ;
- EPHYR_LOG ("screen nummber requested:%d\n",
- drawable->pScreen->myNum) ;
-
- memset (&reply, 0, sizeof (reply)) ;
- if (!ephyrHostGLXMakeCurrent (hostx_get_window (drawable->pScreen->myNum),
- req->context,
- req->oldContextTag,
- (int*)&reply.contextTag)) {
- EPHYR_LOG_ERROR ("ephyrHostGLXMakeCurrent() failed\n") ;
- goto out;
- }
- reply.length = 0;
- reply.type = X_Reply;
- reply.sequenceNumber = a_cl->client->sequence;
- if (a_do_swap) {
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.contextTag);
- }
- WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, (char *)&reply);
-
- res = Success ;
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXMakeCurrent (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXMakeCurrentReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXMakeCurrentSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXMakeCurrentReal (a_cl, a_pc, TRUE) ;
-}
-
-static int
-ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
-{
- ClientPtr client=NULL ;
- int context_tag=0, name=0, res=BadImplementation, length=0 ;
- char *string=NULL;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- client = a_cl->client ;
-
- if (a_do_swap) {
- __GLX_SWAP_INT (a_pc + 4);
- __GLX_SWAP_INT (a_pc + __GLX_SINGLE_HDR_SIZE);
- }
- context_tag = __GLX_GET_SINGLE_CONTEXT_TAG (a_pc) ;
- a_pc += __GLX_SINGLE_HDR_SIZE;
- name = *(GLenum*)(a_pc + 0);
- EPHYR_LOG ("context_tag:%d, name:%d\n", context_tag, name) ;
- if (!ephyrHostGLXGetStringFromServer (context_tag,
- name,
- EPHYR_HOST_GLX_GetString,
- &string)) {
- EPHYR_LOG_ERROR ("failed to get string from server\n") ;
- goto out ;
- }
- if (string) {
- length = strlen (string) + 1;
- EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ;
- } else {
- EPHYR_LOG ("got string: string (null)\n") ;
- }
- __GLX_BEGIN_REPLY (length);
- __GLX_PUT_SIZE (length);
- __GLX_SEND_HEADER ();
- if (a_do_swap) {
- __GLX_SWAP_REPLY_SIZE ();
- __GLX_SWAP_REPLY_HEADER ();
- }
- WriteToClient (client, length, (char *)string);
-
- res = Success ;
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXGetString (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetStringReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXGetStringSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetStringReal (a_cl, a_pc, TRUE) ;
-}
-
-static int
-ephyrGLXGetIntegervReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
-{
- int res=BadImplementation;
- xGLXSingleReq * const req = (xGLXSingleReq *) a_pc;
- GLenum int_name ;
- int value=0 ;
- GLint answer_buf_room[200];
- GLint *buf=NULL ;
-
- EPHYR_LOG ("enter\n") ;
-
- a_pc += __GLX_SINGLE_HDR_SIZE;
-
- int_name = *(GLenum*) (a_pc+0) ;
- if (!ephyrHostGetIntegerValue (req->contextTag, int_name, &value)) {
- EPHYR_LOG_ERROR ("ephyrHostGetIntegerValue() failed\n") ;
- goto out ;
- }
- buf = __glXGetAnswerBuffer (a_cl, sizeof (value),
- answer_buf_room,
- sizeof (answer_buf_room),
- 4) ;
-
- if (!buf) {
- EPHYR_LOG_ERROR ("failed to allocate reply buffer\n") ;
- res = BadAlloc ;
- goto out ;
- }
- __glXSendReply (a_cl->client, buf, 1, sizeof (value), GL_FALSE, 0) ;
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXGetIntegerv (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetIntegervReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXGetIntegervSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXGetIntegervReal (a_cl, a_pc, TRUE) ;
-}
-
-static int
-ephyrGLXIsDirectReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
-{
- int res=BadImplementation;
- ClientPtr client = a_cl->client;
- xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
- xGLXIsDirectReply reply;
- int is_direct=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, FALSE) ;
-
- EPHYR_LOG ("enter\n") ;
-
- memset (&reply, 0, sizeof (reply)) ;
- if (!ephyrHostIsContextDirect (req->context, (int*)&is_direct)) {
- EPHYR_LOG_ERROR ("ephyrHostIsContextDirect() failed\n") ;
- goto out ;
- }
- reply.isDirect = is_direct ;
- reply.length = 0;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
- res = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-int
-ephyrGLXIsDirect (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXIsDirectReal (a_cl, a_pc, FALSE) ;
-}
-
-int
-ephyrGLXIsDirectSwap (__GLXclientState *a_cl, GLbyte *a_pc)
-{
- return ephyrGLXIsDirectReal (a_cl, a_pc, TRUE) ;
-}
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include "extnsionst.h"
+#include "ephyrglxext.h"
+#include "ephyrhostglx.h"
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+#include <GL/glxproto.h>
+#include "glx/glxserver.h"
+#include "glx/indirect_table.h"
+#include "glx/indirect_util.h"
+#include "glx/unpack.h"
+#include "hostx.h"
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+int ephyrGLXQueryVersion(__GLXclientState * cl, GLbyte * pc);
+int ephyrGLXQueryVersionSwap(__GLXclientState * cl, GLbyte * pc);
+int ephyrGLXGetVisualConfigs(__GLXclientState * cl, GLbyte * pc);
+int ephyrGLXGetVisualConfigsSwap(__GLXclientState * cl, GLbyte * pc);
+int ephyrGLXClientInfo(__GLXclientState * cl, GLbyte * pc);
+int ephyrGLXClientInfoSwap(__GLXclientState * cl, GLbyte * pc);
+int ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXQueryServerStringSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXCreateContext(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXCreateContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXGetIntegervSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXIsDirect(__GLXclientState * a_cl, GLbyte * a_pc);
+int ephyrGLXIsDirectSwap(__GLXclientState * a_cl, GLbyte * a_pc);
+
+Bool
+ephyrHijackGLXExtension(void)
+{
+ const void *(*dispatch_functions)[2];
+
+ if (!hostx_has_glx()) {
+ EPHYR_LOG("host X does not have GLX\n");
+ return FALSE;
+ }
+ EPHYR_LOG("host X does have GLX\n");
+
+ if (!Single_dispatch_info.dispatch_functions) {
+ EPHYR_LOG_ERROR("could not get dispatch functions table\n");
+ return FALSE;
+ }
+ /*
+ * hijack some single entry point dispatch functions
+ */
+ dispatch_functions = Single_dispatch_info.dispatch_functions;
+ EPHYR_RETURN_VAL_IF_FAIL(dispatch_functions, FALSE);
+
+ dispatch_functions[X_GLXQueryVersion][0] = ephyrGLXQueryVersion;
+ dispatch_functions[X_GLXQueryVersion][1] = ephyrGLXQueryVersionSwap;
+
+ dispatch_functions[X_GLXGetVisualConfigs][0] = ephyrGLXGetVisualConfigs;
+ dispatch_functions[X_GLXGetVisualConfigs][1] = ephyrGLXGetVisualConfigsSwap;
+ dispatch_functions[X_GLXClientInfo][0] = ephyrGLXClientInfo;
+ dispatch_functions[X_GLXClientInfo][1] = ephyrGLXClientInfoSwap;
+
+ dispatch_functions[X_GLXQueryServerString][0] = ephyrGLXQueryServerString;
+ dispatch_functions[X_GLXQueryServerString][1] =
+ ephyrGLXQueryServerStringSwap;
+
+ dispatch_functions[X_GLXCreateContext][0] = ephyrGLXCreateContext;
+ dispatch_functions[X_GLXCreateContext][1] = ephyrGLXCreateContextSwap;
+
+ dispatch_functions[X_GLXDestroyContext][0] = ephyrGLXDestroyContext;
+ dispatch_functions[X_GLXDestroyContext][1] = ephyrGLXDestroyContextSwap;
+
+ dispatch_functions[X_GLXMakeCurrent][0] = ephyrGLXMakeCurrent;
+ dispatch_functions[X_GLXMakeCurrent][1] = ephyrGLXMakeCurrentSwap;
+
+ dispatch_functions[X_GLXIsDirect][0] = ephyrGLXIsDirect;
+ dispatch_functions[X_GLXIsDirect][1] = ephyrGLXIsDirectSwap;
+
+ dispatch_functions[73][0] = ephyrGLXGetString;
+ dispatch_functions[73][1] = ephyrGLXGetStringSwap;
+
+ dispatch_functions[61][0] = ephyrGLXGetIntegerv;
+ dispatch_functions[61][1] = ephyrGLXGetIntegervSwap;
+
+ /*
+ * hijack some vendor priv entry point dispatch functions
+ */
+ dispatch_functions = VendorPriv_dispatch_info.dispatch_functions;
+ dispatch_functions[92][0] = ephyrGLXGetFBConfigsSGIX;
+ dispatch_functions[92][1] = ephyrGLXGetFBConfigsSGIXSwap;
+ EPHYR_LOG("hijacked glx entry points to forward requests to host X\n");
+
+ return TRUE;
+}
+
+/*********************
+ * implementation of
+ * hijacked GLX entry
+ * points
+ ********************/
+
+int
+ephyrGLXQueryVersion(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ ClientPtr client = a_cl->client;
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
+ xGLXQueryVersionReply reply;
+ int major, minor;
+ int res = BadImplementation;
+
+ EPHYR_LOG("enter\n");
+
+ major = req->majorVersion;
+ minor = req->minorVersion;
+
+ if (!ephyrHostGLXQueryVersion(&major, &minor)) {
+ EPHYR_LOG_ERROR("ephyrHostGLXQueryVersion() failed\n");
+ goto out;
+ }
+ EPHYR_LOG("major:%d, minor:%d\n", major, minor);
+ reply.majorVersion = major;
+ reply.minorVersion = minor;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapQueryVersionReply(client, &reply);
+ }
+ else {
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *) &reply);
+ }
+
+ res = Success;
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXQueryVersionSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->majorVersion);
+ __GLX_SWAP_INT(&req->minorVersion);
+ return ephyrGLXQueryVersion(a_cl, a_pc);
+}
+
+static int
+ephyrGLXGetVisualConfigsReal(__GLXclientState * a_cl,
+ GLbyte * a_pc, Bool a_do_swap)
+{
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
+ ClientPtr client = a_cl->client;
+ xGLXGetVisualConfigsReply reply;
+ int32_t *props_buf = NULL, num_visuals = 0,
+ num_props = 0, res = BadImplementation, i = 0,
+ props_per_visual_size = 0, props_buf_size = 0;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ EPHYR_LOG("enter\n");
+
+ if (!ephyrHostGLXGetVisualConfigs(req->screen,
+ &num_visuals,
+ &num_props,
+ &props_buf_size, &props_buf)) {
+ EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
+ goto out;
+ }
+ EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
+
+ reply.numVisuals = num_visuals;
+ reply.numProps = num_props;
+ reply.length = (num_visuals * __GLX_SIZE_CARD32 * num_props) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (a_do_swap) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ __GLX_SWAP_INT_ARRAY(props_buf, num_props);
+ }
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *) &reply);
+ props_per_visual_size = props_buf_size / num_visuals;
+ for (i = 0; i < num_visuals; i++) {
+ WriteToClient(client,
+ props_per_visual_size,
+ (char *) props_buf + i * props_per_visual_size);
+ }
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ free(props_buf);
+ props_buf = NULL;
+
+ return res;
+}
+
+static int
+ephyrGLXGetFBConfigsSGIXReal(__GLXclientState * a_cl,
+ GLbyte * a_pc, Bool a_do_swap)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) a_pc;
+ ClientPtr client = a_cl->client;
+ xGLXGetVisualConfigsReply reply;
+ int32_t *props_buf = NULL, num_visuals = 0,
+ num_props = 0, res = BadImplementation, i = 0,
+ props_per_visual_size = 0, props_buf_size = 0;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ EPHYR_LOG("enter\n");
+
+ if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX(req->screen,
+ &num_visuals,
+ &num_props,
+ &props_buf_size, &props_buf)) {
+ EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
+ goto out;
+ }
+ EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
+
+ reply.numVisuals = num_visuals;
+ reply.numProps = num_props;
+ reply.length = props_buf_size >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (a_do_swap) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ __GLX_SWAP_INT_ARRAY(props_buf, num_props);
+ }
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *) &reply);
+ props_per_visual_size = props_buf_size / num_visuals;
+ for (i = 0; i < num_visuals; i++) {
+ WriteToClient(client,
+ props_per_visual_size,
+ &((char *) props_buf)[i * props_per_visual_size]);
+ }
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ free(props_buf);
+ props_buf = NULL;
+
+ return res;
+}
+
+int
+ephyrGLXGetVisualConfigs(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetVisualConfigsReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXGetVisualConfigsSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetVisualConfigsReal(a_cl, a_pc, TRUE);
+}
+
+int
+ephyrGLXClientInfo(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ int res = BadImplementation;
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
+
+ EPHYR_LOG("enter\n");
+ if (!ephyrHostGLXSendClientInfo(req->major, req->minor, (char *) req + 1)) {
+ EPHYR_LOG_ERROR("failed to send client info to host\n");
+ goto out;
+ }
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXClientInfoSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->major);
+ __GLX_SWAP_INT(&req->minor);
+ __GLX_SWAP_INT(&req->numbytes);
+
+ return ephyrGLXClientInfo(a_cl, a_pc);
+}
+
+int
+ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ int res = BadImplementation;
+ ClientPtr client = a_cl->client;
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
+ xGLXQueryServerStringReply reply;
+ char *server_string = NULL, *buf = NULL;
+ int length = 0;
+
+ EPHYR_LOG("enter\n");
+ if (!ephyrHostGLXGetStringFromServer(req->screen,
+ req->name,
+ EPHYR_HOST_GLX_QueryServerString,
+ &server_string)) {
+ EPHYR_LOG_ERROR("failed to query string from host\n");
+ goto out;
+ }
+ EPHYR_LOG("string: %s\n", server_string);
+ length = strlen(server_string) + 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = __GLX_PAD(length) >> 2;
+ reply.n = length;
+ buf = calloc(reply.length << 2, 1);
+ if (!buf) {
+ EPHYR_LOG_ERROR("failed to allocate string\n;");
+ return BadAlloc;
+ }
+ memcpy(buf, server_string, length);
+
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *) &reply);
+ WriteToClient(client, (int) (reply.length << 2), server_string);
+
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ free(server_string);
+ server_string = NULL;
+
+ free(buf);
+ buf = NULL;
+
+ return res;
+}
+
+int
+ephyrGLXQueryServerStringSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ EPHYR_LOG_ERROR("not yet implemented\n");
+ return BadImplementation;
+}
+
+int
+ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetFBConfigsSGIXReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetFBConfigsSGIXReal(a_cl, a_pc, TRUE);
+}
+
+static int
+ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap)
+{
+ int res = BadImplementation;
+ EphyrHostWindowAttributes host_w_attrs;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue);
+ EPHYR_LOG("enter\n");
+
+ if (a_do_swap) {
+ __GLX_SWAP_SHORT(&a_req->length);
+ __GLX_SWAP_INT(&a_req->context);
+ __GLX_SWAP_INT(&a_req->visual);
+ __GLX_SWAP_INT(&a_req->screen);
+ __GLX_SWAP_INT(&a_req->shareList);
+ }
+
+ EPHYR_LOG("context creation requested. localid:%d, "
+ "screen:%d, visual:%d, direct:%d\n",
+ (int) a_req->context, (int) a_req->screen,
+ (int) a_req->visual, (int) a_req->isDirect);
+
+ memset(&host_w_attrs, 0, sizeof(host_w_attrs));
+ if (!hostx_get_window_attributes(hostx_get_window(a_req->screen),
+ &host_w_attrs)) {
+ EPHYR_LOG_ERROR("failed to get host window attrs\n");
+ goto out;
+ }
+
+ EPHYR_LOG("host window visual id: %d\n", host_w_attrs.visualid);
+
+ if (!ephyrHostGLXCreateContext(a_req->screen,
+ host_w_attrs.visualid,
+ a_req->context,
+ a_req->shareList, a_req->isDirect)) {
+ EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n");
+ goto out;
+ }
+ res = Success;
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXCreateContext(__GLXclientState * cl, GLbyte * pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+
+ return ephyrGLXCreateContextReal(req, FALSE);
+}
+
+int
+ephyrGLXCreateContextSwap(__GLXclientState * cl, GLbyte * pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+
+ return ephyrGLXCreateContextReal(req, TRUE);
+}
+
+static int
+ephyrGLXDestroyContextReal(__GLXclientState * a_cl,
+ GLbyte * a_pc, Bool a_do_swap)
+{
+ int res = BadImplementation;
+ ClientPtr client = a_cl->client;
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) a_pc;
+
+ EPHYR_LOG("enter. id:%d\n", (int) req->context);
+ if (!ephyrHostDestroyContext(req->context)) {
+ EPHYR_LOG_ERROR("ephyrHostDestroyContext() failed\n");
+ client->errorValue = req->context;
+ goto out;
+ }
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXDestroyContextReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXDestroyContextReal(a_cl, a_pc, TRUE);
+}
+
+static int
+ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
+{
+ int res = BadImplementation;
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
+ xGLXMakeCurrentReply reply;
+ DrawablePtr drawable = NULL;
+ int rc = 0;
+
+ EPHYR_LOG("enter\n");
+ rc = dixLookupDrawable(&drawable,
+ req->drawable, a_cl->client, 0, DixReadAccess);
+ EPHYR_RETURN_VAL_IF_FAIL(drawable, BadValue);
+ EPHYR_RETURN_VAL_IF_FAIL(drawable->pScreen, BadValue);
+ EPHYR_LOG("screen nummber requested:%d\n", drawable->pScreen->myNum);
+
+ memset(&reply, 0, sizeof(reply));
+ if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawable->pScreen->myNum),
+ req->context,
+ req->oldContextTag,
+ (int *) &reply.contextTag)) {
+ EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
+ goto out;
+ }
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = a_cl->client->sequence;
+ if (a_do_swap) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.contextTag);
+ }
+ WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, (char *) &reply);
+
+ res = Success;
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXMakeCurrentReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXMakeCurrentReal(a_cl, a_pc, TRUE);
+}
+
+static int
+ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
+{
+ ClientPtr client = NULL;
+ int context_tag = 0, name = 0, res = BadImplementation, length = 0;
+ char *string = NULL;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ client = a_cl->client;
+
+ if (a_do_swap) {
+ __GLX_SWAP_INT(a_pc + 4);
+ __GLX_SWAP_INT(a_pc + __GLX_SINGLE_HDR_SIZE);
+ }
+ context_tag = __GLX_GET_SINGLE_CONTEXT_TAG(a_pc);
+ a_pc += __GLX_SINGLE_HDR_SIZE;
+ name = *(GLenum *) (a_pc + 0);
+ EPHYR_LOG("context_tag:%d, name:%d\n", context_tag, name);
+ if (!ephyrHostGLXGetStringFromServer(context_tag,
+ name,
+ EPHYR_HOST_GLX_GetString, &string)) {
+ EPHYR_LOG_ERROR("failed to get string from server\n");
+ goto out;
+ }
+ if (string) {
+ length = strlen(string) + 1;
+ EPHYR_LOG("got string:'%s', size:%d\n", string, length);
+ }
+ else {
+ EPHYR_LOG("got string: string (null)\n");
+ }
+ __GLX_BEGIN_REPLY(length);
+ __GLX_PUT_SIZE(length);
+ __GLX_SEND_HEADER();
+ if (a_do_swap) {
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SWAP_REPLY_HEADER();
+ }
+ WriteToClient(client, length, (char *) string);
+
+ res = Success;
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetStringReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetStringReal(a_cl, a_pc, TRUE);
+}
+
+static int
+ephyrGLXGetIntegervReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
+{
+ int res = BadImplementation;
+ xGLXSingleReq *const req = (xGLXSingleReq *) a_pc;
+ GLenum int_name;
+ int value = 0;
+ GLint answer_buf_room[200];
+ GLint *buf = NULL;
+
+ EPHYR_LOG("enter\n");
+
+ a_pc += __GLX_SINGLE_HDR_SIZE;
+
+ int_name = *(GLenum *) (a_pc + 0);
+ if (!ephyrHostGetIntegerValue(req->contextTag, int_name, &value)) {
+ EPHYR_LOG_ERROR("ephyrHostGetIntegerValue() failed\n");
+ goto out;
+ }
+ buf = __glXGetAnswerBuffer(a_cl, sizeof(value),
+ answer_buf_room, sizeof(answer_buf_room), 4);
+
+ if (!buf) {
+ EPHYR_LOG_ERROR("failed to allocate reply buffer\n");
+ res = BadAlloc;
+ goto out;
+ }
+ __glXSendReply(a_cl->client, buf, 1, sizeof(value), GL_FALSE, 0);
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetIntegervReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXGetIntegervSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXGetIntegervReal(a_cl, a_pc, TRUE);
+}
+
+static int
+ephyrGLXIsDirectReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
+{
+ int res = BadImplementation;
+ ClientPtr client = a_cl->client;
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
+ xGLXIsDirectReply reply;
+ int is_direct = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, FALSE);
+
+ EPHYR_LOG("enter\n");
+
+ memset(&reply, 0, sizeof(reply));
+ if (!ephyrHostIsContextDirect(req->context, (int *) &is_direct)) {
+ EPHYR_LOG_ERROR("ephyrHostIsContextDirect() failed\n");
+ goto out;
+ }
+ reply.isDirect = is_direct;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *) &reply);
+ res = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+int
+ephyrGLXIsDirect(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXIsDirectReal(a_cl, a_pc, FALSE);
+}
+
+int
+ephyrGLXIsDirectSwap(__GLXclientState * a_cl, GLbyte * a_pc)
+{
+ return ephyrGLXIsDirectReal(a_cl, a_pc, TRUE);
+}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
index 728687b46..6b9da6fb1 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
@@ -56,79 +56,76 @@ enum VisualConfRequestType {
EPHYR_GET_FB_CONFIG,
EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
EPHYR_GET_VISUAL_CONFIGS
-
};
static Bool ephyrHostGLXGetVisualConfigsInternal
- (enum VisualConfRequestType a_type,
- int32_t a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf);
+ (enum VisualConfRequestType a_type,
+ int32_t a_screen,
+ int32_t * a_num_visuals,
+ int32_t * a_num_props, int32_t * a_props_buf_size, int32_t ** a_props_buf);
Bool
-ephyrHostGLXGetMajorOpcode (int *a_opcode)
+ephyrHostGLXGetMajorOpcode(int *a_opcode)
{
- Bool is_ok=FALSE ;
- Display *dpy=hostx_get_display () ;
- static int opcode ;
- int first_event_return=0, first_error_return=0;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ static int opcode;
+ int first_event_return = 0, first_error_return = 0;
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
- EPHYR_LOG ("enter\n") ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
+ EPHYR_LOG("enter\n");
if (!opcode) {
- if (!XQueryExtension (dpy, GLX_EXTENSION_NAME, &opcode,
- &first_event_return, &first_error_return)) {
- EPHYR_LOG_ERROR ("XQueryExtension() failed\n") ;
- goto out ;
+ if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &opcode,
+ &first_event_return, &first_error_return)) {
+ EPHYR_LOG_ERROR("XQueryExtension() failed\n");
+ goto out;
}
}
- *a_opcode = opcode ;
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("release\n") ;
- return is_ok ;
+ *a_opcode = opcode;
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("release\n");
+ return is_ok;
}
Bool
-ephyrHostGLXQueryVersion (int *a_major, int *a_minor)
+ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
{
- Bool is_ok = FALSE ;
- Display *dpy = hostx_get_display () ;
- int major_opcode=0;
- xGLXQueryVersionReq *req=NULL;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int major_opcode = 0;
+ xGLXQueryVersionReq *req = NULL;
xGLXQueryVersionReply reply;
- EPHYR_RETURN_VAL_IF_FAIL (a_major && a_minor, FALSE) ;
- EPHYR_LOG ("enter\n") ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_major && a_minor, FALSE);
+ EPHYR_LOG("enter\n");
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- EPHYR_LOG ("major opcode: %d\n", major_opcode) ;
+ EPHYR_LOG("major opcode: %d\n", major_opcode);
/* Send the glXQueryVersion request */
- memset (&reply, 0, sizeof (reply)) ;
- LockDisplay (dpy);
- GetReq (GLXQueryVersion, req);
+ memset(&reply, 0, sizeof(reply));
+ LockDisplay(dpy);
+ GetReq(GLXQueryVersion, req);
req->reqType = major_opcode;
req->glxCode = X_GLXQueryVersion;
req->majorVersion = 2;
req->minorVersion = 1;
- _XReply(dpy, (xReply*) &reply, 0, False);
- UnlockDisplay (dpy);
- SyncHandle ();
+ _XReply(dpy, (xReply *) & reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
- *a_major = reply.majorVersion ;
- *a_minor = reply.minorVersion ;
+ *a_major = reply.majorVersion;
+ *a_minor = reply.minorVersion;
- EPHYR_LOG ("major:%d, minor:%d\n", *a_major, *a_minor) ;
+ EPHYR_LOG("major:%d, minor:%d\n", *a_major, *a_minor);
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
/**
@@ -154,165 +151,161 @@ typedef struct GLXGenericGetString {
#define X_GLXGenericGetString 0
Bool
-ephyrHostGLXGetStringFromServer (int a_screen_number,
- int a_string_name,
- enum EphyrHostGLXGetStringOps a_op,
- char **a_string)
+ephyrHostGLXGetStringFromServer(int a_screen_number,
+ int a_string_name,
+ enum EphyrHostGLXGetStringOps a_op,
+ char **a_string)
{
- Bool is_ok=FALSE ;
- Display *dpy = hostx_get_display () ;
- int default_screen = DefaultScreen (dpy);
- xGLXGenericGetStringReq *req=NULL;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int default_screen = DefaultScreen(dpy);
+ xGLXGenericGetStringReq *req = NULL;
xGLXSingleReply reply;
- int length=0, numbytes=0, major_opcode=0, get_string_op=0;
+ int length = 0, numbytes = 0, major_opcode = 0, get_string_op = 0;
- EPHYR_RETURN_VAL_IF_FAIL (dpy && a_string, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy && a_string, FALSE);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
switch (a_op) {
- case EPHYR_HOST_GLX_QueryServerString:
- get_string_op = X_GLXQueryServerString;
- break ;
- case EPHYR_HOST_GLX_GetString:
- get_string_op = X_GLsop_GetString;
- EPHYR_LOG ("Going to glXGetString. strname:%#x, ctxttag:%d\n",
- a_string_name, a_screen_number) ;
- break ;
- default:
- EPHYR_LOG_ERROR ("unknown EphyrHostGLXGetStringOp:%d\n", a_op) ;
- goto out ;
+ case EPHYR_HOST_GLX_QueryServerString:
+ get_string_op = X_GLXQueryServerString;
+ break;
+ case EPHYR_HOST_GLX_GetString:
+ get_string_op = X_GLsop_GetString;
+ EPHYR_LOG("Going to glXGetString. strname:%#x, ctxttag:%d\n",
+ a_string_name, a_screen_number);
+ break;
+ default:
+ EPHYR_LOG_ERROR("unknown EphyrHostGLXGetStringOp:%d\n", a_op);
+ goto out;
}
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- EPHYR_LOG ("major opcode: %d\n", major_opcode) ;
+ EPHYR_LOG("major opcode: %d\n", major_opcode);
- LockDisplay (dpy);
+ LockDisplay(dpy);
/* All of the GLX protocol requests for getting a string from the server
* look the same. The exact meaning of the a_for_whom field is usually
* either the screen number (for glXQueryServerString) or the context tag
* (for GLXSingle).
*/
- GetReq (GLXGenericGetString, req);
+ GetReq(GLXGenericGetString, req);
req->reqType = major_opcode;
req->glxCode = get_string_op;
req->for_whom = default_screen;
req->name = a_string_name;
- _XReply (dpy, (xReply *)&reply, 0, False);
+ _XReply(dpy, (xReply *) & reply, 0, False);
length = reply.length * 4;
if (!length) {
numbytes = 0;
- } else {
+ }
+ else {
numbytes = reply.size;
}
- EPHYR_LOG ("going to get a string of size:%d\n", numbytes) ;
+ EPHYR_LOG("going to get a string of size:%d\n", numbytes);
- *a_string = (char *) Xmalloc (numbytes +1);
+ *a_string = (char *) Xmalloc(numbytes + 1);
if (!a_string) {
- EPHYR_LOG_ERROR ("allocation failed\n") ;
+ EPHYR_LOG_ERROR("allocation failed\n");
goto out;
}
- memset (*a_string, 0, numbytes+1) ;
- if (_XRead (dpy, *a_string, numbytes)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- EPHYR_LOG_ERROR ("read failed\n") ;
- goto out ;
+ memset(*a_string, 0, numbytes + 1);
+ if (_XRead(dpy, *a_string, numbytes)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ EPHYR_LOG_ERROR("read failed\n");
+ goto out;
}
length -= numbytes;
- _XEatData (dpy, length) ;
- UnlockDisplay (dpy);
- SyncHandle ();
- EPHYR_LOG ("strname:%#x, strvalue:'%s', strlen:%d\n",
- a_string_name, *a_string, numbytes) ;
-
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ _XEatData(dpy, length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ EPHYR_LOG("strname:%#x, strvalue:'%s', strlen:%d\n",
+ a_string_name, *a_string, numbytes);
+
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
static Bool
-ephyrHostGLXGetVisualConfigsInternal (enum VisualConfRequestType a_type,
- int32_t a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf)
+ephyrHostGLXGetVisualConfigsInternal(enum VisualConfRequestType a_type,
+ int32_t a_screen,
+ int32_t * a_num_visuals,
+ int32_t * a_num_props,
+ int32_t * a_props_buf_size,
+ int32_t ** a_props_buf)
{
- Bool is_ok = FALSE ;
- Display *dpy = hostx_get_display () ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
xGLXGetVisualConfigsReq *req;
xGLXGetFBConfigsReq *fb_req;
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXGetFBConfigsSGIXReq *sgi_req;
xGLXGetVisualConfigsReply reply;
- char *server_glx_version=NULL,
- *server_glx_extensions=NULL ;
- int j=0,
- screens=0,
- major_opcode=0,
- num_props=0,
- num_visuals=0,
- props_buf_size=0,
- props_per_visual_size=0;
- int32_t *props_buf=NULL;
-
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
-
- screens = ScreenCount (dpy);
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get opcode\n") ;
- goto out ;
+ char *server_glx_version = NULL, *server_glx_extensions = NULL;
+ int j = 0,
+ screens = 0,
+ major_opcode = 0,
+ num_props = 0,
+ num_visuals = 0, props_buf_size = 0, props_per_visual_size = 0;
+ int32_t *props_buf = NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
+
+ screens = ScreenCount(dpy);
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get opcode\n");
+ goto out;
}
LockDisplay(dpy);
switch (a_type) {
- case EPHYR_GET_FB_CONFIG:
- GetReq(GLXGetFBConfigs,fb_req);
+ case EPHYR_GET_FB_CONFIG:
+ GetReq(GLXGetFBConfigs, fb_req);
fb_req->reqType = major_opcode;
fb_req->glxCode = X_GLXGetFBConfigs;
- fb_req->screen = DefaultScreen (dpy);
+ fb_req->screen = DefaultScreen(dpy);
break;
- case EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX:
+ case EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX:
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXGetFBConfigsSGIXReq
- -
- sz_xGLXVendorPrivateWithReplyReq,
- vpreq);
+ - sz_xGLXVendorPrivateWithReplyReq, vpreq);
sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
sgi_req->reqType = major_opcode;
sgi_req->glxCode = X_GLXVendorPrivateWithReply;
sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
- sgi_req->screen = DefaultScreen (dpy);
+ sgi_req->screen = DefaultScreen(dpy);
break;
- case EPHYR_GET_VISUAL_CONFIGS:
- GetReq(GLXGetVisualConfigs,req);
+ case EPHYR_GET_VISUAL_CONFIGS:
+ GetReq(GLXGetVisualConfigs, req);
req->reqType = major_opcode;
req->glxCode = X_GLXGetVisualConfigs;
- req->screen = DefaultScreen (dpy);
+ req->screen = DefaultScreen(dpy);
break;
}
- if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
- EPHYR_LOG_ERROR ("unknown error\n") ;
+ if (!_XReply(dpy, (xReply *) & reply, 0, False)) {
+ EPHYR_LOG_ERROR("unknown error\n");
UnlockDisplay(dpy);
- goto out ;
+ goto out;
}
- if (!reply.numVisuals) {
- EPHYR_LOG_ERROR ("screen does not support GL rendering\n") ;
+ if (!reply.numVisuals) {
+ EPHYR_LOG_ERROR("screen does not support GL rendering\n");
UnlockDisplay(dpy);
- goto out ;
+ goto out;
}
- num_visuals = reply.numVisuals ;
+ num_visuals = reply.numVisuals;
/* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for
* FIXME: FBconfigs?
@@ -322,9 +315,9 @@ ephyrHostGLXGetVisualConfigsInternal (enum VisualConfRequestType a_type,
if ((num_props < __GLX_MIN_CONFIG_PROPS) ||
(num_props > __GLX_MAX_CONFIG_PROPS)) {
/* Huh? Not in protocol defined limits. Punt */
- EPHYR_LOG_ERROR ("got a bad reply to request\n") ;
+ EPHYR_LOG_ERROR("got a bad reply to request\n");
UnlockDisplay(dpy);
- goto out ;
+ goto out;
}
if (a_type != EPHYR_GET_VISUAL_CONFIGS) {
@@ -332,250 +325,242 @@ ephyrHostGLXGetVisualConfigsInternal (enum VisualConfRequestType a_type,
}
props_per_visual_size = num_props * __GLX_SIZE_INT32;
props_buf_size = props_per_visual_size * reply.numVisuals;
- props_buf = malloc (props_buf_size) ;
+ props_buf = malloc(props_buf_size);
for (j = 0; j < reply.numVisuals; j++) {
- if (_XRead (dpy,
- &((char*)props_buf)[j*props_per_visual_size],
- props_per_visual_size) != Success) {
- EPHYR_LOG_ERROR ("read failed\n") ;
+ if (_XRead(dpy,
+ &((char *) props_buf)[j * props_per_visual_size],
+ props_per_visual_size) != Success) {
+ EPHYR_LOG_ERROR("read failed\n");
}
}
UnlockDisplay(dpy);
- *a_num_visuals = num_visuals ;
- *a_num_props = reply.numProps ;
- *a_props_buf_size = props_buf_size ;
- *a_props_buf = props_buf ;
- is_ok = TRUE ;
+ *a_num_visuals = num_visuals;
+ *a_num_props = reply.numProps;
+ *a_props_buf_size = props_buf_size;
+ *a_props_buf = props_buf;
+ is_ok = TRUE;
-out:
+ out:
if (server_glx_version) {
- XFree (server_glx_version) ;
- server_glx_version = NULL ;
+ XFree(server_glx_version);
+ server_glx_version = NULL;
}
if (server_glx_extensions) {
- XFree (server_glx_extensions) ;
- server_glx_extensions = NULL ;
+ XFree(server_glx_extensions);
+ server_glx_extensions = NULL;
}
- SyncHandle () ;
+ SyncHandle();
return is_ok;
}
Bool
-ephyrHostGLXGetVisualConfigs (int32_t a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf)
+ephyrHostGLXGetVisualConfigs(int32_t a_screen,
+ int32_t * a_num_visuals,
+ int32_t * a_num_props,
+ int32_t * a_props_buf_size, int32_t ** a_props_buf)
{
Bool is_ok = FALSE;
- EPHYR_LOG ("enter\n") ;
- is_ok = ephyrHostGLXGetVisualConfigsInternal (EPHYR_GET_VISUAL_CONFIGS,
- a_screen,
- a_num_visuals,
- a_num_props,
- a_props_buf_size,
- a_props_buf) ;
+ EPHYR_LOG("enter\n");
+ is_ok = ephyrHostGLXGetVisualConfigsInternal(EPHYR_GET_VISUAL_CONFIGS,
+ a_screen,
+ a_num_visuals,
+ a_num_props,
+ a_props_buf_size, a_props_buf);
- EPHYR_LOG ("leave:%d\n", is_ok) ;
+ EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
Bool
-ephyrHostGLXVendorPrivGetFBConfigsSGIX (int a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf)
+ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
+ int32_t * a_num_visuals,
+ int32_t * a_num_props,
+ int32_t * a_props_buf_size,
+ int32_t ** a_props_buf)
{
- Bool is_ok=FALSE ;
- EPHYR_LOG ("enter\n") ;
+ Bool is_ok = FALSE;
+
+ EPHYR_LOG("enter\n");
is_ok = ephyrHostGLXGetVisualConfigsInternal
- (EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
- a_screen,
- a_num_visuals,
- a_num_props,
- a_props_buf_size,
- a_props_buf) ;
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ (EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
+ a_screen, a_num_visuals, a_num_props, a_props_buf_size, a_props_buf);
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
Bool
-ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
- const char* a_extension_list)
+ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
+ const char *a_extension_list)
{
- Bool is_ok = FALSE ;
- Display *dpy = hostx_get_display () ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
xGLXClientInfoReq *req;
int size;
- int32_t major_opcode=0 ;
+ int32_t major_opcode = 0;
- EPHYR_RETURN_VAL_IF_FAIL (dpy && a_extension_list, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy && a_extension_list, FALSE);
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- LockDisplay (dpy);
+ LockDisplay(dpy);
- GetReq (GLXClientInfo,req);
+ GetReq(GLXClientInfo, req);
req->reqType = major_opcode;
req->glxCode = X_GLXClientInfo;
req->major = a_major;
req->minor = a_minor;
- size = strlen (a_extension_list) + 1;
+ size = strlen(a_extension_list) + 1;
req->length += bytes_to_int32(size);
req->numbytes = size;
- Data (dpy, a_extension_list, size);
+ Data(dpy, a_extension_list, size);
UnlockDisplay(dpy);
SyncHandle();
- is_ok=TRUE ;
+ is_ok = TRUE;
-out:
- return is_ok ;
+ out:
+ return is_ok;
}
Bool
-ephyrHostGLXCreateContext (int a_screen,
- int a_visual_id,
- int a_context_id,
- int a_share_list_ctxt_id,
- Bool a_direct)
+ephyrHostGLXCreateContext(int a_screen,
+ int a_visual_id,
+ int a_context_id,
+ int a_share_list_ctxt_id, Bool a_direct)
{
Bool is_ok = FALSE;
- Display *dpy = hostx_get_display ();
- int major_opcode=0, remote_context_id=0;
+ Display *dpy = hostx_get_display();
+ int major_opcode = 0, remote_context_id = 0;
xGLXCreateContextReq *req;
- EPHYR_LOG ("enter. screen:%d, visual:%d, contextid:%d, direct:%d\n",
- a_screen, a_visual_id, a_context_id, a_direct) ;
+ EPHYR_LOG("enter. screen:%d, visual:%d, contextid:%d, direct:%d\n",
+ a_screen, a_visual_id, a_context_id, a_direct);
- if (!hostx_allocate_resource_id_peer (a_context_id, &remote_context_id)) {
- EPHYR_LOG_ERROR ("failed to peer the context id %d host X",
- remote_context_id) ;
- goto out ;
+ if (!hostx_allocate_resource_id_peer(a_context_id, &remote_context_id)) {
+ EPHYR_LOG_ERROR("failed to peer the context id %d host X",
+ remote_context_id);
+ goto out;
}
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- LockDisplay (dpy) ;
+ LockDisplay(dpy);
/* Send the glXCreateContext request */
- GetReq(GLXCreateContext,req);
+ GetReq(GLXCreateContext, req);
req->reqType = major_opcode;
req->glxCode = X_GLXCreateContext;
req->context = remote_context_id;
req->visual = a_visual_id;
- req->screen = DefaultScreen (dpy);
+ req->screen = DefaultScreen(dpy);
req->shareList = a_share_list_ctxt_id;
req->isDirect = a_direct;
- UnlockDisplay (dpy);
- SyncHandle ();
+ UnlockDisplay(dpy);
+ SyncHandle();
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
Bool
-ephyrHostDestroyContext (int a_ctxt_id)
+ephyrHostDestroyContext(int a_ctxt_id)
{
- Bool is_ok=FALSE;
- Display *dpy=hostx_get_display ();
- int major_opcode=0, remote_ctxt_id=0 ;
- xGLXDestroyContextReq *req=NULL;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int major_opcode = 0, remote_ctxt_id = 0;
+ xGLXDestroyContextReq *req = NULL;
- EPHYR_LOG ("enter:%d\n", a_ctxt_id) ;
+ EPHYR_LOG("enter:%d\n", a_ctxt_id);
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_ctxt_id)) {
- EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n") ;
- goto out ;
+ if (!hostx_get_resource_id_peer(a_ctxt_id, &remote_ctxt_id)) {
+ EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
+ goto out;
}
- EPHYR_LOG ("host context id:%d\n", remote_ctxt_id) ;
+ EPHYR_LOG("host context id:%d\n", remote_ctxt_id);
- LockDisplay (dpy);
- GetReq (GLXDestroyContext,req);
+ LockDisplay(dpy);
+ GetReq(GLXDestroyContext, req);
req->reqType = major_opcode;
req->glxCode = X_GLXDestroyContext;
req->context = remote_ctxt_id;
- UnlockDisplay (dpy);
- SyncHandle ();
+ UnlockDisplay(dpy);
+ SyncHandle();
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
Bool
-ephyrHostGLXMakeCurrent (int a_drawable,
- int a_glx_ctxt_id,
- int a_old_ctxt_tag,
- int *a_ctxt_tag)
+ephyrHostGLXMakeCurrent(int a_drawable,
+ int a_glx_ctxt_id, int a_old_ctxt_tag, int *a_ctxt_tag)
{
- Bool is_ok=FALSE ;
- Display *dpy = hostx_get_display () ;
- int32_t major_opcode=0 ;
- int remote_glx_ctxt_id=0 ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int32_t major_opcode = 0;
+ int remote_glx_ctxt_id = 0;
xGLXMakeCurrentReq *req;
xGLXMakeCurrentReply reply;
- EPHYR_RETURN_VAL_IF_FAIL (a_ctxt_tag, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_ctxt_tag, FALSE);
- EPHYR_LOG ("enter. drawable:%d, context:%d, oldtag:%d\n",
- a_drawable, a_glx_ctxt_id, a_old_ctxt_tag) ;
+ EPHYR_LOG("enter. drawable:%d, context:%d, oldtag:%d\n",
+ a_drawable, a_glx_ctxt_id, a_old_ctxt_tag);
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- if (!hostx_get_resource_id_peer (a_glx_ctxt_id, &remote_glx_ctxt_id)) {
- EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n") ;
- goto out ;
+ if (!hostx_get_resource_id_peer(a_glx_ctxt_id, &remote_glx_ctxt_id)) {
+ EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
+ goto out;
}
- LockDisplay (dpy);
+ LockDisplay(dpy);
- GetReq (GLXMakeCurrent,req);
+ GetReq(GLXMakeCurrent, req);
req->reqType = major_opcode;
req->glxCode = X_GLXMakeCurrent;
req->drawable = a_drawable;
req->context = remote_glx_ctxt_id;
req->oldContextTag = a_old_ctxt_tag;
- memset (&reply, 0, sizeof (reply)) ;
- if (!_XReply (dpy, (xReply*)&reply, 0, False)) {
- EPHYR_LOG_ERROR ("failed to get reply from host\n") ;
- UnlockDisplay (dpy);
- SyncHandle ();
- goto out ;
+ memset(&reply, 0, sizeof(reply));
+ if (!_XReply(dpy, (xReply *) & reply, 0, False)) {
+ EPHYR_LOG_ERROR("failed to get reply from host\n");
+ UnlockDisplay(dpy);
+ SyncHandle();
+ goto out;
}
- UnlockDisplay (dpy);
- SyncHandle ();
- *a_ctxt_tag = reply.contextTag ;
- EPHYR_LOG ("context tag:%d\n", *a_ctxt_tag) ;
- is_ok = TRUE ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *a_ctxt_tag = reply.contextTag;
+ EPHYR_LOG("context tag:%d\n", *a_ctxt_tag);
+ is_ok = TRUE;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
#define X_GLXSingle 0
@@ -614,86 +599,85 @@ out:
*p = *(GLfloat *)&reply.pad3;
Bool
-ephyrHostGetIntegerValue (int a_current_context_tag, int a_int, int *a_val)
+ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val)
{
- Bool is_ok=FALSE;
- Display *dpy = hostx_get_display () ;
- int major_opcode=0, size=0;
- xGLXSingleReq *req=NULL;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int major_opcode = 0, size = 0;
+ xGLXSingleReq *req = NULL;
xGLXSingleReply reply;
- unsigned char* pc=NULL ;
+ unsigned char *pc = NULL;
- EPHYR_RETURN_VAL_IF_FAIL (a_val, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_val, FALSE);
- EPHYR_LOG ("enter\n") ;
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ EPHYR_LOG("enter\n");
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- LockDisplay (dpy) ;
- GetReqExtra (GLXSingle, 4, req) ;
- req->reqType = major_opcode ;
- req->glxCode = X_GLsop_GetIntegerv ;
+ LockDisplay(dpy);
+ GetReqExtra(GLXSingle, 4, req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLsop_GetIntegerv;
req->contextTag = a_current_context_tag;
- pc = ((unsigned char *)(req) + sz_xGLXSingleReq) ;
- EPHYR_GLX_SINGLE_PUT_LONG (0, a_int) ;
- EPHYR_GLX_SINGLE_READ_XREPLY () ;
- EPHYR_GLX_SINGLE_GET_SIZE (size) ;
+ pc = ((unsigned char *) (req) + sz_xGLXSingleReq);
+ EPHYR_GLX_SINGLE_PUT_LONG(0, a_int);
+ EPHYR_GLX_SINGLE_READ_XREPLY();
+ EPHYR_GLX_SINGLE_GET_SIZE(size);
if (!size) {
- UnlockDisplay (dpy) ;
- SyncHandle () ;
- EPHYR_LOG_ERROR ("X_GLsop_GetIngerv failed\n") ;
- goto out ;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ EPHYR_LOG_ERROR("X_GLsop_GetIngerv failed\n");
+ goto out;
}
- EPHYR_GLX_SINGLE_GET_LONG (a_val) ;
- UnlockDisplay (dpy) ;
- SyncHandle () ;
- is_ok = TRUE ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ EPHYR_GLX_SINGLE_GET_LONG(a_val);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ is_ok = TRUE;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
Bool
-ephyrHostIsContextDirect (int a_ctxt_id,
- int *a_is_direct)
+ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct)
{
- Bool is_ok=FALSE;
- Display *dpy = hostx_get_display () ;
- xGLXIsDirectReq *req=NULL;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ xGLXIsDirectReq *req = NULL;
xGLXIsDirectReply reply;
- int major_opcode=0, remote_glx_ctxt_id=0;
+ int major_opcode = 0, remote_glx_ctxt_id = 0;
- EPHYR_LOG ("enter\n") ;
- if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
- EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
- goto out ;
+ EPHYR_LOG("enter\n");
+ if (!ephyrHostGLXGetMajorOpcode(&major_opcode)) {
+ EPHYR_LOG_ERROR("failed to get major opcode\n");
+ goto out;
}
- if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_glx_ctxt_id)) {
- EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n") ;
- goto out ;
+ if (!hostx_get_resource_id_peer(a_ctxt_id, &remote_glx_ctxt_id)) {
+ EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
+ goto out;
}
- memset (&reply, 0, sizeof (reply)) ;
+ memset(&reply, 0, sizeof(reply));
/* Send the glXIsDirect request */
- LockDisplay (dpy);
- GetReq (GLXIsDirect,req);
+ LockDisplay(dpy);
+ GetReq(GLXIsDirect, req);
req->reqType = major_opcode;
req->glxCode = X_GLXIsDirect;
req->context = remote_glx_ctxt_id;
- if (!_XReply (dpy, (xReply*) &reply, 0, False)) {
- EPHYR_LOG_ERROR ("fail in reading reply from host\n") ;
- UnlockDisplay (dpy);
- SyncHandle ();
- goto out ;
+ if (!_XReply(dpy, (xReply *) & reply, 0, False)) {
+ EPHYR_LOG_ERROR("fail in reading reply from host\n");
+ UnlockDisplay(dpy);
+ SyncHandle();
+ goto out;
}
- UnlockDisplay (dpy);
- SyncHandle ();
- *a_is_direct = reply.isDirect ;
- is_ok = TRUE ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *a_is_direct = reply.isDirect;
+ is_ok = TRUE;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
index 6db362f30..9c6012070 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
@@ -34,43 +34,38 @@ enum EphyrHostGLXGetStringOps {
EPHYR_HOST_GLX_GetString,
};
-Bool ephyrHostGLXQueryVersion (int *a_maj, int *a_min) ;
-Bool ephyrHostGLXGetStringFromServer (int a_screen_number,
- int a_string_name,
- enum EphyrHostGLXGetStringOps a_op,
- char **a_string) ;
-Bool ephyrHostGLXGetVisualConfigs (int a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf) ;
+Bool ephyrHostGLXQueryVersion(int *a_maj, int *a_min);
+Bool ephyrHostGLXGetStringFromServer(int a_screen_number,
+ int a_string_name,
+ enum EphyrHostGLXGetStringOps a_op,
+ char **a_string);
+Bool ephyrHostGLXGetVisualConfigs(int a_screen,
+ int32_t * a_num_visuals,
+ int32_t * a_num_props,
+ int32_t * a_props_buf_size,
+ int32_t ** a_props_buf);
Bool
-ephyrHostGLXVendorPrivGetFBConfigsSGIX (int a_screen,
- int32_t *a_num_visuals,
- int32_t *a_num_props,
- int32_t *a_props_buf_size,
- int32_t **a_props_buf);
-Bool ephyrHostGLXGetMajorOpcode (int32_t *a_opcode) ;
-Bool ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
- const char* a_extension_list) ;
-Bool ephyrHostGLXCreateContext (int a_screen,
- int a_visual_id,
- int a_context_id,
- int a_shared_list_ctx_id,
- Bool a_direct) ;
-Bool ephyrHostDestroyContext (int a_ctxt_id) ;
+ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
+ int32_t * a_num_visuals,
+ int32_t * a_num_props,
+ int32_t * a_props_buf_size,
+ int32_t ** a_props_buf);
+Bool ephyrHostGLXGetMajorOpcode(int32_t * a_opcode);
+Bool ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
+ const char *a_extension_list);
+Bool ephyrHostGLXCreateContext(int a_screen,
+ int a_visual_id,
+ int a_context_id,
+ int a_shared_list_ctx_id, Bool a_direct);
-Bool ephyrHostGLXMakeCurrent (int a_drawable, int a_glx_ctxt_id,
- int a_olg_ctxt_tag, int *a_ctxt_tag) ;
+Bool ephyrHostDestroyContext(int a_ctxt_id);
-Bool ephyrHostGetIntegerValue (int a_current_context_tag,
- int a_int,
- int *a_val) ;
+Bool ephyrHostGLXMakeCurrent(int a_drawable, int a_glx_ctxt_id,
+ int a_olg_ctxt_tag, int *a_ctxt_tag);
-Bool ephyrHostIsContextDirect (int a_ctxt_id,
- int *a_is_direct) ;
+Bool ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val);
+Bool ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct);
#endif /*__EPHYRHOSTGLX_H__*/
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c
index 3137055ca..410e6b6e4 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c
@@ -50,45 +50,42 @@
dpy->bufptr += SIZEOF(xReq);\
dpy->request++
-
Bool
-ephyrHostProxyDoForward (pointer a_request_buffer,
- struct XReply *a_reply,
- Bool a_do_swap)
+ephyrHostProxyDoForward(pointer a_request_buffer,
+ struct XReply *a_reply, Bool a_do_swap)
{
- Bool is_ok = FALSE ;
- int n=0 ;
- Display *dpy=hostx_get_display () ;
- xReq *in_req = (xReq*) a_request_buffer ;
- xReq *forward_req=NULL ;
- struct XReply reply ;
+ Bool is_ok = FALSE;
+ int n = 0;
+ Display *dpy = hostx_get_display();
+ xReq *in_req = (xReq *) a_request_buffer;
+ xReq *forward_req = NULL;
+ struct XReply reply;
- EPHYR_RETURN_VAL_IF_FAIL (in_req && dpy, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(in_req && dpy, FALSE);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
if (a_do_swap) {
- swaps(&in_req->length) ;
+ swaps(&in_req->length);
}
- EPHYR_LOG ("Req {type:%d, data:%d, length:%d}\n",
- in_req->reqType, in_req->data, in_req->length) ;
- GetXReq (forward_req) ;
- memmove (forward_req, in_req, 4) ;
+ EPHYR_LOG("Req {type:%d, data:%d, length:%d}\n",
+ in_req->reqType, in_req->data, in_req->length);
+ GetXReq(forward_req);
+ memmove(forward_req, in_req, 4);
- if (!_XReply (dpy, (xReply*) &reply, 0, FALSE)) {
- EPHYR_LOG_ERROR ("failed to get reply\n") ;
+ if (!_XReply(dpy, (xReply *) & reply, 0, FALSE)) {
+ EPHYR_LOG_ERROR("failed to get reply\n");
goto out;
}
- EPHYR_LOG ("XReply{type:%d, foo:%d, seqnum:%d, length:%d}\n",
- reply.type, reply.foo, reply.sequence_number, reply.length) ;
+ EPHYR_LOG("XReply{type:%d, foo:%d, seqnum:%d, length:%d}\n",
+ reply.type, reply.foo, reply.sequence_number, reply.length);
if (a_reply) {
- memmove (a_reply, &reply, sizeof (reply)) ;
+ memmove(a_reply, &reply, sizeof(reply));
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h
index 720c986ff..13721606a 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h
@@ -30,22 +30,22 @@
#define __EPHYRHOSTPROXY_H__
struct XReply {
- int8_t type ;/*X_Reply*/
+ int8_t type; /*X_Reply */
int8_t foo;
- int16_t sequence_number ;
- int32_t length ;
- /*following is some data up to 32 bytes lenght*/
- int32_t pad0 ;
- int32_t pad1 ;
- int32_t pad2 ;
- int32_t pad3 ;
- int32_t pad4 ;
- int32_t pad5 ;
+ int16_t sequence_number;
+ int32_t length;
+ /*following is some data up to 32 bytes lenght */
+ int32_t pad0;
+ int32_t pad1;
+ int32_t pad2;
+ int32_t pad3;
+ int32_t pad4;
+ int32_t pad5;
};
Bool
-ephyrHostProxyDoForward (pointer a_request_buffer,
- struct XReply *a_reply,
- Bool a_do_swap) ;
+
+ephyrHostProxyDoForward(pointer a_request_buffer,
+ struct XReply *a_reply, Bool a_do_swap);
#endif /*__EPHYRHOSTPROXY_H__*/
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
index 69ad8a517..05a821b39 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -53,42 +53,37 @@
#ifndef TRUE
#define TRUE 1
#endif /*TRUE*/
-
#ifndef FALSE
#define FALSE 0
#endif /*FALSE*/
-
static XExtensionInfo _xv_info_data;
static XExtensionInfo *xv_info = &_xv_info_data;
static char *xv_extension_name = XvName;
-static char *xv_error_string(Display *dpy, int code, XExtCodes *codes,
- char * buf, int n);
-static int xv_close_display(Display *dpy, XExtCodes *codes);
-static Bool xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire);
+static char *xv_error_string(Display * dpy, int code, XExtCodes * codes,
+ char *buf, int n);
+static int xv_close_display(Display * dpy, XExtCodes * codes);
+static Bool xv_wire_to_event(Display * dpy, XEvent * host, xEvent *wire);
static XExtensionHooks xv_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- xv_close_display, /* close_display */
- xv_wire_to_event, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- xv_error_string /* error_string */
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ xv_close_display, /* close_display */
+ xv_wire_to_event, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ xv_error_string /* error_string */
};
-
-static char *xv_error_list[] =
-{
- "BadPort", /* XvBadPort */
- "BadEncoding", /* XvBadEncoding */
- "BadControl" /* XvBadControl */
+static char *xv_error_list[] = {
+ "BadPort", /* XvBadPort */
+ "BadEncoding", /* XvBadEncoding */
+ "BadControl" /* XvBadControl */
};
-
#define XvCheckExtension(dpy, i, val) \
XextCheckExtension(dpy, i, xv_extension_name, val)
#define XvGetReq(name, req) \
@@ -102,51 +97,51 @@ static char *xv_error_list[] =
dpy->bufptr += SIZEOF(xv##name##Req);\
dpy->request++
-static XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info)
-
+static
+XEXT_GENERATE_CLOSE_DISPLAY(xv_close_display, xv_info)
-static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info,
- xv_extension_name,
- &xv_extension_hooks,
- XvNumEvents, NULL)
+static
+XEXT_GENERATE_FIND_DISPLAY(xv_find_display, xv_info,
+ xv_extension_name,
+ &xv_extension_hooks, XvNumEvents, NULL)
-static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name,
- XvNumErrors, xv_error_list)
+static
+XEXT_GENERATE_ERROR_STRING(xv_error_string, xv_extension_name,
+ XvNumErrors, xv_error_list)
struct _EphyrHostXVAdaptorArray {
- XvAdaptorInfo *adaptors ;
- unsigned int nb_adaptors ;
+ XvAdaptorInfo *adaptors;
+ unsigned int nb_adaptors;
};
/*heavily copied from libx11*/
#define BUFSIZE 2048
static void
-ephyrHostXVLogXErrorEvent (Display *a_display,
- XErrorEvent *a_err_event,
- FILE *a_fp)
+ephyrHostXVLogXErrorEvent(Display * a_display,
+ XErrorEvent * a_err_event, FILE * a_fp)
{
char buffer[BUFSIZ];
char mesg[BUFSIZ];
char number[32];
const char *mtype = "XlibMessage";
- register _XExtension *ext = (_XExtension *)NULL;
- _XExtension *bext = (_XExtension *)NULL;
- Display *dpy = a_display ;
+ register _XExtension *ext = (_XExtension *) NULL;
+ _XExtension *bext = (_XExtension *) NULL;
+ Display *dpy = a_display;
XGetErrorText(dpy, a_err_event->error_code, buffer, BUFSIZ);
XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
(void) fprintf(a_fp, "%s: %s\n ", mesg, buffer);
XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
(void) fprintf(a_fp, mesg, a_err_event->request_code);
if (a_err_event->request_code < 128) {
snprintf(number, sizeof(number), "%d", a_err_event->request_code);
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
- } else {
+ }
+ else {
for (ext = dpy->ext_procs;
- ext && (ext->codes.major_opcode != a_err_event->request_code);
- ext = ext->next)
- ;
+ ext && (ext->codes.major_opcode != a_err_event->request_code);
+ ext = ext->next);
if (ext)
strcpy(buffer, ext->name);
else
@@ -155,7 +150,7 @@ ephyrHostXVLogXErrorEvent (Display *a_display,
(void) fprintf(a_fp, " (%s)\n", buffer);
if (a_err_event->request_code >= 128) {
XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
fputs(" ", a_fp);
(void) fprintf(a_fp, mesg, a_err_event->minor_code);
if (ext) {
@@ -166,20 +161,20 @@ ephyrHostXVLogXErrorEvent (Display *a_display,
}
fputs("\n", a_fp);
}
- if (a_err_event->error_code >= 128) {
+ if (a_err_event->error_code >= 128) {
/* kludge, try to find the extension that caused it */
buffer[0] = '\0';
for (ext = dpy->ext_procs; ext; ext = ext->next) {
if (ext->error_string)
- (*ext->error_string)(dpy, a_err_event->error_code, &ext->codes,
- buffer, BUFSIZ);
+ (*ext->error_string) (dpy, a_err_event->error_code, &ext->codes,
+ buffer, BUFSIZ);
if (buffer[0]) {
bext = ext;
break;
}
if (ext->codes.first_error &&
- ext->codes.first_error < (int)a_err_event->error_code &&
- (!bext || ext->codes.first_error > bext->codes.first_error))
+ ext->codes.first_error < (int) a_err_event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
bext = ext;
}
if (bext)
@@ -196,505 +191,476 @@ ephyrHostXVLogXErrorEvent (Display *a_display,
/* let extensions try to print the values */
for (ext = dpy->ext_procs; ext; ext = ext->next) {
if (ext->error_values)
- (*ext->error_values)(dpy, a_err_event, a_fp);
+ (*ext->error_values) (dpy, a_err_event, a_fp);
}
- } else if ((a_err_event->error_code == BadWindow) ||
- (a_err_event->error_code == BadPixmap) ||
- (a_err_event->error_code == BadCursor) ||
- (a_err_event->error_code == BadFont) ||
- (a_err_event->error_code == BadDrawable) ||
- (a_err_event->error_code == BadColor) ||
- (a_err_event->error_code == BadGC) ||
- (a_err_event->error_code == BadIDChoice) ||
- (a_err_event->error_code == BadValue) ||
- (a_err_event->error_code == BadAtom)) {
+ }
+ else if ((a_err_event->error_code == BadWindow) ||
+ (a_err_event->error_code == BadPixmap) ||
+ (a_err_event->error_code == BadCursor) ||
+ (a_err_event->error_code == BadFont) ||
+ (a_err_event->error_code == BadDrawable) ||
+ (a_err_event->error_code == BadColor) ||
+ (a_err_event->error_code == BadGC) ||
+ (a_err_event->error_code == BadIDChoice) ||
+ (a_err_event->error_code == BadValue) ||
+ (a_err_event->error_code == BadAtom)) {
if (a_err_event->error_code == BadValue)
XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
else if (a_err_event->error_code == BadAtom)
XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
else
XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
fputs(" ", a_fp);
(void) fprintf(a_fp, mesg, a_err_event->resourceid);
fputs("\n", a_fp);
}
XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
fputs(" ", a_fp);
(void) fprintf(a_fp, mesg, a_err_event->serial);
XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
- mesg, BUFSIZ);
+ mesg, BUFSIZ);
fputs("\n ", a_fp);
(void) fprintf(a_fp, mesg, dpy->request);
fputs("\n", a_fp);
}
static int
-ephyrHostXVErrorHandler (Display *a_display,
- XErrorEvent *a_error_event)
+ephyrHostXVErrorHandler(Display * a_display, XErrorEvent * a_error_event)
{
- EPHYR_LOG_ERROR ("got an error from the host xserver:\n") ;
- ephyrHostXVLogXErrorEvent (a_display, a_error_event, stderr) ;
- return Success ;
+ EPHYR_LOG_ERROR("got an error from the host xserver:\n");
+ ephyrHostXVLogXErrorEvent(a_display, a_error_event, stderr);
+ return Success;
}
void
-ephyrHostXVInit (void)
+ephyrHostXVInit(void)
{
- static Bool s_initialized ;
+ static Bool s_initialized;
if (s_initialized)
- return ;
- XSetErrorHandler (ephyrHostXVErrorHandler) ;
- s_initialized = TRUE ;
+ return;
+ XSetErrorHandler(ephyrHostXVErrorHandler);
+ s_initialized = TRUE;
}
Bool
-ephyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors)
+ephyrHostXVQueryAdaptors(EphyrHostXVAdaptorArray ** a_adaptors)
{
- EphyrHostXVAdaptorArray *result=NULL ;
- int ret=0 ;
- Bool is_ok=FALSE ;
+ EphyrHostXVAdaptorArray *result = NULL;
+ int ret = 0;
+ Bool is_ok = FALSE;
- EPHYR_RETURN_VAL_IF_FAIL (a_adaptors, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_adaptors, FALSE);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
- result = calloc (1, sizeof (EphyrHostXVAdaptorArray)) ;
+ result = calloc(1, sizeof(EphyrHostXVAdaptorArray));
if (!result)
- goto out ;
+ goto out;
- ret = XvQueryAdaptors (hostx_get_display (),
- DefaultRootWindow (hostx_get_display ()),
- &result->nb_adaptors,
- &result->adaptors) ;
+ ret = XvQueryAdaptors(hostx_get_display(),
+ DefaultRootWindow(hostx_get_display()),
+ &result->nb_adaptors, &result->adaptors);
if (ret != Success) {
- EPHYR_LOG_ERROR ("failed to query host adaptors: %d\n", ret) ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to query host adaptors: %d\n", ret);
+ goto out;
}
- *a_adaptors = result ;
- is_ok = TRUE ;
+ *a_adaptors = result;
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
void
-ephyrHostXVAdaptorArrayDelete (EphyrHostXVAdaptorArray *a_adaptors)
+ephyrHostXVAdaptorArrayDelete(EphyrHostXVAdaptorArray * a_adaptors)
{
if (!a_adaptors)
- return ;
+ return;
if (a_adaptors->adaptors) {
- XvFreeAdaptorInfo (a_adaptors->adaptors) ;
- a_adaptors->adaptors = NULL ;
- a_adaptors->nb_adaptors = 0 ;
+ XvFreeAdaptorInfo(a_adaptors->adaptors);
+ a_adaptors->adaptors = NULL;
+ a_adaptors->nb_adaptors = 0;
}
- XFree (a_adaptors) ;
+ XFree(a_adaptors);
}
int
-ephyrHostXVAdaptorArrayGetSize (const EphyrHostXVAdaptorArray *a_this)
+ephyrHostXVAdaptorArrayGetSize(const EphyrHostXVAdaptorArray * a_this)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
- return a_this->nb_adaptors ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, -1);
+ return a_this->nb_adaptors;
}
-EphyrHostXVAdaptor*
-ephyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_this,
- int a_index)
+EphyrHostXVAdaptor *
+ephyrHostXVAdaptorArrayAt(const EphyrHostXVAdaptorArray * a_this, int a_index)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, NULL);
if (a_index >= a_this->nb_adaptors)
- return NULL ;
- return (EphyrHostXVAdaptor*)&a_this->adaptors[a_index] ;
+ return NULL;
+ return (EphyrHostXVAdaptor *) & a_this->adaptors[a_index];
}
char
-ephyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this)
+ephyrHostXVAdaptorGetType(const EphyrHostXVAdaptor * a_this)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
- return ((XvAdaptorInfo*)a_this)->type ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, -1);
+ return ((XvAdaptorInfo *) a_this)->type;
}
-const char*
-ephyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this)
+const char *
+ephyrHostXVAdaptorGetName(const EphyrHostXVAdaptor * a_this)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, NULL);
- return ((XvAdaptorInfo*)a_this)->name ;
+ return ((XvAdaptorInfo *) a_this)->name;
}
-EphyrHostVideoFormat*
-ephyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this,
- int *a_nb_formats)
+EphyrHostVideoFormat *
+ephyrHostXVAdaptorGetVideoFormats(const EphyrHostXVAdaptor * a_this,
+ int *a_nb_formats)
{
- EphyrHostVideoFormat *formats=NULL ;
- int nb_formats=0, i=0 ;
- XVisualInfo *visual_info, visual_info_template ;
- int nb_visual_info ;
+ EphyrHostVideoFormat *formats = NULL;
+ int nb_formats = 0, i = 0;
+ XVisualInfo *visual_info, visual_info_template;
+ int nb_visual_info;
- EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, NULL);
- nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ;
- formats = calloc (nb_formats, sizeof (EphyrHostVideoFormat)) ;
- for (i=0; i < nb_formats; i++) {
- memset (&visual_info_template, 0, sizeof (visual_info_template)) ;
+ nb_formats = ((XvAdaptorInfo *) a_this)->num_formats;
+ formats = calloc(nb_formats, sizeof(EphyrHostVideoFormat));
+ for (i = 0; i < nb_formats; i++) {
+ memset(&visual_info_template, 0, sizeof(visual_info_template));
visual_info_template.visualid =
- ((XvAdaptorInfo*)a_this)->formats[i].visual_id;
- visual_info = XGetVisualInfo (hostx_get_display (),
- VisualIDMask,
- &visual_info_template,
- &nb_visual_info) ;
- formats[i].depth = ((XvAdaptorInfo*)a_this)->formats[i].depth ;
- formats[i].visual_class = visual_info->class ;
- XFree (visual_info) ;
+ ((XvAdaptorInfo *) a_this)->formats[i].visual_id;
+ visual_info = XGetVisualInfo(hostx_get_display(),
+ VisualIDMask,
+ &visual_info_template, &nb_visual_info);
+ formats[i].depth = ((XvAdaptorInfo *) a_this)->formats[i].depth;
+ formats[i].visual_class = visual_info->class;
+ XFree(visual_info);
}
if (a_nb_formats)
- *a_nb_formats = nb_formats ;
- return formats ;
+ *a_nb_formats = nb_formats;
+ return formats;
}
int
-ephyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this)
+ephyrHostXVAdaptorGetNbPorts(const EphyrHostXVAdaptor * a_this)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, -1);
- return ((XvAdaptorInfo*)a_this)->num_ports ;
+ return ((XvAdaptorInfo *) a_this)->num_ports;
}
int
-ephyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this)
+ephyrHostXVAdaptorGetFirstPortID(const EphyrHostXVAdaptor * a_this)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, -1);
- return ((XvAdaptorInfo*)a_this)->base_id ;
+ return ((XvAdaptorInfo *) a_this)->base_id;
}
Bool
-ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
- Bool *a_result)
+ephyrHostXVAdaptorHasPutVideo(const EphyrHostXVAdaptor * a_this, Bool *a_result)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
- if ((((XvAdaptorInfo*)a_this)->type & (XvVideoMask | XvInputMask)) ==
- (XvVideoMask | XvInputMask))
- *a_result = TRUE ;
+ if ((((XvAdaptorInfo *) a_this)->type & (XvVideoMask | XvInputMask)) ==
+ (XvVideoMask | XvInputMask))
+ *a_result = TRUE;
else
- *a_result = FALSE ;
- return TRUE ;
+ *a_result = FALSE;
+ return TRUE;
}
Bool
-ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
- Bool *a_result)
+ephyrHostXVAdaptorHasGetVideo(const EphyrHostXVAdaptor * a_this, Bool *a_result)
{
- if ((((XvAdaptorInfo*)a_this)->type & (XvVideoMask | XvOutputMask)) ==
- (XvVideoMask | XvOutputMask))
- *a_result = TRUE ;
+ if ((((XvAdaptorInfo *) a_this)->type & (XvVideoMask | XvOutputMask)) ==
+ (XvVideoMask | XvOutputMask))
+ *a_result = TRUE;
else
- *a_result = FALSE ;
- return TRUE ;
+ *a_result = FALSE;
+ return TRUE;
}
Bool
-ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
- Bool *a_result)
+ephyrHostXVAdaptorHasPutStill(const EphyrHostXVAdaptor * a_this, Bool *a_result)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
- if ((((XvAdaptorInfo*)a_this)->type & (XvStillMask | XvInputMask)) ==
- (XvStillMask | XvInputMask))
- *a_result = TRUE ;
+ if ((((XvAdaptorInfo *) a_this)->type & (XvStillMask | XvInputMask)) ==
+ (XvStillMask | XvInputMask))
+ *a_result = TRUE;
else
- *a_result = FALSE ;
- return TRUE ;
+ *a_result = FALSE;
+ return TRUE;
}
Bool
-ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
- Bool *a_result)
+ephyrHostXVAdaptorHasGetStill(const EphyrHostXVAdaptor * a_this, Bool *a_result)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
- if ((((XvAdaptorInfo*)a_this)->type & (XvStillMask | XvOutputMask)) ==
- (XvStillMask | XvOutputMask))
- *a_result = TRUE ;
+ if ((((XvAdaptorInfo *) a_this)->type & (XvStillMask | XvOutputMask)) ==
+ (XvStillMask | XvOutputMask))
+ *a_result = TRUE;
else
- *a_result = FALSE ;
- return TRUE ;
+ *a_result = FALSE;
+ return TRUE;
}
Bool
-ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
- Bool *a_result)
+ephyrHostXVAdaptorHasPutImage(const EphyrHostXVAdaptor * a_this, Bool *a_result)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
- if ((((XvAdaptorInfo*)a_this)->type & (XvImageMask | XvInputMask)) ==
- (XvImageMask | XvInputMask))
- *a_result = TRUE ;
+ if ((((XvAdaptorInfo *) a_this)->type & (XvImageMask | XvInputMask)) ==
+ (XvImageMask | XvInputMask))
+ *a_result = TRUE;
else
- *a_result = FALSE ;
- return TRUE ;
+ *a_result = FALSE;
+ return TRUE;
}
Bool
-ephyrHostXVQueryEncodings (int a_port_id,
- EphyrHostEncoding **a_encodings,
- unsigned int *a_num_encodings)
+ephyrHostXVQueryEncodings(int a_port_id,
+ EphyrHostEncoding ** a_encodings,
+ unsigned int *a_num_encodings)
{
- EphyrHostEncoding *encodings=NULL ;
- XvEncodingInfo *encoding_info=NULL ;
- unsigned int num_encodings=0, i;
- int ret=0 ;
+ EphyrHostEncoding *encodings = NULL;
+ XvEncodingInfo *encoding_info = NULL;
+ unsigned int num_encodings = 0, i;
+ int ret = 0;
- EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_encodings && a_num_encodings, FALSE);
- ret = XvQueryEncodings (hostx_get_display (),
- a_port_id,
- &num_encodings,
- &encoding_info) ;
+ ret = XvQueryEncodings(hostx_get_display(),
+ a_port_id, &num_encodings, &encoding_info);
if (num_encodings && encoding_info) {
- encodings = calloc (num_encodings, sizeof (EphyrHostEncoding)) ;
- for (i=0; i<num_encodings; i++) {
- encodings[i].id = encoding_info[i].encoding_id ;
- encodings[i].name = strdup (encoding_info[i].name) ;
- encodings[i].width = encoding_info[i].width ;
- encodings[i].height = encoding_info[i].height ;
- encodings[i].rate.numerator = encoding_info[i].rate.numerator ;
- encodings[i].rate.denominator = encoding_info[i].rate.denominator ;
+ encodings = calloc(num_encodings, sizeof(EphyrHostEncoding));
+ for (i = 0; i < num_encodings; i++) {
+ encodings[i].id = encoding_info[i].encoding_id;
+ encodings[i].name = strdup(encoding_info[i].name);
+ encodings[i].width = encoding_info[i].width;
+ encodings[i].height = encoding_info[i].height;
+ encodings[i].rate.numerator = encoding_info[i].rate.numerator;
+ encodings[i].rate.denominator = encoding_info[i].rate.denominator;
}
}
if (encoding_info) {
- XvFreeEncodingInfo (encoding_info) ;
- encoding_info = NULL ;
+ XvFreeEncodingInfo(encoding_info);
+ encoding_info = NULL;
}
- *a_encodings = encodings ;
- *a_num_encodings = num_encodings ;
+ *a_encodings = encodings;
+ *a_num_encodings = num_encodings;
if (ret != Success)
- return FALSE ;
- return TRUE ;
+ return FALSE;
+ return TRUE;
}
void
-ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
- int a_num_encodings)
+ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings, int a_num_encodings)
{
- int i=0 ;
+ int i = 0;
if (!a_encodings)
- return ;
- for (i=0; i < a_num_encodings; i++) {
- free(a_encodings[i].name) ;
- a_encodings[i].name = NULL ;
+ return;
+ for (i = 0; i < a_num_encodings; i++) {
+ free(a_encodings[i].name);
+ a_encodings[i].name = NULL;
}
- free(a_encodings) ;
+ free(a_encodings);
}
void
-ephyrHostAttributesDelete (EphyrHostAttribute *a_attributes)
+ephyrHostAttributesDelete(EphyrHostAttribute * a_attributes)
{
if (!a_attributes)
- return ;
- XFree (a_attributes) ;
+ return;
+ XFree(a_attributes);
}
Bool
-ephyrHostXVQueryPortAttributes (int a_port_id,
- EphyrHostAttribute **a_attributes,
- int *a_num_attributes)
+ephyrHostXVQueryPortAttributes(int a_port_id,
+ EphyrHostAttribute ** a_attributes,
+ int *a_num_attributes)
{
- EPHYR_RETURN_VAL_IF_FAIL (a_attributes && a_num_attributes, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_attributes && a_num_attributes, FALSE);
*a_attributes =
- (EphyrHostAttribute*)XvQueryPortAttributes (hostx_get_display (),
- a_port_id,
- a_num_attributes);
+ (EphyrHostAttribute *) XvQueryPortAttributes(hostx_get_display(),
+ a_port_id,
+ a_num_attributes);
- return TRUE ;
+ return TRUE;
}
Bool
-ephyrHostXVQueryImageFormats (int a_port_id,
- EphyrHostImageFormat **a_formats,
- int *a_num_format)
+ephyrHostXVQueryImageFormats(int a_port_id,
+ EphyrHostImageFormat ** a_formats,
+ int *a_num_format)
{
- XvImageFormatValues *result=NULL ;
+ XvImageFormatValues *result = NULL;
- EPHYR_RETURN_VAL_IF_FAIL (a_formats && a_num_format, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_formats && a_num_format, FALSE);
- result = XvListImageFormats (hostx_get_display (),
- a_port_id,
- a_num_format) ;
- *a_formats = (EphyrHostImageFormat*) result ;
- return TRUE ;
+ result = XvListImageFormats(hostx_get_display(), a_port_id, a_num_format);
+ *a_formats = (EphyrHostImageFormat *) result;
+ return TRUE;
}
Bool
-ephyrHostXVSetPortAttribute (int a_port_id,
- int a_atom,
- int a_attr_value)
+ephyrHostXVSetPortAttribute(int a_port_id, int a_atom, int a_attr_value)
{
- int res=Success ;
+ int res = Success;
- EPHYR_LOG ("atom,name,value: (%d,%s,%d)\n",
- a_atom,
- XGetAtomName (hostx_get_display (), a_atom),
- a_attr_value) ;
+ EPHYR_LOG("atom,name,value: (%d,%s,%d)\n",
+ a_atom, XGetAtomName(hostx_get_display(), a_atom), a_attr_value);
- res = XvSetPortAttribute (hostx_get_display (),
- a_port_id,
- a_atom,
- a_attr_value) ;
+ res = XvSetPortAttribute(hostx_get_display(),
+ a_port_id, a_atom, a_attr_value);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvSetPortAttribute() failed: %d\n", res) ;
- return FALSE ;
+ EPHYR_LOG_ERROR("XvSetPortAttribute() failed: %d\n", res);
+ return FALSE;
}
- XFlush (hostx_get_display ()) ;
- EPHYR_LOG ("leave\n") ;
+ XFlush(hostx_get_display());
+ EPHYR_LOG("leave\n");
- return TRUE ;
+ return TRUE;
}
Bool
-ephyrHostXVGetPortAttribute (int a_port_id,
- int a_atom,
- int *a_attr_value)
+ephyrHostXVGetPortAttribute(int a_port_id, int a_atom, int *a_attr_value)
{
- int res=Success ;
- Bool ret=FALSE ;
+ int res = Success;
+ Bool ret = FALSE;
- EPHYR_RETURN_VAL_IF_FAIL (a_attr_value, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_attr_value, FALSE);
- EPHYR_LOG ("enter, a_port_id: %d, a_atomid: %d, attr_name: %s\n",
- a_port_id, a_atom, XGetAtomName (hostx_get_display (), a_atom)) ;
+ EPHYR_LOG("enter, a_port_id: %d, a_atomid: %d, attr_name: %s\n",
+ a_port_id, a_atom, XGetAtomName(hostx_get_display(), a_atom));
- res = XvGetPortAttribute (hostx_get_display (),
- a_port_id,
- a_atom,
- a_attr_value) ;
+ res = XvGetPortAttribute(hostx_get_display(),
+ a_port_id, a_atom, a_attr_value);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvGetPortAttribute() failed: %d \n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvGetPortAttribute() failed: %d \n", res);
+ goto out;
}
- EPHYR_LOG ("atom,value: (%d, %d)\n", a_atom, *a_attr_value) ;
+ EPHYR_LOG("atom,value: (%d, %d)\n", a_atom, *a_attr_value);
- ret = TRUE ;
+ ret = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return ret ;
+ out:
+ EPHYR_LOG("leave\n");
+ return ret;
}
Bool
-ephyrHostXVQueryBestSize (int a_port_id,
- Bool a_motion,
- unsigned int a_frame_w,
- unsigned int a_frame_h,
- unsigned int a_drw_w,
- unsigned int a_drw_h,
- unsigned int *a_actual_w,
- unsigned int *a_actual_h)
-{
- int res=0 ;
- Bool is_ok=FALSE ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_actual_w && a_actual_h, FALSE) ;
-
- EPHYR_LOG ("enter: frame (%dx%d), drw (%dx%d)\n",
- a_frame_w, a_frame_h,
- a_drw_w, a_drw_h) ;
-
- res = XvQueryBestSize (hostx_get_display (),
- a_port_id,
- a_motion,
- a_frame_w, a_frame_h,
- a_drw_w, a_drw_h,
- a_actual_w, a_actual_h) ;
+ephyrHostXVQueryBestSize(int a_port_id,
+ Bool a_motion,
+ unsigned int a_frame_w,
+ unsigned int a_frame_h,
+ unsigned int a_drw_w,
+ unsigned int a_drw_h,
+ unsigned int *a_actual_w, unsigned int *a_actual_h)
+{
+ int res = 0;
+ Bool is_ok = FALSE;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_actual_w && a_actual_h, FALSE);
+
+ EPHYR_LOG("enter: frame (%dx%d), drw (%dx%d)\n",
+ a_frame_w, a_frame_h, a_drw_w, a_drw_h);
+
+ res = XvQueryBestSize(hostx_get_display(),
+ a_port_id,
+ a_motion,
+ a_frame_w, a_frame_h,
+ a_drw_w, a_drw_h, a_actual_w, a_actual_h);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvQueryBestSize() failed: %d\n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvQueryBestSize() failed: %d\n", res);
+ goto out;
}
- XSync (hostx_get_display (), FALSE) ;
+ XSync(hostx_get_display(), FALSE);
- EPHYR_LOG ("actual (%dx%d)\n", *a_actual_w, *a_actual_h) ;
- is_ok = TRUE ;
+ EPHYR_LOG("actual (%dx%d)\n", *a_actual_w, *a_actual_h);
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
static Bool
-xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
+xv_wire_to_event(Display * dpy, XEvent * host, xEvent *wire)
{
- XExtDisplayInfo *info = xv_find_display (dpy);
- XvEvent *re = (XvEvent *)host;
- xvEvent *event = (xvEvent *)wire;
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ XvEvent *re = (XvEvent *) host;
+ xvEvent *event = (xvEvent *) wire;
XvCheckExtension(dpy, info, False);
switch ((event->u.u.type & 0x7F) - info->codes->first_event) {
- case XvVideoNotify:
- re->xvvideo.type = event->u.u.type & 0x7f;
- re->xvvideo.serial =
- _XSetLastRequestRead(dpy, (xGenericReply *)event);
- re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
- re->xvvideo.display = dpy;
- re->xvvideo.time = event->u.videoNotify.time;
- re->xvvideo.reason = event->u.videoNotify.reason;
- re->xvvideo.drawable = event->u.videoNotify.drawable;
- re->xvvideo.port_id = event->u.videoNotify.port;
- break;
- case XvPortNotify:
- re->xvport.type = event->u.u.type & 0x7f;
- re->xvport.serial =
- _XSetLastRequestRead(dpy, (xGenericReply *)event);
- re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
- re->xvport.display = dpy;
- re->xvport.time = event->u.portNotify.time;
- re->xvport.port_id = event->u.portNotify.port;
- re->xvport.attribute = event->u.portNotify.attribute;
- re->xvport.value = event->u.portNotify.value;
- break;
- default:
- return False;
- }
-
- return True ;
+ case XvVideoNotify:
+ re->xvvideo.type = event->u.u.type & 0x7f;
+ re->xvvideo.serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
+ re->xvvideo.display = dpy;
+ re->xvvideo.time = event->u.videoNotify.time;
+ re->xvvideo.reason = event->u.videoNotify.reason;
+ re->xvvideo.drawable = event->u.videoNotify.drawable;
+ re->xvvideo.port_id = event->u.videoNotify.port;
+ break;
+ case XvPortNotify:
+ re->xvport.type = event->u.u.type & 0x7f;
+ re->xvport.serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
+ re->xvport.display = dpy;
+ re->xvport.time = event->u.portNotify.time;
+ re->xvport.port_id = event->u.portNotify.port;
+ re->xvport.attribute = event->u.portNotify.attribute;
+ re->xvport.value = event->u.portNotify.value;
+ break;
+ default:
+ return False;
+ }
+
+ return True;
}
Bool
-ephyrHostXVQueryImageAttributes (int a_port_id,
- int a_image_id /*image fourcc code*/,
- unsigned short *a_width,
- unsigned short *a_height,
- int *a_image_size,
- int *a_pitches,
- int *a_offsets)
-{
- Display *dpy = hostx_get_display () ;
- Bool ret=FALSE ;
- XExtDisplayInfo *info = xv_find_display (dpy);
- xvQueryImageAttributesReq *req=NULL;
+ephyrHostXVQueryImageAttributes(int a_port_id,
+ int a_image_id /*image fourcc code */ ,
+ unsigned short *a_width,
+ unsigned short *a_height,
+ int *a_image_size,
+ int *a_pitches, int *a_offsets)
+{
+ Display *dpy = hostx_get_display();
+ Bool ret = FALSE;
+ XExtDisplayInfo *info = xv_find_display(dpy);
+ xvQueryImageAttributesReq *req = NULL;
xvQueryImageAttributesReply rep;
- EPHYR_RETURN_VAL_IF_FAIL (a_width, FALSE) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_height, FALSE) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_image_size, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_width, FALSE);
+ EPHYR_RETURN_VAL_IF_FAIL(a_height, FALSE);
+ EPHYR_RETURN_VAL_IF_FAIL(a_image_size, FALSE);
- XvCheckExtension (dpy, info, FALSE);
+ XvCheckExtension(dpy, info, FALSE);
- LockDisplay (dpy);
+ LockDisplay(dpy);
- XvGetReq (QueryImageAttributes, req);
+ XvGetReq(QueryImageAttributes, req);
req->id = a_image_id;
req->port = a_port_id;
req->width = *a_width;
@@ -702,315 +668,308 @@ ephyrHostXVQueryImageAttributes (int a_port_id,
/*
* read the reply
*/
- if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
- EPHYR_LOG_ERROR ("QeryImageAttribute req failed\n") ;
- goto out ;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ EPHYR_LOG_ERROR("QeryImageAttribute req failed\n");
+ goto out;
}
if (a_pitches && a_offsets) {
- _XRead (dpy,
- (char*)a_pitches,
- rep.num_planes << 2);
- _XRead (dpy,
- (char*)a_offsets,
- rep.num_planes << 2);
- } else {
+ _XRead(dpy, (char *) a_pitches, rep.num_planes << 2);
+ _XRead(dpy, (char *) a_offsets, rep.num_planes << 2);
+ }
+ else {
_XEatData(dpy, rep.length << 2);
}
- *a_width = rep.width ;
- *a_height = rep.height ;
- *a_image_size = rep.data_size ;
+ *a_width = rep.width;
+ *a_height = rep.height;
+ *a_image_size = rep.data_size;
- ret = TRUE ;
+ ret = TRUE;
-out:
- UnlockDisplay (dpy) ;
- SyncHandle ();
- return ret ;
+ out:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ret;
}
Bool
-ephyrHostGetAtom (const char* a_name,
- Bool a_create_if_not_exists,
- int *a_atom)
+ephyrHostGetAtom(const char *a_name, Bool a_create_if_not_exists, int *a_atom)
{
- int atom=None ;
+ int atom = None;
- EPHYR_RETURN_VAL_IF_FAIL (a_atom, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_atom, FALSE);
- atom = XInternAtom (hostx_get_display (), a_name, a_create_if_not_exists);
+ atom = XInternAtom(hostx_get_display(), a_name, a_create_if_not_exists);
if (atom == None) {
- return FALSE ;
+ return FALSE;
}
- *a_atom = atom ;
- return TRUE ;
+ *a_atom = atom;
+ return TRUE;
}
-char*
-ephyrHostGetAtomName (int a_atom)
+char *
+ephyrHostGetAtomName(int a_atom)
{
- return XGetAtomName (hostx_get_display (), a_atom) ;
+ return XGetAtomName(hostx_get_display(), a_atom);
}
void
-ephyrHostFree (void *a_pointer)
+ephyrHostFree(void *a_pointer)
{
if (a_pointer)
- XFree (a_pointer) ;
+ XFree(a_pointer);
}
Bool
-ephyrHostXVPutImage (int a_screen_num,
- int a_port_id,
- int a_image_id,
- int a_drw_x,
- int a_drw_y,
- int a_drw_w,
- int a_drw_h,
- int a_src_x,
- int a_src_y,
- int a_src_w,
- int a_src_h,
- int a_image_width,
- int a_image_height,
- unsigned char *a_buf,
- EphyrHostBox *a_clip_rects,
- int a_clip_rect_nums )
-{
- Bool is_ok=TRUE ;
- XvImage *xv_image=NULL ;
- GC gc=0 ;
+ephyrHostXVPutImage(int a_screen_num,
+ int a_port_id,
+ int a_image_id,
+ int a_drw_x,
+ int a_drw_y,
+ int a_drw_w,
+ int a_drw_h,
+ int a_src_x,
+ int a_src_y,
+ int a_src_w,
+ int a_src_h,
+ int a_image_width,
+ int a_image_height,
+ unsigned char *a_buf,
+ EphyrHostBox * a_clip_rects, int a_clip_rect_nums)
+{
+ Bool is_ok = TRUE;
+ XvImage *xv_image = NULL;
+ GC gc = 0;
XGCValues gc_values;
- Display *dpy = hostx_get_display () ;
- XRectangle *rects=NULL ;
- int res = 0 ;
+ Display *dpy = hostx_get_display();
+ XRectangle *rects = NULL;
+ int res = 0;
- EPHYR_RETURN_VAL_IF_FAIL (a_buf, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(a_buf, FALSE);
- EPHYR_LOG ("enter, num_clip_rects: %d\n", a_clip_rect_nums) ;
+ EPHYR_LOG("enter, num_clip_rects: %d\n", a_clip_rect_nums);
- memset (&gc_values, 0, sizeof (gc_values)) ;
- gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ memset(&gc_values, 0, sizeof(gc_values));
+ gc = XCreateGC(dpy, hostx_get_window(a_screen_num), 0L, &gc_values);
if (!gc) {
- EPHYR_LOG_ERROR ("failed to create gc \n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create gc \n");
+ goto out;
}
- xv_image = (XvImage*) XvCreateImage (hostx_get_display (),
+ xv_image = (XvImage *) XvCreateImage(hostx_get_display(),
a_port_id, a_image_id,
- NULL, a_image_width, a_image_height) ;
+ NULL, a_image_width, a_image_height);
if (!xv_image) {
- EPHYR_LOG_ERROR ("failed to create image\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create image\n");
+ goto out;
}
- xv_image->data = (char*)a_buf ;
+ xv_image->data = (char *) a_buf;
if (a_clip_rect_nums) {
- int i=0 ;
- rects = calloc (a_clip_rect_nums, sizeof (XRectangle)) ;
- for (i=0; i < a_clip_rect_nums; i++) {
- rects[i].x = a_clip_rects[i].x1 ;
- rects[i].y = a_clip_rects[i].y1 ;
+ int i = 0;
+
+ rects = calloc(a_clip_rect_nums, sizeof(XRectangle));
+ for (i = 0; i < a_clip_rect_nums; i++) {
+ rects[i].x = a_clip_rects[i].x1;
+ rects[i].y = a_clip_rects[i].y1;
rects[i].width = a_clip_rects[i].x2 - a_clip_rects[i].x1;
rects[i].height = a_clip_rects[i].y2 - a_clip_rects[i].y1;
- EPHYR_LOG ("(x,y,w,h): (%d,%d,%d,%d)\n",
- rects[i].x, rects[i].y,
- rects[i].width, rects[i].height) ;
+ EPHYR_LOG("(x,y,w,h): (%d,%d,%d,%d)\n",
+ rects[i].x, rects[i].y, rects[i].width, rects[i].height);
}
- XSetClipRectangles (dpy, gc, 0, 0, rects, a_clip_rect_nums, YXBanded) ;
- /*this always returns 1*/
- }
- res = XvPutImage (dpy, a_port_id,
- hostx_get_window (a_screen_num),
- gc, xv_image,
- a_src_x, a_src_y, a_src_w, a_src_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+ XSetClipRectangles(dpy, gc, 0, 0, rects, a_clip_rect_nums, YXBanded);
+ /*this always returns 1 */
+ }
+ res = XvPutImage(dpy, a_port_id,
+ hostx_get_window(a_screen_num),
+ gc, xv_image,
+ a_src_x, a_src_y, a_src_w, a_src_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvPutImage() failed: %d\n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvPutImage() failed: %d\n", res);
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
+ out:
if (xv_image) {
- XFree (xv_image) ;
- xv_image = NULL ;
+ XFree(xv_image);
+ xv_image = NULL;
}
if (gc) {
- XFreeGC (dpy, gc) ;
- gc = NULL ;
+ XFreeGC(dpy, gc);
+ gc = NULL;
}
free(rects);
rects = NULL;
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
Bool
-ephyrHostXVPutVideo (int a_screen_num, int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+ephyrHostXVPutVideo(int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
- Bool is_ok=FALSE ;
- int res=FALSE ;
- GC gc=0 ;
+ Bool is_ok = FALSE;
+ int res = FALSE;
+ GC gc = 0;
XGCValues gc_values;
- Display *dpy=hostx_get_display () ;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
- gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ gc = XCreateGC(dpy, hostx_get_window(a_screen_num), 0L, &gc_values);
if (!gc) {
- EPHYR_LOG_ERROR ("failed to create gc \n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create gc \n");
+ goto out;
}
- res = XvPutVideo (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+ res = XvPutVideo(dpy, a_port_id, hostx_get_window(a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvPutVideo() failed: %d\n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvPutVideo() failed: %d\n", res);
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
+ out:
if (gc) {
- XFreeGC (dpy, gc) ;
- gc = NULL ;
+ XFreeGC(dpy, gc);
+ gc = NULL;
}
- return is_ok ;
+ return is_ok;
}
Bool
-ephyrHostXVGetVideo (int a_screen_num, int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+ephyrHostXVGetVideo(int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
- Bool is_ok=FALSE ;
- int res=FALSE ;
- GC gc=0 ;
+ Bool is_ok = FALSE;
+ int res = FALSE;
+ GC gc = 0;
XGCValues gc_values;
- Display *dpy=hostx_get_display () ;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
- gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ gc = XCreateGC(dpy, hostx_get_window(a_screen_num), 0L, &gc_values);
if (!gc) {
- EPHYR_LOG_ERROR ("failed to create gc \n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create gc \n");
+ goto out;
}
- res = XvGetVideo (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+ res = XvGetVideo(dpy, a_port_id, hostx_get_window(a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvGetVideo() failed: %d\n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvGetVideo() failed: %d\n", res);
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
+ out:
if (gc) {
- XFreeGC (dpy, gc) ;
- gc = NULL ;
+ XFreeGC(dpy, gc);
+ gc = NULL;
}
- return is_ok ;
+ return is_ok;
}
Bool
-ephyrHostXVPutStill (int a_screen_num, int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+ephyrHostXVPutStill(int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
- Bool is_ok=FALSE ;
- int res=FALSE ;
- GC gc=0 ;
+ Bool is_ok = FALSE;
+ int res = FALSE;
+ GC gc = 0;
XGCValues gc_values;
- Display *dpy=hostx_get_display () ;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
- gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ gc = XCreateGC(dpy, hostx_get_window(a_screen_num), 0L, &gc_values);
if (!gc) {
- EPHYR_LOG_ERROR ("failed to create gc \n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create gc \n");
+ goto out;
}
- res = XvPutStill (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+ res = XvPutStill(dpy, a_port_id, hostx_get_window(a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvPutStill() failed: %d\n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvPutStill() failed: %d\n", res);
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
+ out:
if (gc) {
- XFreeGC (dpy, gc) ;
- gc = NULL ;
+ XFreeGC(dpy, gc);
+ gc = NULL;
}
- return is_ok ;
+ return is_ok;
}
Bool
-ephyrHostXVGetStill (int a_screen_num, int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+ephyrHostXVGetStill(int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
- Bool is_ok=FALSE ;
- int res=FALSE ;
- GC gc=0 ;
+ Bool is_ok = FALSE;
+ int res = FALSE;
+ GC gc = 0;
XGCValues gc_values;
- Display *dpy=hostx_get_display () ;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
- gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ gc = XCreateGC(dpy, hostx_get_window(a_screen_num), 0L, &gc_values);
if (!gc) {
- EPHYR_LOG_ERROR ("failed to create gc \n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create gc \n");
+ goto out;
}
- res = XvGetStill (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+ res = XvGetStill(dpy, a_port_id, hostx_get_window(a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h);
if (res != Success) {
- EPHYR_LOG_ERROR ("XvGetStill() failed: %d\n", res) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvGetStill() failed: %d\n", res);
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
+ out:
if (gc) {
- XFreeGC (dpy, gc) ;
- gc = NULL ;
+ XFreeGC(dpy, gc);
+ gc = NULL;
}
- return is_ok ;
+ return is_ok;
}
Bool
-ephyrHostXVStopVideo (int a_screen_num, int a_port_id)
+ephyrHostXVStopVideo(int a_screen_num, int a_port_id)
{
- int ret=0 ;
- Bool is_ok=FALSE ;
- Display *dpy = hostx_get_display () ;
+ int ret = 0;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
- ret = XvStopVideo (dpy, a_port_id, hostx_get_window (a_screen_num)) ;
+ ret = XvStopVideo(dpy, a_port_id, hostx_get_window(a_screen_num));
if (ret != Success) {
- EPHYR_LOG_ERROR ("XvStopVideo() failed: %d \n", ret) ;
- goto out ;
+ EPHYR_LOG_ERROR("XvStopVideo() failed: %d \n", ret);
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h
index 05ee38a03..0d3177277 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h
@@ -28,40 +28,40 @@
#ifndef __EPHYRHOSTVIDEO_H__
#define __EPHYRHOSTVIDEO_H__
-typedef void* EphyrHostXVAdaptor ;
-typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray ;
+typedef void *EphyrHostXVAdaptor;
+typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray;
typedef struct _EphyrHostVideoFormat {
- char depth ;
+ char depth;
short visual_class;
-} EphyrHostVideoFormat ;
+} EphyrHostVideoFormat;
typedef struct _EphyrHostRational {
- int numerator ;
- int denominator ;
+ int numerator;
+ int denominator;
} EphyrHostRational;
typedef struct _EphyrHostEncoding {
- int id ;
- char *name ;
- unsigned short width, height ;
- EphyrHostRational rate ;
-} EphyrHostEncoding ;
+ int id;
+ char *name;
+ unsigned short width, height;
+ EphyrHostRational rate;
+} EphyrHostEncoding;
typedef struct _EphyrHostAttribute {
int flags;
int min_value;
int max_value;
char *name;
-} EphyrHostAttribute ;
+} EphyrHostAttribute;
typedef struct _EphyrHostImageFormat {
- int id; /* Unique descriptor for the format */
- int type; /* XvRGB, XvYUV */
- int byte_order; /* LSBFirst, MSBFirst */
- char guid[16]; /* Globally Unique IDentifier */
+ int id; /* Unique descriptor for the format */
+ int type; /* XvRGB, XvYUV */
+ int byte_order; /* LSBFirst, MSBFirst */
+ char guid[16]; /* Globally Unique IDentifier */
int bits_per_pixel;
- int format; /* XvPacked, XvPlanar */
+ int format; /* XvPacked, XvPlanar */
int num_planes;
/* for RGB formats only */
@@ -80,159 +80,152 @@ typedef struct _EphyrHostImageFormat {
unsigned int vert_y_period;
unsigned int vert_u_period;
unsigned int vert_v_period;
- char component_order[32]; /* eg. UYVY */
- int scanline_order; /* XvTopToBottom, XvBottomToTop */
-} EphyrHostImageFormat ;
+ char component_order[32]; /* eg. UYVY */
+ int scanline_order; /* XvTopToBottom, XvBottomToTop */
+} EphyrHostImageFormat;
typedef struct {
- unsigned short x1, y1, x2, y2 ;
-} EphyrHostBox ;
+ unsigned short x1, y1, x2, y2;
+} EphyrHostBox;
-void ephyrHostXVInit (void) ;
+void ephyrHostXVInit(void);
-void ephyrHostFree (void *a_pointer) ;
+void ephyrHostFree(void *a_pointer);
/*
* host adaptor array
*/
-Bool ephyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors) ;
-void ephyrHostXVAdaptorArrayDelete (EphyrHostXVAdaptorArray *a_adaptors) ;
-int ephyrHostXVAdaptorArrayGetSize (const EphyrHostXVAdaptorArray *a_this) ;
-EphyrHostXVAdaptor* ephyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_this,
- int a_index) ;
+Bool ephyrHostXVQueryAdaptors(EphyrHostXVAdaptorArray ** a_adaptors);
+void ephyrHostXVAdaptorArrayDelete(EphyrHostXVAdaptorArray * a_adaptors);
+int ephyrHostXVAdaptorArrayGetSize(const EphyrHostXVAdaptorArray * a_this);
+EphyrHostXVAdaptor *ephyrHostXVAdaptorArrayAt(const EphyrHostXVAdaptorArray *
+ a_this, int a_index);
/*
* host adaptor
*/
-char ephyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this) ;
-const char* ephyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) ;
-EphyrHostVideoFormat* ephyrHostXVAdaptorGetVideoFormats
- (const EphyrHostXVAdaptor *a_this,
- int *a_nb_formats) ;
-int ephyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this) ;
-int ephyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this) ;
-
-Bool ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
- Bool *a_result) ;
-Bool ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
- Bool *a_result) ;
-Bool ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
- Bool *a_result) ;
-Bool ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
- Bool *a_result) ;
-Bool ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
- Bool *a_result) ;
+char ephyrHostXVAdaptorGetType(const EphyrHostXVAdaptor * a_this);
+const char *ephyrHostXVAdaptorGetName(const EphyrHostXVAdaptor * a_this);
+EphyrHostVideoFormat *ephyrHostXVAdaptorGetVideoFormats
+ (const EphyrHostXVAdaptor * a_this, int *a_nb_formats);
+int ephyrHostXVAdaptorGetNbPorts(const EphyrHostXVAdaptor * a_this);
+int ephyrHostXVAdaptorGetFirstPortID(const EphyrHostXVAdaptor * a_this);
+
+Bool ephyrHostXVAdaptorHasPutVideo(const EphyrHostXVAdaptor * a_this,
+ Bool *a_result);
+Bool ephyrHostXVAdaptorHasGetVideo(const EphyrHostXVAdaptor * a_this,
+ Bool *a_result);
+Bool ephyrHostXVAdaptorHasPutStill(const EphyrHostXVAdaptor * a_this,
+ Bool *a_result);
+Bool ephyrHostXVAdaptorHasGetStill(const EphyrHostXVAdaptor * a_this,
+ Bool *a_result);
+Bool ephyrHostXVAdaptorHasPutImage(const EphyrHostXVAdaptor * a_this,
+ Bool *a_result);
/*
* encoding
*/
-Bool ephyrHostXVQueryEncodings (int a_port_id,
- EphyrHostEncoding **a_encodings,
- unsigned int *a_num_encodings) ;
+Bool ephyrHostXVQueryEncodings(int a_port_id,
+ EphyrHostEncoding ** a_encodings,
+ unsigned int *a_num_encodings);
-void ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
- int a_num_encodings) ;
+void ephyrHostEncodingsDelete(EphyrHostEncoding * a_encodings,
+ int a_num_encodings);
/*
* attribute
*/
-Bool ephyrHostXVQueryPortAttributes (int a_port_id,
- EphyrHostAttribute **a_attributes,
- int *a_num_attributes) ;
+Bool ephyrHostXVQueryPortAttributes(int a_port_id,
+ EphyrHostAttribute ** a_attributes,
+ int *a_num_attributes);
+
+void ephyrHostAttributesDelete(EphyrHostAttribute * a_attributes);
-void ephyrHostAttributesDelete (EphyrHostAttribute *a_attributes) ;
/*
* image format
*/
-Bool ephyrHostXVQueryImageFormats (int a_port_id,
- EphyrHostImageFormat **a_formats,
- int *a_num_format) ;
+Bool ephyrHostXVQueryImageFormats(int a_port_id,
+ EphyrHostImageFormat ** a_formats,
+ int *a_num_format);
/*
* Port Attribute Get/Set
*/
-Bool ephyrHostXVSetPortAttribute (int a_port_id,
- int a_atom,
- int a_attr_value) ;
-Bool ephyrHostXVGetPortAttribute (int a_port_id,
- int a_atom,
- int *a_attr_value) ;
+Bool ephyrHostXVSetPortAttribute(int a_port_id, int a_atom, int a_attr_value);
+Bool ephyrHostXVGetPortAttribute(int a_port_id, int a_atom, int *a_attr_value);
+
/*
*size query
*/
-Bool ephyrHostXVQueryBestSize (int a_port_id,
- Bool a_motion,
- unsigned int a_frame_w,
- unsigned int a_frame_h,
- unsigned int a_drw_w,
- unsigned int a_drw_h,
- unsigned int *a_actual_w,
- unsigned int *a_actual_h) ;
-
-Bool ephyrHostXVQueryImageAttributes (int a_port_id,
- int a_image_id /*image fourcc code*/,
- unsigned short *a_width,
- unsigned short *a_height,
- int *a_image_size,
- int *a_pitches,
- int *a_offsets) ;
+Bool ephyrHostXVQueryBestSize(int a_port_id,
+ Bool a_motion,
+ unsigned int a_frame_w,
+ unsigned int a_frame_h,
+ unsigned int a_drw_w,
+ unsigned int a_drw_h,
+ unsigned int *a_actual_w,
+ unsigned int *a_actual_h);
+
+Bool ephyrHostXVQueryImageAttributes(int a_port_id,
+ int a_image_id /*image fourcc code */ ,
+ unsigned short *a_width,
+ unsigned short *a_height,
+ int *a_image_size,
+ int *a_pitches, int *a_offsets);
/*
* atom
*/
-Bool ephyrHostGetAtom (const char* a_name,
- Bool a_create_if_not_exists,
- int *a_atom) ;
-char* ephyrHostGetAtomName (int a_atom) ;
+Bool ephyrHostGetAtom(const char *a_name,
+ Bool a_create_if_not_exists, int *a_atom);
+char *ephyrHostGetAtomName(int a_atom);
/*
*PutImage
* (ignore clipping for now)
*/
-Bool ephyrHostXVPutImage (int a_screen_num,
- int a_port_id,
- int a_image_id,
- int a_drw_x,
- int a_drw_y,
- int a_drw_w,
- int a_drw_h,
- int a_src_x,
- int a_src_y,
- int a_src_w,
- int a_src_h,
- int a_image_width,
- int a_image_height,
- unsigned char *a_buf,
- EphyrHostBox *a_clip_rects,
- int a_clip_rect_nums) ;
+Bool ephyrHostXVPutImage(int a_screen_num,
+ int a_port_id,
+ int a_image_id,
+ int a_drw_x,
+ int a_drw_y,
+ int a_drw_w,
+ int a_drw_h,
+ int a_src_x,
+ int a_src_y,
+ int a_src_w,
+ int a_src_h,
+ int a_image_width,
+ int a_image_height,
+ unsigned char *a_buf,
+ EphyrHostBox * a_clip_rects, int a_clip_rect_nums);
/*
* Putvideo/PutStill/GetVideo
*/
-Bool ephyrHostXVPutVideo (int a_screen_num,
- int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
-
-Bool ephyrHostXVGetVideo (int a_screen_num,
- int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
-
-Bool ephyrHostXVPutStill (int a_screen_num,
- int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
-
-Bool ephyrHostXVGetStill (int a_screen_num,
- int a_port_id,
- int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
- int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
+Bool ephyrHostXVPutVideo(int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h);
+
+Bool ephyrHostXVGetVideo(int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h);
+
+Bool ephyrHostXVPutStill(int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h);
+
+Bool ephyrHostXVGetStill(int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h);
/*
* StopVideo
*/
-Bool ephyrHostXVStopVideo (int a_screen_num, int a_port_id) ;
+Bool ephyrHostXVStopVideo(int a_screen_num, int a_port_id);
#endif /*__EPHYRHOSTVIDEO_H__*/
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
index b674bb8d0..a62b49d4b 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -30,301 +30,274 @@
#include "ephyrlog.h"
extern Window EphyrPreExistingHostWin;
-extern Bool EphyrWantGrayScale;
-extern Bool kdHasPointer;
-extern Bool kdHasKbd;
+extern Bool EphyrWantGrayScale;
+extern Bool kdHasPointer;
+extern Bool kdHasKbd;
#ifdef GLXEXT
-extern Bool ephyrNoDRI;
+extern Bool ephyrNoDRI;
extern Bool noGlxVisualInit;
#endif
-extern Bool ephyrNoXV;
+extern Bool ephyrNoXV;
#ifdef KDRIVE_EVDEV
-extern KdPointerDriver LinuxEvdevMouseDriver;
+extern KdPointerDriver LinuxEvdevMouseDriver;
extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
#endif
-void processScreenArg (char *screen_size, char *parent_id) ;
+void processScreenArg(char *screen_size, char *parent_id);
void
-InitCard (char *name)
+InitCard(char *name)
{
EPHYR_DBG("mark");
- KdCardInfoAdd (&ephyrFuncs, 0);
+ KdCardInfoAdd(&ephyrFuncs, 0);
}
void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{
- KdInitOutput (pScreenInfo, argc, argv);
+ KdInitOutput(pScreenInfo, argc, argv);
}
void
-InitInput (int argc, char **argv)
+InitInput(int argc, char **argv)
{
- KdKeyboardInfo *ki;
- KdPointerInfo *pi;
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
- KdAddKeyboardDriver(&EphyrKeyboardDriver);
+ KdAddKeyboardDriver(&EphyrKeyboardDriver);
#ifdef KDRIVE_EVDEV
- KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
+ KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
#endif
- KdAddPointerDriver(&EphyrMouseDriver);
+ KdAddPointerDriver(&EphyrMouseDriver);
#ifdef KDRIVE_EVDEV
- KdAddPointerDriver(&LinuxEvdevMouseDriver);
+ KdAddPointerDriver(&LinuxEvdevMouseDriver);
#endif
- if (!kdHasKbd) {
- ki = KdNewKeyboard();
- if (!ki)
- FatalError("Couldn't create Xephyr keyboard\n");
- ki->driver = &EphyrKeyboardDriver;
- KdAddKeyboard(ki);
- }
-
- if (!kdHasPointer) {
- pi = KdNewPointer();
- if (!pi)
- FatalError("Couldn't create Xephyr pointer\n");
- pi->driver = &EphyrMouseDriver;
- KdAddPointer(pi);
- }
-
- KdInitInput();
+ if (!kdHasKbd) {
+ ki = KdNewKeyboard();
+ if (!ki)
+ FatalError("Couldn't create Xephyr keyboard\n");
+ ki->driver = &EphyrKeyboardDriver;
+ KdAddKeyboard(ki);
+ }
+
+ if (!kdHasPointer) {
+ pi = KdNewPointer();
+ if (!pi)
+ FatalError("Couldn't create Xephyr pointer\n");
+ pi->driver = &EphyrMouseDriver;
+ KdAddPointer(pi);
+ }
+
+ KdInitInput();
}
void
-CloseInput (void)
+CloseInput(void)
{
- KdCloseInput();
+ KdCloseInput();
}
#ifdef DDXBEFORERESET
void
-ddxBeforeReset (void)
+ddxBeforeReset(void)
{
}
#endif
void
-ddxUseMsg (void)
+ddxUseMsg(void)
{
- KdUseMsg();
-
- ErrorF("\nXephyr Option Usage:\n");
- ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
- ErrorF("-host-cursor Re-use exisiting X host server cursor\n");
- ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
- ErrorF("-grayscale Simulate 8bit grayscale\n");
- ErrorF("-fakexa Simulate acceleration using software rendering\n");
- ErrorF("-verbosity <level> Set log verbosity level\n");
+ KdUseMsg();
+
+ ErrorF("\nXephyr Option Usage:\n");
+ ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
+ ErrorF("-host-cursor Re-use exisiting X host server cursor\n");
+ ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
+ ErrorF("-grayscale Simulate 8bit grayscale\n");
+ ErrorF
+ ("-fakexa Simulate acceleration using software rendering\n");
+ ErrorF("-verbosity <level> Set log verbosity level\n");
#ifdef GLXEXT
- ErrorF("-nodri do not use DRI\n");
+ ErrorF("-nodri do not use DRI\n");
#endif
- ErrorF("-noxv do not use XV\n");
- ErrorF("-name [name] define the name in the WM_CLASS property\n");
- ErrorF("-title [title] set the window title in the WM_NAME property\n");
- ErrorF("\n");
+ ErrorF("-noxv do not use XV\n");
+ ErrorF("-name [name] define the name in the WM_CLASS property\n");
+ ErrorF
+ ("-title [title] set the window title in the WM_NAME property\n");
+ ErrorF("\n");
- exit(1);
+ exit(1);
}
void
-processScreenArg (char *screen_size, char *parent_id)
+processScreenArg(char *screen_size, char *parent_id)
{
- KdCardInfo *card;
+ KdCardInfo *card;
- InitCard (0); /*Put each screen on a separate card*/
- card = KdCardInfoLast ();
+ InitCard(0); /*Put each screen on a separate card */
+ card = KdCardInfoLast();
- if (card)
- {
- KdScreenInfo *screen;
- unsigned long p_id = 0;
+ if (card) {
+ KdScreenInfo *screen;
+ unsigned long p_id = 0;
- screen = KdScreenInfoAdd (card);
- KdParseScreen (screen, screen_size);
+ screen = KdScreenInfoAdd(card);
+ KdParseScreen(screen, screen_size);
- if (parent_id)
- {
- p_id = strtol (parent_id, NULL, 0);
+ if (parent_id) {
+ p_id = strtol(parent_id, NULL, 0);
}
- EPHYR_DBG ("screen number:%d\n", screen->mynum) ;
- hostx_add_screen (screen, p_id, screen->mynum);
+ EPHYR_DBG("screen number:%d\n", screen->mynum);
+ hostx_add_screen(screen, p_id, screen->mynum);
}
- else
- {
- ErrorF("No matching card found!\n");
+ else {
+ ErrorF("No matching card found!\n");
}
}
int
-ddxProcessArgument (int argc, char **argv, int i)
+ddxProcessArgument(int argc, char **argv, int i)
{
- static char* parent = NULL;
- EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] );
+ static char *parent = NULL;
- if (i == 1)
- {
- hostx_use_resname(basename(argv[0]), 0);
+ EPHYR_DBG("mark argv[%d]='%s'", i, argv[i]);
+
+ if (i == 1) {
+ hostx_use_resname(basename(argv[0]), 0);
}
- if (!strcmp (argv[i], "-parent"))
- {
- if(i+1 < argc)
- {
- int j;
- /* If parent is specified and a screen argument follows, don't do
- * anything, let the -screen handling init the rest */
- for (j = i; j < argc; j++)
- {
- if (!strcmp(argv[j], "-screen"))
- {
- parent = argv[i + 1];
- return 2;
- }
- }
-
- processScreenArg ("100x100", argv[i+1]);
- return 2;
- }
-
- UseMsg();
- exit(1);
+ if (!strcmp(argv[i], "-parent")) {
+ if (i + 1 < argc) {
+ int j;
+
+ /* If parent is specified and a screen argument follows, don't do
+ * anything, let the -screen handling init the rest */
+ for (j = i; j < argc; j++) {
+ if (!strcmp(argv[j], "-screen")) {
+ parent = argv[i + 1];
+ return 2;
+ }
+ }
+
+ processScreenArg("100x100", argv[i + 1]);
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
}
- else if (!strcmp (argv[i], "-screen"))
- {
- if ((i+1) < argc)
- {
- processScreenArg (argv[i+1], parent);
- parent = NULL;
- return 2;
- }
-
- UseMsg();
- exit(1);
+ else if (!strcmp(argv[i], "-screen")) {
+ if ((i + 1) < argc) {
+ processScreenArg(argv[i + 1], parent);
+ parent = NULL;
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
}
- else if (!strcmp (argv[i], "-host-cursor"))
- {
- hostx_use_host_cursor();
- return 1;
+ else if (!strcmp(argv[i], "-host-cursor")) {
+ hostx_use_host_cursor();
+ return 1;
}
- else if (!strcmp (argv[i], "-fullscreen"))
- {
- hostx_use_fullscreen();
- return 1;
+ else if (!strcmp(argv[i], "-fullscreen")) {
+ hostx_use_fullscreen();
+ return 1;
}
- else if (!strcmp (argv[i], "-grayscale"))
- {
- EphyrWantGrayScale = 1;
- return 1;
+ else if (!strcmp(argv[i], "-grayscale")) {
+ EphyrWantGrayScale = 1;
+ return 1;
}
- else if (!strcmp (argv[i], "-fakexa"))
- {
- ephyrFuncs.initAccel = ephyrDrawInit;
- ephyrFuncs.enableAccel = ephyrDrawEnable;
- ephyrFuncs.disableAccel = ephyrDrawDisable;
- ephyrFuncs.finiAccel = ephyrDrawFini;
- return 1;
+ else if (!strcmp(argv[i], "-fakexa")) {
+ ephyrFuncs.initAccel = ephyrDrawInit;
+ ephyrFuncs.enableAccel = ephyrDrawEnable;
+ ephyrFuncs.disableAccel = ephyrDrawDisable;
+ ephyrFuncs.finiAccel = ephyrDrawFini;
+ return 1;
}
- else if (!strcmp (argv[i], "-verbosity"))
- {
- if(i+1 < argc && argv[i+1][0] != '-')
- {
- int verbosity=atoi (argv[i+1]) ;
- LogSetParameter (XLOG_VERBOSITY, verbosity) ;
- EPHYR_LOG ("set verbosiry to %d\n", verbosity) ;
- return 2 ;
- }
- else
- {
- UseMsg() ;
- exit(1) ;
- }
+ else if (!strcmp(argv[i], "-verbosity")) {
+ if (i + 1 < argc && argv[i + 1][0] != '-') {
+ int verbosity = atoi(argv[i + 1]);
+
+ LogSetParameter(XLOG_VERBOSITY, verbosity);
+ EPHYR_LOG("set verbosiry to %d\n", verbosity);
+ return 2;
+ }
+ else {
+ UseMsg();
+ exit(1);
+ }
}
#ifdef GLXEXT
- else if (!strcmp (argv[i], "-nodri"))
- {
- noGlxVisualInit = FALSE ;
- ephyrNoDRI = TRUE ;
- EPHYR_LOG ("no direct rendering enabled\n") ;
- return 1 ;
- }
+ else if (!strcmp(argv[i], "-nodri")) {
+ noGlxVisualInit = FALSE;
+ ephyrNoDRI = TRUE;
+ EPHYR_LOG("no direct rendering enabled\n");
+ return 1;
+ }
#endif
- else if (!strcmp (argv[i], "-noxv"))
- {
- ephyrNoXV = TRUE ;
- EPHYR_LOG ("no XVideo enabled\n") ;
- return 1 ;
- }
- else if (!strcmp (argv[i], "-name"))
- {
- if (i+1 < argc && argv[i+1][0] != '-')
- {
- hostx_use_resname(argv[i+1], 1);
- return 2;
- }
- else
- {
- UseMsg();
- return 0;
- }
- }
- else if (!strcmp (argv[i], "-title"))
- {
- if (i+1 < argc && argv[i+1][0] != '-')
- {
- hostx_set_title(argv[i+1]);
- return 2;
- }
- else
- {
- UseMsg();
- return 0;
- }
- }
- else if (argv[i][0] == ':')
- {
- hostx_set_display_name(argv[i]);
+ else if (!strcmp(argv[i], "-noxv")) {
+ ephyrNoXV = TRUE;
+ EPHYR_LOG("no XVideo enabled\n");
+ return 1;
}
- /* Xnest compatibility */
- else if (!strcmp(argv[i], "-display"))
- {
- hostx_set_display_name(argv[i+1]);
- return 2;
- }
- else if (!strcmp(argv[i], "-sync") ||
- !strcmp(argv[i], "-full") ||
- !strcmp(argv[i], "-sss") ||
- !strcmp(argv[i], "-install"))
- {
- return 1;
- }
- else if (!strcmp(argv[i], "-bw") ||
- !strcmp(argv[i], "-class") ||
- !strcmp(argv[i], "-geometry") ||
- !strcmp(argv[i], "-scrns"))
- {
- return 2;
- }
- /* end Xnest compat */
-
- return KdProcessArgument (argc, argv, i);
+ else if (!strcmp(argv[i], "-name")) {
+ if (i + 1 < argc && argv[i + 1][0] != '-') {
+ hostx_use_resname(argv[i + 1], 1);
+ return 2;
+ }
+ else {
+ UseMsg();
+ return 0;
+ }
+ }
+ else if (!strcmp(argv[i], "-title")) {
+ if (i + 1 < argc && argv[i + 1][0] != '-') {
+ hostx_set_title(argv[i + 1]);
+ return 2;
+ }
+ else {
+ UseMsg();
+ return 0;
+ }
+ }
+ else if (argv[i][0] == ':') {
+ hostx_set_display_name(argv[i]);
+ }
+ /* Xnest compatibility */
+ else if (!strcmp(argv[i], "-display")) {
+ hostx_set_display_name(argv[i + 1]);
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-sync") ||
+ !strcmp(argv[i], "-full") ||
+ !strcmp(argv[i], "-sss") || !strcmp(argv[i], "-install")) {
+ return 1;
+ }
+ else if (!strcmp(argv[i], "-bw") ||
+ !strcmp(argv[i], "-class") ||
+ !strcmp(argv[i], "-geometry") || !strcmp(argv[i], "-scrns")) {
+ return 2;
+ }
+ /* end Xnest compat */
+
+ return KdProcessArgument(argc, argv, i);
}
void
-OsVendorInit (void)
+OsVendorInit(void)
{
- EPHYR_DBG("mark");
+ EPHYR_DBG("mark");
- if (hostx_want_host_cursor())
- {
- ephyrFuncs.initCursor = &ephyrCursorInit;
- ephyrFuncs.enableCursor = &ephyrCursorEnable;
+ if (hostx_want_host_cursor()) {
+ ephyrFuncs.initCursor = &ephyrCursorInit;
+ ephyrFuncs.enableCursor = &ephyrCursorEnable;
}
- KdOsInit (&EphyrOsFuncs);
+ KdOsInit(&EphyrOsFuncs);
}
/* 'Fake' cursor stuff, could be improved */
@@ -332,31 +305,32 @@ OsVendorInit (void)
static Bool
ephyrRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- return TRUE;
+ return TRUE;
}
static Bool
ephyrUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- return TRUE;
+ return TRUE;
}
static void
-ephyrSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+ephyrSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
+ int y)
{
- ;
+ ;
}
static void
ephyrMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- ;
+ ;
}
static Bool
ephyrDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
- return TRUE;
+ return TRUE;
}
static void
@@ -365,57 +339,55 @@ ephyrDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
}
miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
- ephyrRealizeCursor,
- ephyrUnrealizeCursor,
- ephyrSetCursor,
- ephyrMoveCursor,
- ephyrDeviceCursorInitialize,
- ephyrDeviceCursorCleanup
+ ephyrRealizeCursor,
+ ephyrUnrealizeCursor,
+ ephyrSetCursor,
+ ephyrMoveCursor,
+ ephyrDeviceCursorInitialize,
+ ephyrDeviceCursorCleanup
};
-
Bool
ephyrCursorInit(ScreenPtr pScreen)
{
- miPointerInitialize(pScreen,
- &EphyrPointerSpriteFuncs,
- &ephyrPointerScreenFuncs,
- FALSE);
+ miPointerInitialize(pScreen,
+ &EphyrPointerSpriteFuncs,
+ &ephyrPointerScreenFuncs, FALSE);
- return TRUE;
+ return TRUE;
}
void
ephyrCursorEnable(ScreenPtr pScreen)
{
- ;
+ ;
}
KdCardFuncs ephyrFuncs = {
- ephyrCardInit, /* cardinit */
- ephyrScreenInit, /* scrinit */
- ephyrInitScreen, /* initScreen */
- ephyrFinishInitScreen, /* finishInitScreen */
- ephyrCreateResources, /* createRes */
- ephyrPreserve, /* preserve */
- ephyrEnable, /* enable */
- ephyrDPMS, /* dpms */
- ephyrDisable, /* disable */
- ephyrRestore, /* restore */
- ephyrScreenFini, /* scrfini */
- ephyrCardFini, /* cardfini */
-
- 0, /* initCursor */
- 0, /* enableCursor */
- 0, /* disableCursor */
- 0, /* finiCursor */
- 0, /* recolorCursor */
-
- 0, /* initAccel */
- 0, /* enableAccel */
- 0, /* disableAccel */
- 0, /* finiAccel */
-
- ephyrGetColors,/* getColors */
- ephyrPutColors, /* putColors */
+ ephyrCardInit, /* cardinit */
+ ephyrScreenInit, /* scrinit */
+ ephyrInitScreen, /* initScreen */
+ ephyrFinishInitScreen, /* finishInitScreen */
+ ephyrCreateResources, /* createRes */
+ ephyrPreserve, /* preserve */
+ ephyrEnable, /* enable */
+ ephyrDPMS, /* dpms */
+ ephyrDisable, /* disable */
+ ephyrRestore, /* restore */
+ ephyrScreenFini, /* scrfini */
+ ephyrCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
+
+ ephyrGetColors, /* getColors */
+ ephyrPutColors, /* putColors */
};
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c b/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c
index 0c070f4c7..3d86d2db1 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c
@@ -46,74 +46,70 @@
#include "ephyrhostproxy.h"
#include "hostx.h"
-static Bool ephyrProxyGetHostExtensionInfo (const char *a_ext_name,
- int *a_major_opcode,
- int *a_first_event,
- int *a_first_error) ;
+static Bool ephyrProxyGetHostExtensionInfo(const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event,
+ int *a_first_error);
-static int ephyrProxyProcDispatch (ClientPtr client) ;
+static int ephyrProxyProcDispatch(ClientPtr client);
static Bool
-ephyrProxyGetHostExtensionInfo (const char *a_ext_name,
- int *a_major_opcode,
- int *a_first_event,
- int *a_first_error)
+ephyrProxyGetHostExtensionInfo(const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event, int *a_first_error)
{
- return hostx_get_extension_info (a_ext_name, a_major_opcode,
- a_first_event, a_first_error) ;
+ return hostx_get_extension_info(a_ext_name, a_major_opcode,
+ a_first_event, a_first_error);
}
static int
-ephyrProxyProcDispatch (ClientPtr a_client)
+ephyrProxyProcDispatch(ClientPtr a_client)
{
- int res=BadImplementation ;
- struct XReply reply ;
+ int res = BadImplementation;
+ struct XReply reply;
- if (!ephyrHostProxyDoForward (a_client->requestBuffer, &reply, FALSE)) {
- EPHYR_LOG_ERROR ("forwarding failed\n") ;
- goto out ;
+ if (!ephyrHostProxyDoForward(a_client->requestBuffer, &reply, FALSE)) {
+ EPHYR_LOG_ERROR("forwarding failed\n");
+ goto out;
}
reply.sequence_number = a_client->sequence;
- res = Success ;
+ res = Success;
- WriteToClient(a_client, 32, (char *)&reply);
+ WriteToClient(a_client, 32, (char *) &reply);
-out:
- return res ;
+ out:
+ return res;
}
static void
-ephyrProxyProcReset (ExtensionEntry *a_entry)
+ephyrProxyProcReset(ExtensionEntry * a_entry)
{
}
Bool
-ephyrProxyExtensionInit (const char *a_extension_name)
+ephyrProxyExtensionInit(const char *a_extension_name)
{
- Bool is_ok = FALSE ;
- int major_opcode=0, first_event=0, first_error=0;
- ExtensionEntry *ext=NULL ;
+ Bool is_ok = FALSE;
+ int major_opcode = 0, first_event = 0, first_error = 0;
+ ExtensionEntry *ext = NULL;
- if (!ephyrProxyGetHostExtensionInfo (a_extension_name,
- &major_opcode,
- &first_event,
- &first_error)) {
- EPHYR_LOG ("failed to query extension %s from host\n", a_extension_name) ;
+ if (!ephyrProxyGetHostExtensionInfo(a_extension_name,
+ &major_opcode,
+ &first_event, &first_error)) {
+ EPHYR_LOG("failed to query extension %s from host\n", a_extension_name);
goto out;
}
- ext = AddExtension ((char*)a_extension_name, 0, 0,
- ephyrProxyProcDispatch,
- ephyrProxyProcDispatch,
- ephyrProxyProcReset,
- StandardMinorOpcode) ;
+ ext = AddExtension((char *) a_extension_name, 0, 0,
+ ephyrProxyProcDispatch,
+ ephyrProxyProcDispatch,
+ ephyrProxyProcReset, StandardMinorOpcode);
if (!ext) {
- EPHYR_LOG_ERROR ("failed to add the extension\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to add the extension\n");
+ goto out;
}
- is_ok = TRUE ;
+ is_ok = TRUE;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
-
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
index 0fd1a63d4..67eadd121 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
@@ -1,1273 +1,1218 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of OpenedHand Ltd not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. OpenedHand Ltd makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:
- * Dodji Seketeli <dodji@openedhand.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include <string.h>
-#include <X11/extensions/Xv.h>
-#include "ephyrlog.h"
-#include "kdrive.h"
-#include "kxv.h"
-#include "ephyr.h"
-#include "hostx.h"
-#include "ephyrhostvideo.h"
-
-struct _EphyrXVPriv {
- EphyrHostXVAdaptorArray *host_adaptors ;
- KdVideoAdaptorPtr adaptors ;
- int num_adaptors ;
-};
-typedef struct _EphyrXVPriv EphyrXVPriv ;
-
-struct _EphyrPortPriv {
- int port_number ;
- KdVideoAdaptorPtr current_adaptor ;
- EphyrXVPriv *xv_priv;
- unsigned char *image_buf ;
- int image_buf_size ;
- int image_id ;
- int drw_x, drw_y, drw_w, drw_h ;
- int src_x, src_y, src_w, src_h ;
- int image_width, image_height ;
-};
-typedef struct _EphyrPortPriv EphyrPortPriv ;
-
-static Bool DoSimpleClip (BoxPtr a_dst_drw,
- BoxPtr a_clipper,
- BoxPtr a_result) ;
-
-static Bool ephyrLocalAtomToHost (int a_local_atom, int *a_host_atom) ;
-
-/*
-static Bool ephyrHostAtomToLocal (int a_host_atom, int *a_local_atom) ;
-*/
-
-static EphyrXVPriv* ephyrXVPrivNew (void) ;
-static void ephyrXVPrivDelete (EphyrXVPriv *a_this) ;
-static Bool ephyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this) ;
-static Bool ephyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this) ;
-static Bool ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
- ScreenPtr a_screen) ;
-
-static Bool ephyrXVPrivIsAttrValueValid (KdAttributePtr a_attrs,
- int a_attrs_len,
- const char *a_attr_name,
- int a_attr_value,
- Bool *a_is_valid) ;
-
-static Bool ephyrXVPrivGetImageBufSize (int a_port_id,
- int a_image_id,
- unsigned short a_width,
- unsigned short a_height,
- int *a_size) ;
-
-static Bool ephyrXVPrivSaveImageToPortPriv (EphyrPortPriv *a_port_priv,
- const unsigned char *a_image,
- int a_image_len) ;
-
-static void ephyrStopVideo (KdScreenInfo *a_info,
- pointer a_xv_priv,
- Bool a_exit);
-
-static int ephyrSetPortAttribute (KdScreenInfo *a_info,
- Atom a_attr_name,
- int a_attr_value,
- pointer a_port_priv);
-
-static int ephyrGetPortAttribute (KdScreenInfo *a_screen_info,
- Atom a_attr_name,
- int *a_attr_value,
- pointer a_port_priv);
-
-static void ephyrQueryBestSize (KdScreenInfo *a_info,
- Bool a_motion,
- short a_src_w,
- short a_src_h,
- short a_drw_w,
- short a_drw_h,
- unsigned int *a_prefered_w,
- unsigned int *a_prefered_h,
- pointer a_port_priv);
-
-static int ephyrPutImage (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_src_x,
- short a_src_y,
- short a_drw_x,
- short a_drw_y,
- short a_src_w,
- short a_src_h,
- short a_drw_w,
- short a_drw_h,
- int a_id,
- unsigned char *a_buf,
- short a_width,
- short a_height,
- Bool a_sync,
- RegionPtr a_clipping_region,
- pointer a_port_priv);
-
-static int ephyrReputImage (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_drw_x,
- short a_drw_y,
- RegionPtr a_clipping_region,
- pointer a_port_priv) ;
-
-static int ephyrPutVideo (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clip_region,
- pointer a_port_priv) ;
-
-static int ephyrGetVideo (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clip_region,
- pointer a_port_priv) ;
-
-static int ephyrPutStill (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clip_region,
- pointer a_port_priv) ;
-
-static int ephyrGetStill (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clip_region,
- pointer a_port_priv) ;
-
-static int ephyrQueryImageAttributes (KdScreenInfo *a_info,
- int a_id,
- unsigned short *a_w,
- unsigned short *a_h,
- int *a_pitches,
- int *a_offsets);
-static int s_base_port_id ;
-
-/**************
- * <helpers>
- * ************/
-
-static Bool
-DoSimpleClip (BoxPtr a_dst_box,
- BoxPtr a_clipper,
- BoxPtr a_result)
-{
- BoxRec dstClippedBox ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_dst_box && a_clipper && a_result, FALSE) ;
-
- /*
- * setup the clipbox inside the destination.
- */
- dstClippedBox.x1 = a_dst_box->x1 ;
- dstClippedBox.x2 = a_dst_box->x2 ;
- dstClippedBox.y1 = a_dst_box->y1 ;
- dstClippedBox.y2 = a_dst_box->y2 ;
-
- /*
- * if the cliper leftmost edge is inside
- * the destination area then the leftmost edge of the resulting
- * clipped box is the leftmost edge of the cliper.
- */
- if (a_clipper->x1 > dstClippedBox.x1)
- dstClippedBox.x1 = a_clipper->x1 ;
-
- /*
- * if the cliper top edge is inside the destination area
- * then the bottom horizontal edge of the resulting clipped box
- * is the bottom edge of the cliper
- */
- if (a_clipper->y1 > dstClippedBox.y1)
- dstClippedBox.y1 = a_clipper->y1 ;
-
- /*ditto for right edge*/
- if (a_clipper->x2 < dstClippedBox.x2)
- dstClippedBox.x2 = a_clipper->x2 ;
-
- /*ditto for bottom edge*/
- if (a_clipper->y2 < dstClippedBox.y2)
- dstClippedBox.y2 = a_clipper->y2 ;
-
- memcpy (a_result, &dstClippedBox, sizeof (dstClippedBox)) ;
- return TRUE ;
-}
-
-static Bool
-ephyrLocalAtomToHost (int a_local_atom, int *a_host_atom)
-{
- const char *atom_name=NULL;
- int host_atom=None ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_host_atom, FALSE) ;
-
- if (!ValidAtom (a_local_atom))
- return FALSE ;
-
- atom_name = NameForAtom (a_local_atom) ;
-
- if (!atom_name)
- return FALSE ;
-
- if (!ephyrHostGetAtom (atom_name, FALSE, &host_atom) || host_atom == None) {
- EPHYR_LOG_ERROR ("no atom for string %s defined in host X\n",
- atom_name) ;
- return FALSE ;
- }
- *a_host_atom = host_atom ;
- return TRUE ;
-}
-
-/*
- Not used yed.
-static Bool
-ephyrHostAtomToLocal (int a_host_atom, int *a_local_atom)
-{
- Bool is_ok=FALSE ;
- char *atom_name=NULL ;
- int atom=None ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_local_atom, FALSE) ;
-
- atom_name = ephyrHostGetAtomName (a_host_atom) ;
- if (!atom_name)
- goto out ;
-
- atom = MakeAtom (atom_name, strlen (atom_name), TRUE) ;
- if (atom == None)
- goto out ;
-
- *a_local_atom = atom ;
- is_ok = TRUE ;
-
-out:
- if (atom_name) {
- ephyrHostFree (atom_name) ;
- }
- return is_ok ;
-}
-*/
-
-/**************
- *</helpers>
- * ************/
-
-Bool
-ephyrInitVideo (ScreenPtr pScreen)
-{
- Bool is_ok = FALSE ;
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- static EphyrXVPriv *xv_priv;
-
- EPHYR_LOG ("enter\n") ;
-
- if (screen->fb.bitsPerPixel == 8) {
- EPHYR_LOG_ERROR ("8 bits depth not supported\n") ;
- return FALSE ;
- }
-
- if (!xv_priv) {
- xv_priv = ephyrXVPrivNew () ;
- }
- if (!xv_priv) {
- EPHYR_LOG_ERROR ("failed to create xv_priv\n") ;
- goto out ;
- }
-
- if (!ephyrXVPrivRegisterAdaptors (xv_priv, pScreen)) {
- EPHYR_LOG_ERROR ("failed to register adaptors\n") ;
- goto out ;
- }
- is_ok = TRUE ;
-
-out:
- return is_ok ;
-}
-
-static EphyrXVPriv*
-ephyrXVPrivNew (void)
-{
- EphyrXVPriv *xv_priv=NULL ;
-
- EPHYR_LOG ("enter\n") ;
-
- xv_priv = calloc(1, sizeof (EphyrXVPriv)) ;
- if (!xv_priv) {
- EPHYR_LOG_ERROR ("failed to create EphyrXVPriv\n") ;
- goto error ;
- }
-
- ephyrHostXVInit () ;
-
- if (!ephyrXVPrivQueryHostAdaptors (xv_priv)) {
- EPHYR_LOG_ERROR ("failed to query the host x for xv properties\n") ;
- goto error ;
- }
- if (!ephyrXVPrivSetAdaptorsHooks (xv_priv)) {
- EPHYR_LOG_ERROR ("failed to set xv_priv hooks\n") ;
- goto error ;
- }
-
- EPHYR_LOG ("leave\n") ;
- return xv_priv ;
-
-error:
- if (xv_priv) {
- ephyrXVPrivDelete (xv_priv) ;
- xv_priv = NULL ;
- }
- return NULL ;
-}
-
-static void
-ephyrXVPrivDelete (EphyrXVPriv *a_this)
-{
- EPHYR_LOG ("enter\n") ;
-
- if (!a_this)
- return ;
- if (a_this->host_adaptors) {
- ephyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
- a_this->host_adaptors = NULL ;
- }
- free(a_this->adaptors) ;
- a_this->adaptors = NULL ;
- free(a_this) ;
- EPHYR_LOG ("leave\n") ;
-}
-
-static KdVideoEncodingPtr
-videoEncodingDup (EphyrHostEncoding *a_encodings,
- int a_num_encodings)
-{
- KdVideoEncodingPtr result = NULL ;
- int i=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, NULL) ;
-
- result = calloc(a_num_encodings, sizeof (KdVideoEncodingRec)) ;
- for (i=0 ; i < a_num_encodings; i++) {
- result[i].id = a_encodings[i].id ;
- result[i].name = strdup (a_encodings[i].name) ;
- result[i].width = a_encodings[i].width ;
- result[i].height = a_encodings[i].height ;
- result[i].rate.numerator = a_encodings[i].rate.numerator ;
- result[i].rate.denominator = a_encodings[i].rate.denominator ;
- }
- return result ;
-}
-
-static KdAttributePtr
-portAttributesDup (EphyrHostAttribute *a_encodings,
- int a_num_encodings)
-{
- int i=0 ;
- KdAttributePtr result=NULL ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, NULL) ;
-
- result = calloc(a_num_encodings, sizeof (KdAttributeRec)) ;
- if (!result) {
- EPHYR_LOG_ERROR ("failed to allocate attributes\n") ;
- return NULL ;
- }
- for (i=0; i < a_num_encodings; i++) {
- result[i].flags = a_encodings[i].flags ;
- result[i].min_value = a_encodings[i].min_value ;
- result[i].max_value = a_encodings[i].max_value ;
- result[i].name = strdup (a_encodings[i].name) ;
- }
- return result ;
-}
-
-static Bool
-ephyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this)
-{
- EphyrHostXVAdaptor *cur_host_adaptor=NULL ;
- EphyrHostVideoFormat *video_formats=NULL ;
- EphyrHostEncoding *encodings=NULL ;
- EphyrHostAttribute *attributes=NULL ;
- EphyrHostImageFormat *image_formats=NULL ;
- int num_video_formats=0, base_port_id=0,
- num_attributes=0, num_formats=0, i=0,
- port_priv_offset=0;
- unsigned num_encodings=0 ;
- Bool is_ok = FALSE ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_this, FALSE) ;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!ephyrHostXVQueryAdaptors (&a_this->host_adaptors)) {
- EPHYR_LOG_ERROR ("failed to query host adaptors\n") ;
- goto out ;
- }
- if (a_this->host_adaptors)
- a_this->num_adaptors =
- ephyrHostXVAdaptorArrayGetSize (a_this->host_adaptors) ;
- if (a_this->num_adaptors < 0) {
- EPHYR_LOG_ERROR ("failed to get number of host adaptors\n") ;
- goto out ;
- }
- EPHYR_LOG ("host has %d adaptors\n", a_this->num_adaptors) ;
- /*
- * copy what we can from adaptors into a_this->adaptors
- */
- if (a_this->num_adaptors) {
- a_this->adaptors = calloc(a_this->num_adaptors,
- sizeof (KdVideoAdaptorRec)) ;
- if (!a_this->adaptors) {
- EPHYR_LOG_ERROR ("failed to create internal adaptors\n") ;
- goto out ;
- }
- }
- for (i=0; i < a_this->num_adaptors; i++) {
- int j=0 ;
- cur_host_adaptor =
- ephyrHostXVAdaptorArrayAt (a_this->host_adaptors, i) ;
- if (!cur_host_adaptor)
- continue ;
- a_this->adaptors[i].nPorts =
- ephyrHostXVAdaptorGetNbPorts (cur_host_adaptor) ;
- if (a_this->adaptors[i].nPorts <=0) {
- EPHYR_LOG_ERROR ("Could not find any port of adaptor %d\n", i) ;
- continue ;
- }
- a_this->adaptors[i].type =
- ephyrHostXVAdaptorGetType (cur_host_adaptor) ;
- a_this->adaptors[i].type |= XvWindowMask ;
- a_this->adaptors[i].flags =
- VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
- if (ephyrHostXVAdaptorGetName (cur_host_adaptor))
- a_this->adaptors[i].name =
- strdup (ephyrHostXVAdaptorGetName (cur_host_adaptor)) ;
- else
- a_this->adaptors[i].name = strdup ("Xephyr Video Overlay");
- base_port_id = ephyrHostXVAdaptorGetFirstPortID (cur_host_adaptor) ;
- if (base_port_id < 0) {
- EPHYR_LOG_ERROR ("failed to get port id for adaptor %d\n", i) ;
- continue ;
- }
- if (!s_base_port_id)
- s_base_port_id = base_port_id ;
-
- if (!ephyrHostXVQueryEncodings (base_port_id,
- &encodings,
- &num_encodings)) {
- EPHYR_LOG_ERROR ("failed to get encodings for port port id %d,"
- " adaptors %d\n",
- base_port_id, i) ;
- continue ;
- }
- a_this->adaptors[i].nEncodings = num_encodings ;
- a_this->adaptors[i].pEncodings =
- videoEncodingDup (encodings, num_encodings) ;
- video_formats = (EphyrHostVideoFormat*)
- ephyrHostXVAdaptorGetVideoFormats (cur_host_adaptor,
- &num_video_formats);
- a_this->adaptors[i].pFormats = (KdVideoFormatPtr) video_formats ;
- a_this->adaptors[i].nFormats = num_video_formats ;
- /* got a_this->adaptors[i].nPorts already
- a_this->adaptors[i].nPorts =
- ephyrHostXVAdaptorGetNbPorts (cur_host_adaptor) ;
- */
- a_this->adaptors[i].pPortPrivates =
- calloc(a_this->adaptors[i].nPorts,
- sizeof (DevUnion) + sizeof (EphyrPortPriv)) ;
- port_priv_offset = a_this->adaptors[i].nPorts;
- for (j=0; j < a_this->adaptors[i].nPorts; j++) {
- EphyrPortPriv *port_privs_base =
- (EphyrPortPriv*)&a_this->adaptors[i].pPortPrivates[port_priv_offset];
- EphyrPortPriv *port_priv = &port_privs_base[j] ;
- port_priv->port_number = base_port_id + j;
- port_priv->current_adaptor = &a_this->adaptors[i] ;
- port_priv->xv_priv = a_this ;
- a_this->adaptors[i].pPortPrivates[j].ptr = port_priv;
- }
- if (!ephyrHostXVQueryPortAttributes (base_port_id,
- &attributes,
- &num_attributes)) {
- EPHYR_LOG_ERROR ("failed to get port attribute "
- "for adaptor %d\n", i) ;
- continue ;
- }
- a_this->adaptors[i].pAttributes =
- portAttributesDup (attributes, num_attributes);
- a_this->adaptors[i].nAttributes = num_attributes ;
- /*make sure atoms of attrs names are created in xephyr*/
- for (j=0; j < a_this->adaptors[i].nAttributes; j++) {
- if (a_this->adaptors[i].pAttributes[j].name)
- MakeAtom (a_this->adaptors[i].pAttributes[j].name,
- strlen (a_this->adaptors[i].pAttributes[j].name),
- TRUE) ;
- }
- if (!ephyrHostXVQueryImageFormats (base_port_id,
- &image_formats,
- &num_formats)) {
- EPHYR_LOG_ERROR ("failed to get image formats "
- "for adaptor %d\n", i) ;
- continue ;
- }
- a_this->adaptors[i].pImages = (KdImagePtr) image_formats ;
- a_this->adaptors[i].nImages = num_formats ;
- }
- is_ok = TRUE ;
-
-out:
- if (encodings) {
- ephyrHostEncodingsDelete (encodings, num_encodings) ;
- encodings = NULL ;
- }
- if (attributes) {
- ephyrHostAttributesDelete (attributes) ;
- attributes = NULL ;
- }
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
-}
-
-static Bool
-ephyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this)
-{
- int i=0 ;
- Bool has_it=FALSE ;
- EphyrHostXVAdaptor *cur_host_adaptor=NULL ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_this, FALSE) ;
-
- EPHYR_LOG ("enter\n") ;
-
- for (i=0; i < a_this->num_adaptors; i++) {
- a_this->adaptors[i].ReputImage = ephyrReputImage ;
- a_this->adaptors[i].StopVideo = ephyrStopVideo ;
- a_this->adaptors[i].SetPortAttribute = ephyrSetPortAttribute ;
- a_this->adaptors[i].GetPortAttribute = ephyrGetPortAttribute ;
- a_this->adaptors[i].QueryBestSize = ephyrQueryBestSize ;
- a_this->adaptors[i].QueryImageAttributes = ephyrQueryImageAttributes ;
-
- cur_host_adaptor =
- ephyrHostXVAdaptorArrayAt (a_this->host_adaptors, i) ;
- if (!cur_host_adaptor) {
- EPHYR_LOG_ERROR ("failed to get host adaptor at index %d\n", i) ;
- continue ;
- }
- has_it = FALSE ;
- if (!ephyrHostXVAdaptorHasPutImage (cur_host_adaptor, &has_it)) {
- EPHYR_LOG_ERROR ("error\n") ;
- }
- if (has_it) {
- a_this->adaptors[i].PutImage = ephyrPutImage;
- }
-
- has_it = FALSE ;
- if (!ephyrHostXVAdaptorHasPutVideo (cur_host_adaptor, &has_it)) {
- EPHYR_LOG_ERROR ("error\n") ;
- }
- if (has_it) {
- a_this->adaptors[i].PutVideo = ephyrPutVideo;
- }
-
- has_it = FALSE ;
- if (!ephyrHostXVAdaptorHasGetVideo (cur_host_adaptor, &has_it)) {
- EPHYR_LOG_ERROR ("error\n") ;
- }
- if (has_it) {
- a_this->adaptors[i].GetVideo = ephyrGetVideo;
- }
-
- has_it = FALSE ;
- if (!ephyrHostXVAdaptorHasPutStill (cur_host_adaptor, &has_it)) {
- EPHYR_LOG_ERROR ("error\n") ;
- }
- if (has_it) {
- a_this->adaptors[i].PutStill = ephyrPutStill;
- }
-
- has_it = FALSE ;
- if (!ephyrHostXVAdaptorHasGetStill (cur_host_adaptor, &has_it)) {
- EPHYR_LOG_ERROR ("error\n") ;
- }
- if (has_it) {
- a_this->adaptors[i].GetStill = ephyrGetStill;
- }
- }
- EPHYR_LOG ("leave\n") ;
- return TRUE ;
-}
-
-static Bool
-ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
- ScreenPtr a_screen)
-{
- KdScreenPriv(a_screen);
- KdScreenInfo *screen = pScreenPriv->screen;
- Bool is_ok = FALSE ;
- KdVideoAdaptorPtr *adaptors=NULL, *registered_adaptors=NULL ;
- int num_registered_adaptors=0, i=0, num_adaptors=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_this && a_screen, FALSE) ;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!a_this->num_adaptors)
- goto out ;
- num_registered_adaptors =
- KdXVListGenericAdaptors (screen, &registered_adaptors);
-
- num_adaptors = num_registered_adaptors + a_this->num_adaptors ;
- adaptors = calloc(num_adaptors, sizeof (KdVideoAdaptorPtr)) ;
- if (!adaptors) {
- EPHYR_LOG_ERROR ("failed to allocate adaptors tab\n") ;
- goto out ;
- }
- memmove (adaptors, registered_adaptors, num_registered_adaptors) ;
- for (i=0 ; i < a_this->num_adaptors; i++) {
- *(adaptors + num_registered_adaptors + i) = &a_this->adaptors[i] ;
- }
- if (!KdXVScreenInit (a_screen, adaptors, num_adaptors)) {
- EPHYR_LOG_ERROR ("failed to register adaptors\n");
- goto out ;
- }
- EPHYR_LOG ("there are %d registered adaptors\n", num_adaptors) ;
- is_ok = TRUE ;
-
-out:
- free(registered_adaptors) ;
- registered_adaptors = NULL ;
- free(adaptors) ;
- adaptors = NULL ;
-
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
-}
-
-static Bool
-ephyrXVPrivIsAttrValueValid (KdAttributePtr a_attrs,
- int a_attrs_len,
- const char *a_attr_name,
- int a_attr_value,
- Bool *a_is_valid)
-{
- int i=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_attrs && a_attr_name && a_is_valid,
- FALSE) ;
-
- for (i=0; i < a_attrs_len; i++) {
- if (a_attrs[i].name && strcmp (a_attrs[i].name, a_attr_name))
- continue ;
- if (a_attrs[i].min_value > a_attr_value ||
- a_attrs[i].max_value < a_attr_value) {
- *a_is_valid = FALSE ;
- EPHYR_LOG_ERROR ("attribute was not valid\n"
- "value:%d. min:%d. max:%d\n",
- a_attr_value,
- a_attrs[i].min_value,
- a_attrs[i].max_value) ;
- } else {
- *a_is_valid = TRUE ;
- }
- return TRUE ;
- }
- return FALSE ;
-}
-
-static Bool
-ephyrXVPrivGetImageBufSize (int a_port_id,
- int a_image_id,
- unsigned short a_width,
- unsigned short a_height,
- int *a_size)
-{
- Bool is_ok=FALSE ;
- unsigned short width=a_width, height=a_height ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_size, FALSE) ;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!ephyrHostXVQueryImageAttributes (a_port_id, a_image_id,
- &width, &height, a_size, NULL, NULL)) {
- EPHYR_LOG_ERROR ("failed to get image attributes\n") ;
- goto out ;
- }
- is_ok = TRUE ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
-}
-
-static Bool
-ephyrXVPrivSaveImageToPortPriv (EphyrPortPriv *a_port_priv,
- const unsigned char *a_image_buf,
- int a_image_len)
-{
- Bool is_ok=FALSE ;
-
- EPHYR_LOG ("enter\n") ;
-
- if (a_port_priv->image_buf_size < a_image_len) {
- unsigned char *buf=NULL ;
- buf = realloc (a_port_priv->image_buf, a_image_len) ;
- if (!buf) {
- EPHYR_LOG_ERROR ("failed to realloc image buffer\n") ;
- goto out ;
- }
- a_port_priv->image_buf = buf ;
- a_port_priv->image_buf_size = a_image_len;
- }
- memmove (a_port_priv->image_buf, a_image_buf, a_image_len) ;
- is_ok = TRUE ;
-
-out:
- return is_ok ;
- EPHYR_LOG ("leave\n") ;
-}
-
-static void
-ephyrStopVideo (KdScreenInfo *a_info, pointer a_port_priv, Bool a_exit)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
-
- EPHYR_RETURN_IF_FAIL (a_info && a_info->pScreen) ;
- EPHYR_RETURN_IF_FAIL (port_priv) ;
-
- EPHYR_LOG ("enter\n") ;
- if (!ephyrHostXVStopVideo (a_info->pScreen->myNum,
- port_priv->port_number)) {
- EPHYR_LOG_ERROR ("XvStopVideo() failed\n") ;
- }
- EPHYR_LOG ("leave\n") ;
-}
-
-static int
-ephyrSetPortAttribute (KdScreenInfo *a_info,
- Atom a_attr_name,
- int a_attr_value,
- pointer a_port_priv)
-{
- int res=Success, host_atom=0 ;
- EphyrPortPriv *port_priv = a_port_priv ;
- Bool is_attr_valid=FALSE ;
-
- EPHYR_RETURN_VAL_IF_FAIL (port_priv, BadMatch) ;
- EPHYR_RETURN_VAL_IF_FAIL (port_priv->current_adaptor, BadMatch) ;
- EPHYR_RETURN_VAL_IF_FAIL (port_priv->current_adaptor->pAttributes,
- BadMatch) ;
- EPHYR_RETURN_VAL_IF_FAIL (port_priv->current_adaptor->nAttributes,
- BadMatch) ;
- EPHYR_RETURN_VAL_IF_FAIL (ValidAtom (a_attr_name), BadMatch) ;
-
- EPHYR_LOG ("enter, portnum:%d, atomid:%d, attr_name:%s, attr_val:%d\n",
- port_priv->port_number,
- (int)a_attr_name,
- NameForAtom (a_attr_name),
- a_attr_value) ;
-
- if (!ephyrLocalAtomToHost (a_attr_name, &host_atom)) {
- EPHYR_LOG_ERROR ("failed to convert local atom to host atom\n") ;
- res = BadMatch ;
- goto out ;
- }
-
- if (!ephyrXVPrivIsAttrValueValid (port_priv->current_adaptor->pAttributes,
- port_priv->current_adaptor->nAttributes,
- NameForAtom (a_attr_name),
- a_attr_value,
- &is_attr_valid)) {
- EPHYR_LOG_ERROR ("failed to validate attribute %s\n",
- NameForAtom (a_attr_name)) ;
- /*
- res = BadMatch ;
- goto out ;
- */
- }
- if (!is_attr_valid) {
- EPHYR_LOG_ERROR ("attribute %s is not valid\n",
- NameForAtom (a_attr_name)) ;
- /*
- res = BadMatch ;
- goto out ;
- */
- }
-
- if (!ephyrHostXVSetPortAttribute (port_priv->port_number,
- host_atom,
- a_attr_value)) {
- EPHYR_LOG_ERROR ("failed to set port attribute\n") ;
- res = BadMatch ;
- goto out ;
- }
-
- res = Success ;
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-static int
-ephyrGetPortAttribute (KdScreenInfo *a_screen_info,
- Atom a_attr_name,
- int *a_attr_value,
- pointer a_port_priv)
-{
- int res=Success, host_atom=0 ;
- EphyrPortPriv *port_priv = a_port_priv ;
-
- EPHYR_RETURN_VAL_IF_FAIL (port_priv, BadMatch) ;
- EPHYR_RETURN_VAL_IF_FAIL (ValidAtom (a_attr_name), BadMatch) ;
-
- EPHYR_LOG ("enter, portnum:%d, atomid:%d, attr_name:%s\n",
- port_priv->port_number,
- (int)a_attr_name,
- NameForAtom (a_attr_name)) ;
-
- if (!ephyrLocalAtomToHost (a_attr_name, &host_atom)) {
- EPHYR_LOG_ERROR ("failed to convert local atom to host atom\n") ;
- res = BadMatch ;
- goto out ;
- }
-
- if (!ephyrHostXVGetPortAttribute (port_priv->port_number,
- host_atom,
- a_attr_value)) {
- EPHYR_LOG_ERROR ("failed to get port attribute\n") ;
- res = BadMatch ;
- goto out ;
- }
-
- res = Success ;
-out:
- EPHYR_LOG ("leave\n") ;
- return res ;
-}
-
-static void
-ephyrQueryBestSize (KdScreenInfo *a_info,
- Bool a_motion,
- short a_src_w,
- short a_src_h,
- short a_drw_w,
- short a_drw_h,
- unsigned int *a_prefered_w,
- unsigned int *a_prefered_h,
- pointer a_port_priv)
-{
- int res=0 ;
- EphyrPortPriv *port_priv = a_port_priv ;
-
- EPHYR_RETURN_IF_FAIL (port_priv) ;
-
- EPHYR_LOG ("enter\n") ;
- res = ephyrHostXVQueryBestSize (port_priv->port_number,
- a_motion,
- a_src_w, a_src_h,
- a_drw_w, a_drw_h,
- a_prefered_w, a_prefered_h) ;
- if (!res) {
- EPHYR_LOG_ERROR ("Failed to query best size\n") ;
- }
- EPHYR_LOG ("leave\n") ;
-}
-
-static int
-ephyrPutImage (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_src_x,
- short a_src_y,
- short a_drw_x,
- short a_drw_y,
- short a_src_w,
- short a_src_h,
- short a_drw_w,
- short a_drw_h,
- int a_id,
- unsigned char *a_buf,
- short a_width,
- short a_height,
- Bool a_sync,
- RegionPtr a_clipping_region,
- pointer a_port_priv)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
- Bool is_ok=FALSE ;
- int result=BadImplementation, image_size=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_drawable, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!ephyrHostXVPutImage (a_info->pScreen->myNum,
- port_priv->port_number,
- a_id,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h,
- a_src_x, a_src_y, a_src_w, a_src_h,
- a_width, a_height, a_buf,
- (EphyrHostBox*)RegionRects (a_clipping_region),
- RegionNumRects (a_clipping_region))) {
- EPHYR_LOG_ERROR ("EphyrHostXVPutImage() failed\n") ;
- goto out ;
- }
-
- /*
- * Now save the image so that we can resend it to host it
- * later, in ReputImage.
- */
- if (!ephyrXVPrivGetImageBufSize (port_priv->port_number,
- a_id, a_width, a_height, &image_size)) {
- EPHYR_LOG_ERROR ("failed to get image size\n") ;
- /*this is a minor error so we won't get bail out abruptly*/
- is_ok = FALSE ;
- } else {
- is_ok = TRUE ;
- }
- if (is_ok) {
- if (!ephyrXVPrivSaveImageToPortPriv (port_priv, a_buf, image_size)) {
- is_ok=FALSE ;
- } else {
- port_priv->image_id = a_id;
- port_priv->drw_x = a_drw_x;
- port_priv->drw_y = a_drw_y;
- port_priv->drw_w = a_drw_w ;
- port_priv->drw_h = a_drw_h ;
- port_priv->src_x = a_src_x;
- port_priv->src_y = a_src_y ;
- port_priv->src_w = a_src_w ;
- port_priv->src_h = a_src_h ;
- port_priv->image_width = a_width ;
- port_priv->image_height = a_height ;
- }
- }
- if (!is_ok) {
- if (port_priv->image_buf) {
- free (port_priv->image_buf) ;
- port_priv->image_buf = NULL ;
- port_priv->image_buf_size = 0 ;
- }
- }
-
- result = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return result ;
-}
-
-static int
-ephyrReputImage (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_drw_x,
- short a_drw_y,
- RegionPtr a_clipping_region,
- pointer a_port_priv)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
- int result=BadImplementation ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_info->pScreen, FALSE) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- if (!port_priv->image_buf_size || !port_priv->image_buf) {
- EPHYR_LOG_ERROR ("has null image buf in cache\n") ;
- goto out ;
- }
- if (!ephyrHostXVPutImage (a_info->pScreen->myNum,
- port_priv->port_number,
- port_priv->image_id,
- a_drw_x, a_drw_y,
- port_priv->drw_w, port_priv->drw_h,
- port_priv->src_x, port_priv->src_y,
- port_priv->src_w, port_priv->src_h,
- port_priv->image_width, port_priv->image_height,
- port_priv->image_buf,
- (EphyrHostBox*)RegionRects (a_clipping_region),
- RegionNumRects (a_clipping_region))) {
- EPHYR_LOG_ERROR ("ephyrHostXVPutImage() failed\n") ;
- goto out ;
- }
-
- result = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return result ;
-}
-
-static int
-ephyrPutVideo (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clipping_region,
- pointer a_port_priv)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
- BoxRec clipped_area, dst_box ;
- int result=BadImplementation ;
- int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_info->pScreen, BadValue) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- dst_box.x1 = a_drw_x ;
- dst_box.x2 = a_drw_x + a_drw_w;
- dst_box.y1 = a_drw_y ;
- dst_box.y2 = a_drw_y + a_drw_h;
-
- if (!DoSimpleClip (&dst_box,
- RegionExtents(a_clipping_region),
- &clipped_area)) {
- EPHYR_LOG_ERROR ("failed to simple clip\n") ;
- goto out ;
- }
-
- drw_x = clipped_area.x1 ;
- drw_y = clipped_area.y1 ;
- drw_w = clipped_area.x2 - clipped_area.x1 ;
- drw_h = clipped_area.y2 - clipped_area.y1 ;
-
- if (!ephyrHostXVPutVideo (a_info->pScreen->myNum,
- port_priv->port_number,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
- EPHYR_LOG_ERROR ("ephyrHostXVPutVideo() failed\n") ;
- goto out ;
- }
- result = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return result ;
-}
-
-static int
-ephyrGetVideo (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clipping_region,
- pointer a_port_priv)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
- BoxRec clipped_area, dst_box ;
- int result=BadImplementation ;
- int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- dst_box.x1 = a_drw_x ;
- dst_box.x2 = a_drw_x + a_drw_w;
- dst_box.y1 = a_drw_y ;
- dst_box.y2 = a_drw_y + a_drw_h;
-
- if (!DoSimpleClip (&dst_box,
- RegionExtents(a_clipping_region),
- &clipped_area)) {
- EPHYR_LOG_ERROR ("failed to simple clip\n") ;
- goto out ;
- }
-
- drw_x = clipped_area.x1 ;
- drw_y = clipped_area.y1 ;
- drw_w = clipped_area.x2 - clipped_area.x1 ;
- drw_h = clipped_area.y2 - clipped_area.y1 ;
-
- if (!ephyrHostXVGetVideo (a_info->pScreen->myNum,
- port_priv->port_number,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
- EPHYR_LOG_ERROR ("ephyrHostXVGetVideo() failed\n") ;
- goto out ;
- }
- result = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return result ;
-}
-
-static int
-ephyrPutStill (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clipping_region,
- pointer a_port_priv)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
- BoxRec clipped_area, dst_box ;
- int result=BadImplementation ;
- int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- dst_box.x1 = a_drw_x ;
- dst_box.x2 = a_drw_x + a_drw_w;
- dst_box.y1 = a_drw_y ;
- dst_box.y2 = a_drw_y + a_drw_h;
-
- if (!DoSimpleClip (&dst_box,
- RegionExtents(a_clipping_region),
- &clipped_area)) {
- EPHYR_LOG_ERROR ("failed to simple clip\n") ;
- goto out ;
- }
-
- drw_x = clipped_area.x1 ;
- drw_y = clipped_area.y1 ;
- drw_w = clipped_area.x2 - clipped_area.x1 ;
- drw_h = clipped_area.y2 - clipped_area.y1 ;
-
- if (!ephyrHostXVPutStill (a_info->pScreen->myNum,
- port_priv->port_number,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
- EPHYR_LOG_ERROR ("ephyrHostXVPutStill() failed\n") ;
- goto out ;
- }
- result = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return result ;
-}
-
-static int
-ephyrGetStill (KdScreenInfo *a_info,
- DrawablePtr a_drawable,
- short a_vid_x, short a_vid_y,
- short a_drw_x, short a_drw_y,
- short a_vid_w, short a_vid_h,
- short a_drw_w, short a_drw_h,
- RegionPtr a_clipping_region,
- pointer a_port_priv)
-{
- EphyrPortPriv *port_priv = a_port_priv ;
- BoxRec clipped_area, dst_box ;
- int result=BadImplementation ;
- int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
- EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
-
- EPHYR_LOG ("enter\n") ;
-
- dst_box.x1 = a_drw_x ;
- dst_box.x2 = a_drw_x + a_drw_w;
- dst_box.y1 = a_drw_y ;
- dst_box.y2 = a_drw_y + a_drw_h;
-
- if (!DoSimpleClip (&dst_box,
- RegionExtents(a_clipping_region),
- &clipped_area)) {
- EPHYR_LOG_ERROR ("failed to simple clip\n") ;
- goto out ;
- }
-
- drw_x = clipped_area.x1 ;
- drw_y = clipped_area.y1 ;
- drw_w = clipped_area.x2 - clipped_area.x1 ;
- drw_h = clipped_area.y2 - clipped_area.y1 ;
-
- if (!ephyrHostXVGetStill (a_info->pScreen->myNum,
- port_priv->port_number,
- a_vid_x, a_vid_y, a_vid_w, a_vid_h,
- a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
- EPHYR_LOG_ERROR ("ephyrHostXVGetStill() failed\n") ;
- goto out ;
- }
- result = Success ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return result ;
-}
-
-static int
-ephyrQueryImageAttributes (KdScreenInfo *a_info,
- int a_id,
- unsigned short *a_w,
- unsigned short *a_h,
- int *a_pitches,
- int *a_offsets)
-{
- int image_size=0 ;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_w && a_h, FALSE) ;
-
- EPHYR_LOG ("enter: dim (%dx%d), pitches: %p, offsets: %p\n",
- *a_w, *a_h, a_pitches, a_offsets) ;
-
- if (!ephyrHostXVQueryImageAttributes (s_base_port_id,
- a_id,
- a_w, a_h,
- &image_size,
- a_pitches, a_offsets)) {
- EPHYR_LOG_ERROR ("EphyrHostXVQueryImageAttributes() failed\n") ;
- goto out ;
- }
- EPHYR_LOG ("image size: %d, dim (%dx%d)\n", image_size, *a_w, *a_h) ;
-
-out:
- EPHYR_LOG ("leave\n") ;
- return image_size ;
-}
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include <string.h>
+#include <X11/extensions/Xv.h>
+#include "ephyrlog.h"
+#include "kdrive.h"
+#include "kxv.h"
+#include "ephyr.h"
+#include "hostx.h"
+#include "ephyrhostvideo.h"
+
+struct _EphyrXVPriv {
+ EphyrHostXVAdaptorArray *host_adaptors;
+ KdVideoAdaptorPtr adaptors;
+ int num_adaptors;
+};
+typedef struct _EphyrXVPriv EphyrXVPriv;
+
+struct _EphyrPortPriv {
+ int port_number;
+ KdVideoAdaptorPtr current_adaptor;
+ EphyrXVPriv *xv_priv;
+ unsigned char *image_buf;
+ int image_buf_size;
+ int image_id;
+ int drw_x, drw_y, drw_w, drw_h;
+ int src_x, src_y, src_w, src_h;
+ int image_width, image_height;
+};
+typedef struct _EphyrPortPriv EphyrPortPriv;
+
+static Bool DoSimpleClip(BoxPtr a_dst_drw, BoxPtr a_clipper, BoxPtr a_result);
+
+static Bool ephyrLocalAtomToHost(int a_local_atom, int *a_host_atom);
+
+/*
+static Bool ephyrHostAtomToLocal (int a_host_atom, int *a_local_atom) ;
+*/
+
+static EphyrXVPriv *ephyrXVPrivNew(void);
+static void ephyrXVPrivDelete(EphyrXVPriv * a_this);
+static Bool ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this);
+static Bool ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this);
+static Bool ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this,
+ ScreenPtr a_screen);
+
+static Bool ephyrXVPrivIsAttrValueValid(KdAttributePtr a_attrs,
+ int a_attrs_len,
+ const char *a_attr_name,
+ int a_attr_value, Bool *a_is_valid);
+
+static Bool ephyrXVPrivGetImageBufSize(int a_port_id,
+ int a_image_id,
+ unsigned short a_width,
+ unsigned short a_height, int *a_size);
+
+static Bool ephyrXVPrivSaveImageToPortPriv(EphyrPortPriv * a_port_priv,
+ const unsigned char *a_image,
+ int a_image_len);
+
+static void ephyrStopVideo(KdScreenInfo * a_info,
+ pointer a_xv_priv, Bool a_exit);
+
+static int ephyrSetPortAttribute(KdScreenInfo * a_info,
+ Atom a_attr_name,
+ int a_attr_value, pointer a_port_priv);
+
+static int ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
+ Atom a_attr_name,
+ int *a_attr_value, pointer a_port_priv);
+
+static void ephyrQueryBestSize(KdScreenInfo * a_info,
+ Bool a_motion,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ unsigned int *a_prefered_w,
+ unsigned int *a_prefered_h, pointer a_port_priv);
+
+static int ephyrPutImage(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_src_x,
+ short a_src_y,
+ short a_drw_x,
+ short a_drw_y,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ int a_id,
+ unsigned char *a_buf,
+ short a_width,
+ short a_height,
+ Bool a_sync,
+ RegionPtr a_clipping_region, pointer a_port_priv);
+
+static int ephyrReputImage(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_drw_x,
+ short a_drw_y,
+ RegionPtr a_clipping_region, pointer a_port_priv);
+
+static int ephyrPutVideo(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region, pointer a_port_priv);
+
+static int ephyrGetVideo(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region, pointer a_port_priv);
+
+static int ephyrPutStill(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region, pointer a_port_priv);
+
+static int ephyrGetStill(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region, pointer a_port_priv);
+
+static int ephyrQueryImageAttributes(KdScreenInfo * a_info,
+ int a_id,
+ unsigned short *a_w,
+ unsigned short *a_h,
+ int *a_pitches, int *a_offsets);
+static int s_base_port_id;
+
+/**************
+ * <helpers>
+ * ************/
+
+static Bool
+DoSimpleClip(BoxPtr a_dst_box, BoxPtr a_clipper, BoxPtr a_result)
+{
+ BoxRec dstClippedBox;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_dst_box && a_clipper && a_result, FALSE);
+
+ /*
+ * setup the clipbox inside the destination.
+ */
+ dstClippedBox.x1 = a_dst_box->x1;
+ dstClippedBox.x2 = a_dst_box->x2;
+ dstClippedBox.y1 = a_dst_box->y1;
+ dstClippedBox.y2 = a_dst_box->y2;
+
+ /*
+ * if the cliper leftmost edge is inside
+ * the destination area then the leftmost edge of the resulting
+ * clipped box is the leftmost edge of the cliper.
+ */
+ if (a_clipper->x1 > dstClippedBox.x1)
+ dstClippedBox.x1 = a_clipper->x1;
+
+ /*
+ * if the cliper top edge is inside the destination area
+ * then the bottom horizontal edge of the resulting clipped box
+ * is the bottom edge of the cliper
+ */
+ if (a_clipper->y1 > dstClippedBox.y1)
+ dstClippedBox.y1 = a_clipper->y1;
+
+ /*ditto for right edge */
+ if (a_clipper->x2 < dstClippedBox.x2)
+ dstClippedBox.x2 = a_clipper->x2;
+
+ /*ditto for bottom edge */
+ if (a_clipper->y2 < dstClippedBox.y2)
+ dstClippedBox.y2 = a_clipper->y2;
+
+ memcpy(a_result, &dstClippedBox, sizeof(dstClippedBox));
+ return TRUE;
+}
+
+static Bool
+ephyrLocalAtomToHost(int a_local_atom, int *a_host_atom)
+{
+ const char *atom_name = NULL;
+ int host_atom = None;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_host_atom, FALSE);
+
+ if (!ValidAtom(a_local_atom))
+ return FALSE;
+
+ atom_name = NameForAtom(a_local_atom);
+
+ if (!atom_name)
+ return FALSE;
+
+ if (!ephyrHostGetAtom(atom_name, FALSE, &host_atom) || host_atom == None) {
+ EPHYR_LOG_ERROR("no atom for string %s defined in host X\n", atom_name);
+ return FALSE;
+ }
+ *a_host_atom = host_atom;
+ return TRUE;
+}
+
+/*
+ Not used yed.
+static Bool
+ephyrHostAtomToLocal (int a_host_atom, int *a_local_atom)
+{
+ Bool is_ok=FALSE ;
+ char *atom_name=NULL ;
+ int atom=None ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_local_atom, FALSE) ;
+
+ atom_name = ephyrHostGetAtomName (a_host_atom) ;
+ if (!atom_name)
+ goto out ;
+
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE) ;
+ if (atom == None)
+ goto out ;
+
+ *a_local_atom = atom ;
+ is_ok = TRUE ;
+
+out:
+ if (atom_name) {
+ ephyrHostFree (atom_name) ;
+ }
+ return is_ok ;
+}
+*/
+
+/**************
+ *</helpers>
+ * ************/
+
+Bool
+ephyrInitVideo(ScreenPtr pScreen)
+{
+ Bool is_ok = FALSE;
+
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ static EphyrXVPriv *xv_priv;
+
+ EPHYR_LOG("enter\n");
+
+ if (screen->fb.bitsPerPixel == 8) {
+ EPHYR_LOG_ERROR("8 bits depth not supported\n");
+ return FALSE;
+ }
+
+ if (!xv_priv) {
+ xv_priv = ephyrXVPrivNew();
+ }
+ if (!xv_priv) {
+ EPHYR_LOG_ERROR("failed to create xv_priv\n");
+ goto out;
+ }
+
+ if (!ephyrXVPrivRegisterAdaptors(xv_priv, pScreen)) {
+ EPHYR_LOG_ERROR("failed to register adaptors\n");
+ goto out;
+ }
+ is_ok = TRUE;
+
+ out:
+ return is_ok;
+}
+
+static EphyrXVPriv *
+ephyrXVPrivNew(void)
+{
+ EphyrXVPriv *xv_priv = NULL;
+
+ EPHYR_LOG("enter\n");
+
+ xv_priv = calloc(1, sizeof(EphyrXVPriv));
+ if (!xv_priv) {
+ EPHYR_LOG_ERROR("failed to create EphyrXVPriv\n");
+ goto error;
+ }
+
+ ephyrHostXVInit();
+
+ if (!ephyrXVPrivQueryHostAdaptors(xv_priv)) {
+ EPHYR_LOG_ERROR("failed to query the host x for xv properties\n");
+ goto error;
+ }
+ if (!ephyrXVPrivSetAdaptorsHooks(xv_priv)) {
+ EPHYR_LOG_ERROR("failed to set xv_priv hooks\n");
+ goto error;
+ }
+
+ EPHYR_LOG("leave\n");
+ return xv_priv;
+
+ error:
+ if (xv_priv) {
+ ephyrXVPrivDelete(xv_priv);
+ xv_priv = NULL;
+ }
+ return NULL;
+}
+
+static void
+ephyrXVPrivDelete(EphyrXVPriv * a_this)
+{
+ EPHYR_LOG("enter\n");
+
+ if (!a_this)
+ return;
+ if (a_this->host_adaptors) {
+ ephyrHostXVAdaptorArrayDelete(a_this->host_adaptors);
+ a_this->host_adaptors = NULL;
+ }
+ free(a_this->adaptors);
+ a_this->adaptors = NULL;
+ free(a_this);
+ EPHYR_LOG("leave\n");
+}
+
+static KdVideoEncodingPtr
+videoEncodingDup(EphyrHostEncoding * a_encodings, int a_num_encodings)
+{
+ KdVideoEncodingPtr result = NULL;
+ int i = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_encodings && a_num_encodings, NULL);
+
+ result = calloc(a_num_encodings, sizeof(KdVideoEncodingRec));
+ for (i = 0; i < a_num_encodings; i++) {
+ result[i].id = a_encodings[i].id;
+ result[i].name = strdup(a_encodings[i].name);
+ result[i].width = a_encodings[i].width;
+ result[i].height = a_encodings[i].height;
+ result[i].rate.numerator = a_encodings[i].rate.numerator;
+ result[i].rate.denominator = a_encodings[i].rate.denominator;
+ }
+ return result;
+}
+
+static KdAttributePtr
+portAttributesDup(EphyrHostAttribute * a_encodings, int a_num_encodings)
+{
+ int i = 0;
+ KdAttributePtr result = NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_encodings && a_num_encodings, NULL);
+
+ result = calloc(a_num_encodings, sizeof(KdAttributeRec));
+ if (!result) {
+ EPHYR_LOG_ERROR("failed to allocate attributes\n");
+ return NULL;
+ }
+ for (i = 0; i < a_num_encodings; i++) {
+ result[i].flags = a_encodings[i].flags;
+ result[i].min_value = a_encodings[i].min_value;
+ result[i].max_value = a_encodings[i].max_value;
+ result[i].name = strdup(a_encodings[i].name);
+ }
+ return result;
+}
+
+static Bool
+ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this)
+{
+ EphyrHostXVAdaptor *cur_host_adaptor = NULL;
+ EphyrHostVideoFormat *video_formats = NULL;
+ EphyrHostEncoding *encodings = NULL;
+ EphyrHostAttribute *attributes = NULL;
+ EphyrHostImageFormat *image_formats = NULL;
+ int num_video_formats = 0, base_port_id = 0,
+ num_attributes = 0, num_formats = 0, i = 0, port_priv_offset = 0;
+ unsigned num_encodings = 0;
+ Bool is_ok = FALSE;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, FALSE);
+
+ EPHYR_LOG("enter\n");
+
+ if (!ephyrHostXVQueryAdaptors(&a_this->host_adaptors)) {
+ EPHYR_LOG_ERROR("failed to query host adaptors\n");
+ goto out;
+ }
+ if (a_this->host_adaptors)
+ a_this->num_adaptors =
+ ephyrHostXVAdaptorArrayGetSize(a_this->host_adaptors);
+ if (a_this->num_adaptors < 0) {
+ EPHYR_LOG_ERROR("failed to get number of host adaptors\n");
+ goto out;
+ }
+ EPHYR_LOG("host has %d adaptors\n", a_this->num_adaptors);
+ /*
+ * copy what we can from adaptors into a_this->adaptors
+ */
+ if (a_this->num_adaptors) {
+ a_this->adaptors = calloc(a_this->num_adaptors,
+ sizeof(KdVideoAdaptorRec));
+ if (!a_this->adaptors) {
+ EPHYR_LOG_ERROR("failed to create internal adaptors\n");
+ goto out;
+ }
+ }
+ for (i = 0; i < a_this->num_adaptors; i++) {
+ int j = 0;
+
+ cur_host_adaptor = ephyrHostXVAdaptorArrayAt(a_this->host_adaptors, i);
+ if (!cur_host_adaptor)
+ continue;
+ a_this->adaptors[i].nPorts =
+ ephyrHostXVAdaptorGetNbPorts(cur_host_adaptor);
+ if (a_this->adaptors[i].nPorts <= 0) {
+ EPHYR_LOG_ERROR("Could not find any port of adaptor %d\n", i);
+ continue;
+ }
+ a_this->adaptors[i].type = ephyrHostXVAdaptorGetType(cur_host_adaptor);
+ a_this->adaptors[i].type |= XvWindowMask;
+ a_this->adaptors[i].flags =
+ VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ if (ephyrHostXVAdaptorGetName(cur_host_adaptor))
+ a_this->adaptors[i].name =
+ strdup(ephyrHostXVAdaptorGetName(cur_host_adaptor));
+ else
+ a_this->adaptors[i].name = strdup("Xephyr Video Overlay");
+ base_port_id = ephyrHostXVAdaptorGetFirstPortID(cur_host_adaptor);
+ if (base_port_id < 0) {
+ EPHYR_LOG_ERROR("failed to get port id for adaptor %d\n", i);
+ continue;
+ }
+ if (!s_base_port_id)
+ s_base_port_id = base_port_id;
+
+ if (!ephyrHostXVQueryEncodings(base_port_id,
+ &encodings, &num_encodings)) {
+ EPHYR_LOG_ERROR("failed to get encodings for port port id %d,"
+ " adaptors %d\n", base_port_id, i);
+ continue;
+ }
+ a_this->adaptors[i].nEncodings = num_encodings;
+ a_this->adaptors[i].pEncodings =
+ videoEncodingDup(encodings, num_encodings);
+ video_formats = (EphyrHostVideoFormat *)
+ ephyrHostXVAdaptorGetVideoFormats(cur_host_adaptor,
+ &num_video_formats);
+ a_this->adaptors[i].pFormats = (KdVideoFormatPtr) video_formats;
+ a_this->adaptors[i].nFormats = num_video_formats;
+ /* got a_this->adaptors[i].nPorts already
+ a_this->adaptors[i].nPorts =
+ ephyrHostXVAdaptorGetNbPorts (cur_host_adaptor) ;
+ */
+ a_this->adaptors[i].pPortPrivates =
+ calloc(a_this->adaptors[i].nPorts,
+ sizeof(DevUnion) + sizeof(EphyrPortPriv));
+ port_priv_offset = a_this->adaptors[i].nPorts;
+ for (j = 0; j < a_this->adaptors[i].nPorts; j++) {
+ EphyrPortPriv *port_privs_base =
+ (EphyrPortPriv *) & a_this->adaptors[i].
+ pPortPrivates[port_priv_offset];
+ EphyrPortPriv *port_priv = &port_privs_base[j];
+
+ port_priv->port_number = base_port_id + j;
+ port_priv->current_adaptor = &a_this->adaptors[i];
+ port_priv->xv_priv = a_this;
+ a_this->adaptors[i].pPortPrivates[j].ptr = port_priv;
+ }
+ if (!ephyrHostXVQueryPortAttributes(base_port_id,
+ &attributes, &num_attributes)) {
+ EPHYR_LOG_ERROR("failed to get port attribute "
+ "for adaptor %d\n", i);
+ continue;
+ }
+ a_this->adaptors[i].pAttributes =
+ portAttributesDup(attributes, num_attributes);
+ a_this->adaptors[i].nAttributes = num_attributes;
+ /*make sure atoms of attrs names are created in xephyr */
+ for (j = 0; j < a_this->adaptors[i].nAttributes; j++) {
+ if (a_this->adaptors[i].pAttributes[j].name)
+ MakeAtom(a_this->adaptors[i].pAttributes[j].name,
+ strlen(a_this->adaptors[i].pAttributes[j].name), TRUE);
+ }
+ if (!ephyrHostXVQueryImageFormats(base_port_id,
+ &image_formats, &num_formats)) {
+ EPHYR_LOG_ERROR("failed to get image formats "
+ "for adaptor %d\n", i);
+ continue;
+ }
+ a_this->adaptors[i].pImages = (KdImagePtr) image_formats;
+ a_this->adaptors[i].nImages = num_formats;
+ }
+ is_ok = TRUE;
+
+ out:
+ if (encodings) {
+ ephyrHostEncodingsDelete(encodings, num_encodings);
+ encodings = NULL;
+ }
+ if (attributes) {
+ ephyrHostAttributesDelete(attributes);
+ attributes = NULL;
+ }
+ EPHYR_LOG("leave\n");
+ return is_ok;
+}
+
+static Bool
+ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this)
+{
+ int i = 0;
+ Bool has_it = FALSE;
+ EphyrHostXVAdaptor *cur_host_adaptor = NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_this, FALSE);
+
+ EPHYR_LOG("enter\n");
+
+ for (i = 0; i < a_this->num_adaptors; i++) {
+ a_this->adaptors[i].ReputImage = ephyrReputImage;
+ a_this->adaptors[i].StopVideo = ephyrStopVideo;
+ a_this->adaptors[i].SetPortAttribute = ephyrSetPortAttribute;
+ a_this->adaptors[i].GetPortAttribute = ephyrGetPortAttribute;
+ a_this->adaptors[i].QueryBestSize = ephyrQueryBestSize;
+ a_this->adaptors[i].QueryImageAttributes = ephyrQueryImageAttributes;
+
+ cur_host_adaptor = ephyrHostXVAdaptorArrayAt(a_this->host_adaptors, i);
+ if (!cur_host_adaptor) {
+ EPHYR_LOG_ERROR("failed to get host adaptor at index %d\n", i);
+ continue;
+ }
+ has_it = FALSE;
+ if (!ephyrHostXVAdaptorHasPutImage(cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR("error\n");
+ }
+ if (has_it) {
+ a_this->adaptors[i].PutImage = ephyrPutImage;
+ }
+
+ has_it = FALSE;
+ if (!ephyrHostXVAdaptorHasPutVideo(cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR("error\n");
+ }
+ if (has_it) {
+ a_this->adaptors[i].PutVideo = ephyrPutVideo;
+ }
+
+ has_it = FALSE;
+ if (!ephyrHostXVAdaptorHasGetVideo(cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR("error\n");
+ }
+ if (has_it) {
+ a_this->adaptors[i].GetVideo = ephyrGetVideo;
+ }
+
+ has_it = FALSE;
+ if (!ephyrHostXVAdaptorHasPutStill(cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR("error\n");
+ }
+ if (has_it) {
+ a_this->adaptors[i].PutStill = ephyrPutStill;
+ }
+
+ has_it = FALSE;
+ if (!ephyrHostXVAdaptorHasGetStill(cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR("error\n");
+ }
+ if (has_it) {
+ a_this->adaptors[i].GetStill = ephyrGetStill;
+ }
+ }
+ EPHYR_LOG("leave\n");
+ return TRUE;
+}
+
+static Bool
+ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this, ScreenPtr a_screen)
+{
+ KdScreenPriv(a_screen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ Bool is_ok = FALSE;
+ KdVideoAdaptorPtr *adaptors = NULL, *registered_adaptors = NULL;
+ int num_registered_adaptors = 0, i = 0, num_adaptors = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_this && a_screen, FALSE);
+
+ EPHYR_LOG("enter\n");
+
+ if (!a_this->num_adaptors)
+ goto out;
+ num_registered_adaptors =
+ KdXVListGenericAdaptors(screen, &registered_adaptors);
+
+ num_adaptors = num_registered_adaptors + a_this->num_adaptors;
+ adaptors = calloc(num_adaptors, sizeof(KdVideoAdaptorPtr));
+ if (!adaptors) {
+ EPHYR_LOG_ERROR("failed to allocate adaptors tab\n");
+ goto out;
+ }
+ memmove(adaptors, registered_adaptors, num_registered_adaptors);
+ for (i = 0; i < a_this->num_adaptors; i++) {
+ *(adaptors + num_registered_adaptors + i) = &a_this->adaptors[i];
+ }
+ if (!KdXVScreenInit(a_screen, adaptors, num_adaptors)) {
+ EPHYR_LOG_ERROR("failed to register adaptors\n");
+ goto out;
+ }
+ EPHYR_LOG("there are %d registered adaptors\n", num_adaptors);
+ is_ok = TRUE;
+
+ out:
+ free(registered_adaptors);
+ registered_adaptors = NULL;
+ free(adaptors);
+ adaptors = NULL;
+
+ EPHYR_LOG("leave\n");
+ return is_ok;
+}
+
+static Bool
+ephyrXVPrivIsAttrValueValid(KdAttributePtr a_attrs,
+ int a_attrs_len,
+ const char *a_attr_name,
+ int a_attr_value, Bool *a_is_valid)
+{
+ int i = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_attrs && a_attr_name && a_is_valid, FALSE);
+
+ for (i = 0; i < a_attrs_len; i++) {
+ if (a_attrs[i].name && strcmp(a_attrs[i].name, a_attr_name))
+ continue;
+ if (a_attrs[i].min_value > a_attr_value ||
+ a_attrs[i].max_value < a_attr_value) {
+ *a_is_valid = FALSE;
+ EPHYR_LOG_ERROR("attribute was not valid\n"
+ "value:%d. min:%d. max:%d\n",
+ a_attr_value,
+ a_attrs[i].min_value, a_attrs[i].max_value);
+ }
+ else {
+ *a_is_valid = TRUE;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static Bool
+ephyrXVPrivGetImageBufSize(int a_port_id,
+ int a_image_id,
+ unsigned short a_width,
+ unsigned short a_height, int *a_size)
+{
+ Bool is_ok = FALSE;
+ unsigned short width = a_width, height = a_height;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_size, FALSE);
+
+ EPHYR_LOG("enter\n");
+
+ if (!ephyrHostXVQueryImageAttributes(a_port_id, a_image_id,
+ &width, &height, a_size, NULL, NULL)) {
+ EPHYR_LOG_ERROR("failed to get image attributes\n");
+ goto out;
+ }
+ is_ok = TRUE;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
+}
+
+static Bool
+ephyrXVPrivSaveImageToPortPriv(EphyrPortPriv * a_port_priv,
+ const unsigned char *a_image_buf,
+ int a_image_len)
+{
+ Bool is_ok = FALSE;
+
+ EPHYR_LOG("enter\n");
+
+ if (a_port_priv->image_buf_size < a_image_len) {
+ unsigned char *buf = NULL;
+
+ buf = realloc(a_port_priv->image_buf, a_image_len);
+ if (!buf) {
+ EPHYR_LOG_ERROR("failed to realloc image buffer\n");
+ goto out;
+ }
+ a_port_priv->image_buf = buf;
+ a_port_priv->image_buf_size = a_image_len;
+ }
+ memmove(a_port_priv->image_buf, a_image_buf, a_image_len);
+ is_ok = TRUE;
+
+ out:
+ return is_ok;
+ EPHYR_LOG("leave\n");
+}
+
+static void
+ephyrStopVideo(KdScreenInfo * a_info, pointer a_port_priv, Bool a_exit)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+
+ EPHYR_RETURN_IF_FAIL(a_info && a_info->pScreen);
+ EPHYR_RETURN_IF_FAIL(port_priv);
+
+ EPHYR_LOG("enter\n");
+ if (!ephyrHostXVStopVideo(a_info->pScreen->myNum, port_priv->port_number)) {
+ EPHYR_LOG_ERROR("XvStopVideo() failed\n");
+ }
+ EPHYR_LOG("leave\n");
+}
+
+static int
+ephyrSetPortAttribute(KdScreenInfo * a_info,
+ Atom a_attr_name, int a_attr_value, pointer a_port_priv)
+{
+ int res = Success, host_atom = 0;
+ EphyrPortPriv *port_priv = a_port_priv;
+ Bool is_attr_valid = FALSE;
+
+ EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
+ EPHYR_RETURN_VAL_IF_FAIL(port_priv->current_adaptor, BadMatch);
+ EPHYR_RETURN_VAL_IF_FAIL(port_priv->current_adaptor->pAttributes, BadMatch);
+ EPHYR_RETURN_VAL_IF_FAIL(port_priv->current_adaptor->nAttributes, BadMatch);
+ EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);
+
+ EPHYR_LOG("enter, portnum:%d, atomid:%d, attr_name:%s, attr_val:%d\n",
+ port_priv->port_number,
+ (int) a_attr_name, NameForAtom(a_attr_name), a_attr_value);
+
+ if (!ephyrLocalAtomToHost(a_attr_name, &host_atom)) {
+ EPHYR_LOG_ERROR("failed to convert local atom to host atom\n");
+ res = BadMatch;
+ goto out;
+ }
+
+ if (!ephyrXVPrivIsAttrValueValid(port_priv->current_adaptor->pAttributes,
+ port_priv->current_adaptor->nAttributes,
+ NameForAtom(a_attr_name),
+ a_attr_value, &is_attr_valid)) {
+ EPHYR_LOG_ERROR("failed to validate attribute %s\n",
+ NameForAtom(a_attr_name));
+ /*
+ res = BadMatch ;
+ goto out ;
+ */
+ }
+ if (!is_attr_valid) {
+ EPHYR_LOG_ERROR("attribute %s is not valid\n",
+ NameForAtom(a_attr_name));
+ /*
+ res = BadMatch ;
+ goto out ;
+ */
+ }
+
+ if (!ephyrHostXVSetPortAttribute(port_priv->port_number,
+ host_atom, a_attr_value)) {
+ EPHYR_LOG_ERROR("failed to set port attribute\n");
+ res = BadMatch;
+ goto out;
+ }
+
+ res = Success;
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+static int
+ephyrGetPortAttribute(KdScreenInfo * a_screen_info,
+ Atom a_attr_name, int *a_attr_value, pointer a_port_priv)
+{
+ int res = Success, host_atom = 0;
+ EphyrPortPriv *port_priv = a_port_priv;
+
+ EPHYR_RETURN_VAL_IF_FAIL(port_priv, BadMatch);
+ EPHYR_RETURN_VAL_IF_FAIL(ValidAtom(a_attr_name), BadMatch);
+
+ EPHYR_LOG("enter, portnum:%d, atomid:%d, attr_name:%s\n",
+ port_priv->port_number,
+ (int) a_attr_name, NameForAtom(a_attr_name));
+
+ if (!ephyrLocalAtomToHost(a_attr_name, &host_atom)) {
+ EPHYR_LOG_ERROR("failed to convert local atom to host atom\n");
+ res = BadMatch;
+ goto out;
+ }
+
+ if (!ephyrHostXVGetPortAttribute(port_priv->port_number,
+ host_atom, a_attr_value)) {
+ EPHYR_LOG_ERROR("failed to get port attribute\n");
+ res = BadMatch;
+ goto out;
+ }
+
+ res = Success;
+ out:
+ EPHYR_LOG("leave\n");
+ return res;
+}
+
+static void
+ephyrQueryBestSize(KdScreenInfo * a_info,
+ Bool a_motion,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ unsigned int *a_prefered_w,
+ unsigned int *a_prefered_h, pointer a_port_priv)
+{
+ int res = 0;
+ EphyrPortPriv *port_priv = a_port_priv;
+
+ EPHYR_RETURN_IF_FAIL(port_priv);
+
+ EPHYR_LOG("enter\n");
+ res = ephyrHostXVQueryBestSize(port_priv->port_number,
+ a_motion,
+ a_src_w, a_src_h,
+ a_drw_w, a_drw_h,
+ a_prefered_w, a_prefered_h);
+ if (!res) {
+ EPHYR_LOG_ERROR("Failed to query best size\n");
+ }
+ EPHYR_LOG("leave\n");
+}
+
+static int
+ephyrPutImage(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_src_x,
+ short a_src_y,
+ short a_drw_x,
+ short a_drw_y,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ int a_id,
+ unsigned char *a_buf,
+ short a_width,
+ short a_height,
+ Bool a_sync, RegionPtr a_clipping_region, pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+ Bool is_ok = FALSE;
+ int result = BadImplementation, image_size = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_info && a_info->pScreen, BadValue);
+ EPHYR_RETURN_VAL_IF_FAIL(a_drawable, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ if (!ephyrHostXVPutImage(a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_id,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h,
+ a_src_x, a_src_y, a_src_w, a_src_h,
+ a_width, a_height, a_buf,
+ (EphyrHostBox *) RegionRects(a_clipping_region),
+ RegionNumRects(a_clipping_region))) {
+ EPHYR_LOG_ERROR("EphyrHostXVPutImage() failed\n");
+ goto out;
+ }
+
+ /*
+ * Now save the image so that we can resend it to host it
+ * later, in ReputImage.
+ */
+ if (!ephyrXVPrivGetImageBufSize(port_priv->port_number,
+ a_id, a_width, a_height, &image_size)) {
+ EPHYR_LOG_ERROR("failed to get image size\n");
+ /*this is a minor error so we won't get bail out abruptly */
+ is_ok = FALSE;
+ }
+ else {
+ is_ok = TRUE;
+ }
+ if (is_ok) {
+ if (!ephyrXVPrivSaveImageToPortPriv(port_priv, a_buf, image_size)) {
+ is_ok = FALSE;
+ }
+ else {
+ port_priv->image_id = a_id;
+ port_priv->drw_x = a_drw_x;
+ port_priv->drw_y = a_drw_y;
+ port_priv->drw_w = a_drw_w;
+ port_priv->drw_h = a_drw_h;
+ port_priv->src_x = a_src_x;
+ port_priv->src_y = a_src_y;
+ port_priv->src_w = a_src_w;
+ port_priv->src_h = a_src_h;
+ port_priv->image_width = a_width;
+ port_priv->image_height = a_height;
+ }
+ }
+ if (!is_ok) {
+ if (port_priv->image_buf) {
+ free(port_priv->image_buf);
+ port_priv->image_buf = NULL;
+ port_priv->image_buf_size = 0;
+ }
+ }
+
+ result = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return result;
+}
+
+static int
+ephyrReputImage(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_drw_x,
+ short a_drw_y, RegionPtr a_clipping_region, pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+ int result = BadImplementation;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_info->pScreen, FALSE);
+ EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ if (!port_priv->image_buf_size || !port_priv->image_buf) {
+ EPHYR_LOG_ERROR("has null image buf in cache\n");
+ goto out;
+ }
+ if (!ephyrHostXVPutImage(a_info->pScreen->myNum,
+ port_priv->port_number,
+ port_priv->image_id,
+ a_drw_x, a_drw_y,
+ port_priv->drw_w, port_priv->drw_h,
+ port_priv->src_x, port_priv->src_y,
+ port_priv->src_w, port_priv->src_h,
+ port_priv->image_width, port_priv->image_height,
+ port_priv->image_buf,
+ (EphyrHostBox *) RegionRects(a_clipping_region),
+ RegionNumRects(a_clipping_region))) {
+ EPHYR_LOG_ERROR("ephyrHostXVPutImage() failed\n");
+ goto out;
+ }
+
+ result = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return result;
+}
+
+static int
+ephyrPutVideo(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region, pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+ BoxRec clipped_area, dst_box;
+ int result = BadImplementation;
+ int drw_x = 0, drw_y = 0, drw_w = 0, drw_h = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_info->pScreen, BadValue);
+ EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ dst_box.x1 = a_drw_x;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip(&dst_box,
+ RegionExtents(a_clipping_region), &clipped_area)) {
+ EPHYR_LOG_ERROR("failed to simple clip\n");
+ goto out;
+ }
+
+ drw_x = clipped_area.x1;
+ drw_y = clipped_area.y1;
+ drw_w = clipped_area.x2 - clipped_area.x1;
+ drw_h = clipped_area.y2 - clipped_area.y1;
+
+ if (!ephyrHostXVPutVideo(a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR("ephyrHostXVPutVideo() failed\n");
+ goto out;
+ }
+ result = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return result;
+}
+
+static int
+ephyrGetVideo(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region, pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+ BoxRec clipped_area, dst_box;
+ int result = BadImplementation;
+ int drw_x = 0, drw_y = 0, drw_w = 0, drw_h = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_info && a_info->pScreen, BadValue);
+ EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ dst_box.x1 = a_drw_x;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip(&dst_box,
+ RegionExtents(a_clipping_region), &clipped_area)) {
+ EPHYR_LOG_ERROR("failed to simple clip\n");
+ goto out;
+ }
+
+ drw_x = clipped_area.x1;
+ drw_y = clipped_area.y1;
+ drw_w = clipped_area.x2 - clipped_area.x1;
+ drw_h = clipped_area.y2 - clipped_area.y1;
+
+ if (!ephyrHostXVGetVideo(a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR("ephyrHostXVGetVideo() failed\n");
+ goto out;
+ }
+ result = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return result;
+}
+
+static int
+ephyrPutStill(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region, pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+ BoxRec clipped_area, dst_box;
+ int result = BadImplementation;
+ int drw_x = 0, drw_y = 0, drw_w = 0, drw_h = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_info && a_info->pScreen, BadValue);
+ EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ dst_box.x1 = a_drw_x;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip(&dst_box,
+ RegionExtents(a_clipping_region), &clipped_area)) {
+ EPHYR_LOG_ERROR("failed to simple clip\n");
+ goto out;
+ }
+
+ drw_x = clipped_area.x1;
+ drw_y = clipped_area.y1;
+ drw_w = clipped_area.x2 - clipped_area.x1;
+ drw_h = clipped_area.y2 - clipped_area.y1;
+
+ if (!ephyrHostXVPutStill(a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR("ephyrHostXVPutStill() failed\n");
+ goto out;
+ }
+ result = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return result;
+}
+
+static int
+ephyrGetStill(KdScreenInfo * a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region, pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv;
+ BoxRec clipped_area, dst_box;
+ int result = BadImplementation;
+ int drw_x = 0, drw_y = 0, drw_w = 0, drw_h = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_info && a_info->pScreen, BadValue);
+ EPHYR_RETURN_VAL_IF_FAIL(a_drawable && port_priv, BadValue);
+
+ EPHYR_LOG("enter\n");
+
+ dst_box.x1 = a_drw_x;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip(&dst_box,
+ RegionExtents(a_clipping_region), &clipped_area)) {
+ EPHYR_LOG_ERROR("failed to simple clip\n");
+ goto out;
+ }
+
+ drw_x = clipped_area.x1;
+ drw_y = clipped_area.y1;
+ drw_w = clipped_area.x2 - clipped_area.x1;
+ drw_h = clipped_area.y2 - clipped_area.y1;
+
+ if (!ephyrHostXVGetStill(a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR("ephyrHostXVGetStill() failed\n");
+ goto out;
+ }
+ result = Success;
+
+ out:
+ EPHYR_LOG("leave\n");
+ return result;
+}
+
+static int
+ephyrQueryImageAttributes(KdScreenInfo * a_info,
+ int a_id,
+ unsigned short *a_w,
+ unsigned short *a_h, int *a_pitches, int *a_offsets)
+{
+ int image_size = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_w && a_h, FALSE);
+
+ EPHYR_LOG("enter: dim (%dx%d), pitches: %p, offsets: %p\n",
+ *a_w, *a_h, a_pitches, a_offsets);
+
+ if (!ephyrHostXVQueryImageAttributes(s_base_port_id,
+ a_id,
+ a_w, a_h,
+ &image_size, a_pitches, a_offsets)) {
+ EPHYR_LOG_ERROR("EphyrHostXVQueryImageAttributes() failed\n");
+ goto out;
+ }
+ EPHYR_LOG("image size: %d, dim (%dx%d)\n", image_size, *a_w, *a_h);
+
+ out:
+ EPHYR_LOG("leave\n");
+ return image_size;
+}
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c
index ebe4e52ed..6988f1625 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.c
+++ b/xorg-server/hw/kdrive/ephyr/hostx.c
@@ -38,13 +38,12 @@
#undef _XSERVER64
#endif
-
#include "hostx.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
-#include <string.h> /* for memset */
+#include <string.h> /* for memset */
#include <errno.h>
#include <time.h>
@@ -60,13 +59,12 @@
#include <X11/extensions/shape.h>
#ifdef XF86DRI
#include <GL/glx.h>
-#endif /* XF86DRI */
+#endif /* XF86DRI */
#include "ephyrlog.h"
#ifdef XF86DRI
-extern Bool XF86DRIQueryExtension (Display *dpy,
- int *event_basep,
- int *error_basep);
+extern Bool XF86DRIQueryExtension(Display * dpy,
+ int *event_basep, int *error_basep);
#endif
/*
@@ -75,261 +73,248 @@ extern Bool XF86DRIQueryExtension (Display *dpy,
* to get clobbered.
*/
-struct EphyrHostScreen
-{
- Window win;
- Window win_pre_existing; /* Set via -parent option like xnest */
- Window peer_win; /* Used for GL; should be at most one */
- XImage *ximg;
- int win_width, win_height;
- int server_depth;
- unsigned char *fb_data; /* only used when host bpp != server bpp */
- XShmSegmentInfo shminfo;
-
- void *info; /* Pointer to the screen this is associated with */
- int mynum; /* Screen number */
+struct EphyrHostScreen {
+ Window win;
+ Window win_pre_existing; /* Set via -parent option like xnest */
+ Window peer_win; /* Used for GL; should be at most one */
+ XImage *ximg;
+ int win_width, win_height;
+ int server_depth;
+ unsigned char *fb_data; /* only used when host bpp != server bpp */
+ XShmSegmentInfo shminfo;
+
+ void *info; /* Pointer to the screen this is associated with */
+ int mynum; /* Screen number */
};
-struct EphyrHostXVars
-{
- char *server_dpy_name;
- Display *dpy;
- int screen;
- Visual *visual;
- Window winroot;
- GC gc;
- int depth;
- Bool use_host_cursor;
- Bool use_fullscreen;
- Bool have_shm;
-
- int n_screens;
- struct EphyrHostScreen *screens;
-
- long damage_debug_msec;
-
- unsigned long cmap[256];
+struct EphyrHostXVars {
+ char *server_dpy_name;
+ Display *dpy;
+ int screen;
+ Visual *visual;
+ Window winroot;
+ GC gc;
+ int depth;
+ Bool use_host_cursor;
+ Bool use_fullscreen;
+ Bool have_shm;
+
+ int n_screens;
+ struct EphyrHostScreen *screens;
+
+ long damage_debug_msec;
+
+ unsigned long cmap[256];
};
/* memset ( missing> ) instead of below */
/*static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};*/
static EphyrHostXVars HostX;
-static int HostXWantDamageDebug = 0;
+static int HostXWantDamageDebug = 0;
-extern EphyrKeySyms ephyrKeySyms;
+extern EphyrKeySyms ephyrKeySyms;
-extern int monitorResolution;
+extern int monitorResolution;
-char *ephyrResName = NULL;
-int ephyrResNameFromCmd = 0;
-char *ephyrTitle = NULL;
+char *ephyrResName = NULL;
+int ephyrResNameFromCmd = 0;
+char *ephyrTitle = NULL;
static void
-hostx_set_fullscreen_hint(void);
+ hostx_set_fullscreen_hint(void);
/* X Error traps */
static int trapped_error_code = 0;
-static int (*old_error_handler) (Display *d, XErrorEvent *e);
+static int (*old_error_handler) (Display * d, XErrorEvent * e);
#define host_depth_matches_server(_vars) (HostX.depth == (_vars)->server_depth)
static struct EphyrHostScreen *
-host_screen_from_screen_info (EphyrScreenInfo *screen)
+host_screen_from_screen_info(EphyrScreenInfo * screen)
{
- int i;
+ int i;
- for (i = 0 ; i < HostX.n_screens ; i++)
- {
- if ( HostX.screens[i].info == screen)
- {
- return &HostX.screens[i];
+ for (i = 0; i < HostX.n_screens; i++) {
+ if (HostX.screens[i].info == screen) {
+ return &HostX.screens[i];
}
}
- return NULL;
+ return NULL;
}
static int
-error_handler(Display *display,
- XErrorEvent *error)
+error_handler(Display * display, XErrorEvent * error)
{
- trapped_error_code = error->error_code;
- return 0;
+ trapped_error_code = error->error_code;
+ return 0;
}
static void
hostx_errors_trap(void)
{
- trapped_error_code = 0;
- old_error_handler = XSetErrorHandler(error_handler);
+ trapped_error_code = 0;
+ old_error_handler = XSetErrorHandler(error_handler);
}
static int
hostx_errors_untrap(void)
{
- XSetErrorHandler(old_error_handler);
- return trapped_error_code;
+ XSetErrorHandler(old_error_handler);
+ return trapped_error_code;
}
int
-hostx_want_screen_size (EphyrScreenInfo screen, int *width, int *height )
+hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
-
- if (host_screen &&
- (host_screen->win_pre_existing != None ||
- HostX.use_fullscreen == True))
- {
- *width = host_screen->win_width;
- *height = host_screen->win_height;
- return 1;
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
+
+ if (host_screen &&
+ (host_screen->win_pre_existing != None ||
+ HostX.use_fullscreen == True)) {
+ *width = host_screen->win_width;
+ *height = host_screen->win_height;
+ return 1;
}
- return 0;
+ return 0;
}
void
-hostx_add_screen (EphyrScreenInfo screen,
- unsigned long win_id,
- int screen_num)
+hostx_add_screen(EphyrScreenInfo screen, unsigned long win_id, int screen_num)
{
- int index = HostX.n_screens;
+ int index = HostX.n_screens;
- HostX.n_screens += 1;
- HostX.screens = realloc (HostX.screens,
- HostX.n_screens * sizeof(struct EphyrHostScreen));
- memset (&HostX.screens[index], 0, sizeof (struct EphyrHostScreen));
+ HostX.n_screens += 1;
+ HostX.screens = realloc(HostX.screens,
+ HostX.n_screens * sizeof(struct EphyrHostScreen));
+ memset(&HostX.screens[index], 0, sizeof(struct EphyrHostScreen));
- HostX.screens[index].info = screen;
- HostX.screens[index].win_pre_existing = win_id;
+ HostX.screens[index].info = screen;
+ HostX.screens[index].win_pre_existing = win_id;
}
-
void
-hostx_set_display_name (char *name)
+hostx_set_display_name(char *name)
{
- HostX.server_dpy_name = strdup (name);
+ HostX.server_dpy_name = strdup(name);
}
void
hostx_set_screen_number(EphyrScreenInfo screen, int number)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
- if (host_screen) {
- host_screen->mynum = number;
- hostx_set_win_title (host_screen->info, "") ;
- }}
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
+
+ if (host_screen) {
+ host_screen->mynum = number;
+ hostx_set_win_title(host_screen->info, "");
+ }
+}
void
-hostx_set_win_title (EphyrScreenInfo screen, char *extra_text)
+hostx_set_win_title(EphyrScreenInfo screen, char *extra_text)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
if (!host_screen)
- return;
+ return;
if (ephyrTitle) {
- XStoreName(HostX.dpy, host_screen->win, ephyrTitle);
- } else {
+ XStoreName(HostX.dpy, host_screen->win, ephyrTitle);
+ }
+ else {
#define BUF_LEN 256
- char buf[BUF_LEN+1];
+ char buf[BUF_LEN + 1];
- memset (buf, 0, BUF_LEN+1) ;
- snprintf (buf, BUF_LEN, "Xephyr on %s.%d %s",
- HostX.server_dpy_name,
- host_screen->mynum,
- (extra_text != NULL) ? extra_text : "");
+ memset(buf, 0, BUF_LEN + 1);
+ snprintf(buf, BUF_LEN, "Xephyr on %s.%d %s",
+ HostX.server_dpy_name,
+ host_screen->mynum, (extra_text != NULL) ? extra_text : "");
- XStoreName (HostX.dpy, host_screen->win, buf);
+ XStoreName(HostX.dpy, host_screen->win, buf);
}
}
int
-hostx_want_host_cursor (void)
+hostx_want_host_cursor(void)
{
- return HostX.use_host_cursor;
+ return HostX.use_host_cursor;
}
void
-hostx_use_host_cursor (void)
+hostx_use_host_cursor(void)
{
- HostX.use_host_cursor = True;
+ HostX.use_host_cursor = True;
}
int
-hostx_want_preexisting_window (EphyrScreenInfo screen)
+hostx_want_preexisting_window(EphyrScreenInfo screen)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
- if (host_screen && host_screen->win_pre_existing)
- {
- return 1;
+ if (host_screen && host_screen->win_pre_existing) {
+ return 1;
}
- else
- {
- return 0;
+ else {
+ return 0;
}
}
void
-hostx_use_fullscreen (void)
+hostx_use_fullscreen(void)
{
- HostX.use_fullscreen = True;
+ HostX.use_fullscreen = True;
}
int
-hostx_want_fullscreen (void)
+hostx_want_fullscreen(void)
{
- return HostX.use_fullscreen;
+ return HostX.use_fullscreen;
}
static void
-hostx_set_fullscreen_hint (void)
+hostx_set_fullscreen_hint(void)
{
- Atom atom_WINDOW_STATE, atom_WINDOW_STATE_FULLSCREEN;
- int index;
-
- atom_WINDOW_STATE
- = XInternAtom(HostX.dpy, "_NET_WM_STATE", False);
- atom_WINDOW_STATE_FULLSCREEN
- = XInternAtom(HostX.dpy, "_NET_WM_STATE_FULLSCREEN",False);
-
- for (index = 0 ; index < HostX.n_screens ; index++)
- {
- XChangeProperty (HostX.dpy, HostX.screens[index].win,
- atom_WINDOW_STATE, XA_ATOM, 32,
- PropModeReplace,
- (unsigned char *)&atom_WINDOW_STATE_FULLSCREEN, 1);
+ Atom atom_WINDOW_STATE, atom_WINDOW_STATE_FULLSCREEN;
+ int index;
+
+ atom_WINDOW_STATE = XInternAtom(HostX.dpy, "_NET_WM_STATE", False);
+ atom_WINDOW_STATE_FULLSCREEN
+ = XInternAtom(HostX.dpy, "_NET_WM_STATE_FULLSCREEN", False);
+
+ for (index = 0; index < HostX.n_screens; index++) {
+ XChangeProperty(HostX.dpy, HostX.screens[index].win,
+ atom_WINDOW_STATE, XA_ATOM, 32,
+ PropModeReplace,
+ (unsigned char *) &atom_WINDOW_STATE_FULLSCREEN, 1);
}
}
-
static void
-hostx_toggle_damage_debug (void)
+hostx_toggle_damage_debug(void)
{
- HostXWantDamageDebug ^= 1;
+ HostXWantDamageDebug ^= 1;
}
void
-hostx_handle_signal (int signum)
+hostx_handle_signal(int signum)
{
- hostx_toggle_damage_debug();
- EPHYR_DBG ("Signal caught. Damage Debug:%i\n",
- HostXWantDamageDebug);
+ hostx_toggle_damage_debug();
+ EPHYR_DBG("Signal caught. Damage Debug:%i\n", HostXWantDamageDebug);
}
void
-hostx_use_resname (char *name, int fromcmd)
+hostx_use_resname(char *name, int fromcmd)
{
- ephyrResName = name;
- ephyrResNameFromCmd = fromcmd;
+ ephyrResName = name;
+ ephyrResNameFromCmd = fromcmd;
}
void
-hostx_set_title (char *title)
+hostx_set_title(char *title)
{
- ephyrTitle = title;
+ ephyrTitle = title;
}
#ifdef __SUNPRO_C
@@ -338,7 +323,8 @@ hostx_set_title (char *title)
#endif
static int _X_NORETURN
-x_io_error_handler (Display *dpy) {
+x_io_error_handler(Display * dpy)
+{
ErrorF("Lost connection to X server: %s\n", strerror(errno));
CloseWellKnownConnections();
OsCleanup(1);
@@ -346,297 +332,271 @@ x_io_error_handler (Display *dpy) {
}
int
-hostx_init (void)
+hostx_init(void)
{
- XSetWindowAttributes attr;
- Cursor empty_cursor;
- Pixmap cursor_pxm;
- XColor col;
- int index;
- char *tmpstr;
- XClassHint *class_hint;
-
- attr.event_mask =
- ButtonPressMask
- |ButtonReleaseMask
- |PointerMotionMask
- |KeyPressMask
- |KeyReleaseMask
- |ExposureMask;
-
- EPHYR_DBG("mark");
-
- if ((HostX.dpy = XOpenDisplay(getenv("DISPLAY"))) == NULL)
- {
- fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n");
- exit(1);
+ XSetWindowAttributes attr;
+ Cursor empty_cursor;
+ Pixmap cursor_pxm;
+ XColor col;
+ int index;
+ char *tmpstr;
+ XClassHint *class_hint;
+
+ attr.event_mask =
+ ButtonPressMask
+ | ButtonReleaseMask
+ | PointerMotionMask | KeyPressMask | KeyReleaseMask | ExposureMask;
+
+ EPHYR_DBG("mark");
+
+ if ((HostX.dpy = XOpenDisplay(getenv("DISPLAY"))) == NULL) {
+ fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n");
+ exit(1);
}
- XSetIOErrorHandler(x_io_error_handler);
+ XSetIOErrorHandler(x_io_error_handler);
- HostX.screen = DefaultScreen(HostX.dpy);
- HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
- HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL);
- HostX.depth = DefaultDepth(HostX.dpy, HostX.screen);
- HostX.visual = DefaultVisual(HostX.dpy, HostX.screen);
+ HostX.screen = DefaultScreen(HostX.dpy);
+ HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
+ HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL);
+ HostX.depth = DefaultDepth(HostX.dpy, HostX.screen);
+ HostX.visual = DefaultVisual(HostX.dpy, HostX.screen);
- class_hint = XAllocClassHint();
+ class_hint = XAllocClassHint();
- for (index = 0 ; index < HostX.n_screens ; index++)
- {
- struct EphyrHostScreen *host_screen = &HostX.screens[index];
+ for (index = 0; index < HostX.n_screens; index++) {
+ struct EphyrHostScreen *host_screen = &HostX.screens[index];
- host_screen->server_depth = HostX.depth;
- if (host_screen->win_pre_existing != None)
- {
- Status result;
- XWindowAttributes prewin_attr;
-
- /* Get screen size from existing window */
-
- hostx_errors_trap();
-
- result = XGetWindowAttributes (HostX.dpy,
- host_screen->win_pre_existing,
- &prewin_attr);
-
-
- if (hostx_errors_untrap() || !result)
- {
- fprintf (stderr, "\nXephyr -parent window' does not exist!\n");
- exit (1);
- }
-
- host_screen->win_width = prewin_attr.width;
- host_screen->win_height = prewin_attr.height;
-
- host_screen->win = XCreateWindow (HostX.dpy,
- host_screen->win_pre_existing,
- 0,0,
- host_screen->win_width,
- host_screen->win_height,
- 0,
- CopyFromParent,
- CopyFromParent,
- CopyFromParent,
- CWEventMask,
- &attr);
- }
- else
- {
- host_screen->win = XCreateWindow (HostX.dpy,
- HostX.winroot,
- 0,0,100,100, /* will resize */
- 0,
- CopyFromParent,
- CopyFromParent,
- CopyFromParent,
- CWEventMask,
- &attr);
-
- hostx_set_win_title (host_screen->info,
- "(ctrl+shift grabs mouse and keyboard)");
-
- if (HostX.use_fullscreen)
- {
- host_screen->win_width = DisplayWidth(HostX.dpy, HostX.screen);
- host_screen->win_height = DisplayHeight(HostX.dpy, HostX.screen);
+ host_screen->server_depth = HostX.depth;
+ if (host_screen->win_pre_existing != None) {
+ Status result;
+ XWindowAttributes prewin_attr;
+
+ /* Get screen size from existing window */
+
+ hostx_errors_trap();
- hostx_set_fullscreen_hint();
+ result = XGetWindowAttributes(HostX.dpy,
+ host_screen->win_pre_existing,
+ &prewin_attr);
+
+ if (hostx_errors_untrap() || !result) {
+ fprintf(stderr, "\nXephyr -parent window' does not exist!\n");
+ exit(1);
}
- if (class_hint)
- {
- tmpstr = getenv("RESOURCE_NAME");
- if (tmpstr && (!ephyrResNameFromCmd))
- ephyrResName = tmpstr;
- class_hint->res_name = ephyrResName;
- class_hint->res_class = "Xephyr";
- XSetClassHint(hostx_get_display(), host_screen->win, class_hint);
+ host_screen->win_width = prewin_attr.width;
+ host_screen->win_height = prewin_attr.height;
+
+ host_screen->win = XCreateWindow(HostX.dpy,
+ host_screen->win_pre_existing,
+ 0, 0,
+ host_screen->win_width,
+ host_screen->win_height,
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWEventMask, &attr);
+ }
+ else {
+ host_screen->win = XCreateWindow(HostX.dpy, HostX.winroot, 0, 0, 100, 100, /* will resize */
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWEventMask, &attr);
+
+ hostx_set_win_title(host_screen->info,
+ "(ctrl+shift grabs mouse and keyboard)");
+
+ if (HostX.use_fullscreen) {
+ host_screen->win_width = DisplayWidth(HostX.dpy, HostX.screen);
+ host_screen->win_height =
+ DisplayHeight(HostX.dpy, HostX.screen);
+
+ hostx_set_fullscreen_hint();
+ }
+
+ if (class_hint) {
+ tmpstr = getenv("RESOURCE_NAME");
+ if (tmpstr && (!ephyrResNameFromCmd))
+ ephyrResName = tmpstr;
+ class_hint->res_name = ephyrResName;
+ class_hint->res_class = "Xephyr";
+ XSetClassHint(hostx_get_display(), host_screen->win,
+ class_hint);
}
}
}
- if (class_hint)
- XFree(class_hint);
-
- XParseColor (HostX.dpy, DefaultColormap (HostX.dpy,HostX.screen),
- "red", &col);
- XAllocColor (HostX.dpy, DefaultColormap (HostX.dpy, HostX.screen),
- &col);
- XSetForeground (HostX.dpy, HostX.gc, col.pixel);
-
- if (!hostx_want_host_cursor ())
- {
- /* Ditch the cursor, we provide our 'own' */
- cursor_pxm = XCreatePixmap (HostX.dpy, HostX.winroot, 1, 1, 1);
- memset (&col, 0, sizeof (col));
- empty_cursor = XCreatePixmapCursor (HostX.dpy,
- cursor_pxm, cursor_pxm,
- &col, &col, 1, 1);
- for ( index = 0 ; index < HostX.n_screens ; index++ )
- {
- XDefineCursor (HostX.dpy,
- HostX.screens[index].win,
- empty_cursor);
+ if (class_hint)
+ XFree(class_hint);
+
+ XParseColor(HostX.dpy, DefaultColormap(HostX.dpy, HostX.screen),
+ "red", &col);
+ XAllocColor(HostX.dpy, DefaultColormap(HostX.dpy, HostX.screen), &col);
+ XSetForeground(HostX.dpy, HostX.gc, col.pixel);
+
+ if (!hostx_want_host_cursor()) {
+ /* Ditch the cursor, we provide our 'own' */
+ cursor_pxm = XCreatePixmap(HostX.dpy, HostX.winroot, 1, 1, 1);
+ memset(&col, 0, sizeof(col));
+ empty_cursor = XCreatePixmapCursor(HostX.dpy,
+ cursor_pxm, cursor_pxm,
+ &col, &col, 1, 1);
+ for (index = 0; index < HostX.n_screens; index++) {
+ XDefineCursor(HostX.dpy, HostX.screens[index].win, empty_cursor);
}
- XFreePixmap (HostX.dpy, cursor_pxm);
+ XFreePixmap(HostX.dpy, cursor_pxm);
}
- for (index = 0 ; index < HostX.n_screens ; index++)
- {
- HostX.screens[index].ximg = NULL;
+ for (index = 0; index < HostX.n_screens; index++) {
+ HostX.screens[index].ximg = NULL;
}
- /* Try to get share memory ximages for a little bit more speed */
+ /* Try to get share memory ximages for a little bit more speed */
- if (!XShmQueryExtension(HostX.dpy) || getenv("XEPHYR_NO_SHM"))
- {
- fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
- HostX.have_shm = False;
+ if (!XShmQueryExtension(HostX.dpy) || getenv("XEPHYR_NO_SHM")) {
+ fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
+ HostX.have_shm = False;
}
- else
- {
- /* Really really check we have shm - better way ?*/
- XShmSegmentInfo shminfo;
+ else {
+ /* Really really check we have shm - better way ? */
+ XShmSegmentInfo shminfo;
HostX.have_shm = True;
- shminfo.shmid=shmget(IPC_PRIVATE, 1, IPC_CREAT|0777);
- shminfo.shmaddr=shmat(shminfo.shmid,0,0);
- shminfo.readOnly=True;
+ shminfo.shmid = shmget(IPC_PRIVATE, 1, IPC_CREAT | 0777);
+ shminfo.shmaddr = shmat(shminfo.shmid, 0, 0);
+ shminfo.readOnly = True;
hostx_errors_trap();
XShmAttach(HostX.dpy, &shminfo);
XSync(HostX.dpy, False);
- if (hostx_errors_untrap())
- {
+ if (hostx_errors_untrap()) {
fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
HostX.have_shm = False;
- }
+ }
shmdt(shminfo.shmaddr);
shmctl(shminfo.shmid, IPC_RMID, 0);
-}
+ }
- XFlush(HostX.dpy);
+ XFlush(HostX.dpy);
- /* Setup the pause time between paints when debugging updates */
+ /* Setup the pause time between paints when debugging updates */
- HostX.damage_debug_msec = 20000; /* 1/50 th of a second */
+ HostX.damage_debug_msec = 20000; /* 1/50 th of a second */
- if (getenv ("XEPHYR_PAUSE"))
- {
- HostX.damage_debug_msec = strtol (getenv ("XEPHYR_PAUSE"), NULL, 0);
- EPHYR_DBG ("pause is %li\n", HostX.damage_debug_msec);
+ if (getenv("XEPHYR_PAUSE")) {
+ HostX.damage_debug_msec = strtol(getenv("XEPHYR_PAUSE"), NULL, 0);
+ EPHYR_DBG("pause is %li\n", HostX.damage_debug_msec);
}
- return 1;
+ return 1;
}
int
-hostx_get_depth (void)
+hostx_get_depth(void)
{
- return HostX.depth;
+ return HostX.depth;
}
int
-hostx_get_server_depth (EphyrScreenInfo screen)
+hostx_get_server_depth(EphyrScreenInfo screen)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
- return host_screen ? host_screen->server_depth : 0;
+ return host_screen ? host_screen->server_depth : 0;
}
void
-hostx_set_server_depth (EphyrScreenInfo screen, int depth)
+hostx_set_server_depth(EphyrScreenInfo screen, int depth)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
- if (host_screen)
- host_screen->server_depth = depth;
+ if (host_screen)
+ host_screen->server_depth = depth;
}
int
-hostx_get_bpp (EphyrScreenInfo screen)
+hostx_get_bpp(EphyrScreenInfo screen)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
- if (!host_screen)
- return 0;
+ if (!host_screen)
+ return 0;
- if (host_depth_matches_server (host_screen))
- return HostX.visual->bits_per_rgb;
- else
- return host_screen->server_depth; /*XXX correct ?*/
+ if (host_depth_matches_server(host_screen))
+ return HostX.visual->bits_per_rgb;
+ else
+ return host_screen->server_depth; /*XXX correct ? */
}
void
-hostx_get_visual_masks (EphyrScreenInfo screen,
- CARD32 *rmsk,
- CARD32 *gmsk,
- CARD32 *bmsk)
+hostx_get_visual_masks(EphyrScreenInfo screen,
+ CARD32 *rmsk, CARD32 *gmsk, CARD32 *bmsk)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
- if (!host_screen)
- return;
+ if (!host_screen)
+ return;
- if (host_depth_matches_server(host_screen))
- {
- *rmsk = HostX.visual->red_mask;
- *gmsk = HostX.visual->green_mask;
- *bmsk = HostX.visual->blue_mask;
+ if (host_depth_matches_server(host_screen)) {
+ *rmsk = HostX.visual->red_mask;
+ *gmsk = HostX.visual->green_mask;
+ *bmsk = HostX.visual->blue_mask;
}
- else if (host_screen->server_depth == 16)
- {
- /* Assume 16bpp 565 */
- *rmsk = 0xf800;
- *gmsk = 0x07e0;
- *bmsk = 0x001f;
+ else if (host_screen->server_depth == 16) {
+ /* Assume 16bpp 565 */
+ *rmsk = 0xf800;
+ *gmsk = 0x07e0;
+ *bmsk = 0x001f;
}
- else
- {
- *rmsk = 0x0;
- *gmsk = 0x0;
- *bmsk = 0x0;
+ else {
+ *rmsk = 0x0;
+ *gmsk = 0x0;
+ *bmsk = 0x0;
}
}
-static int
+static int
hostx_calculate_color_shift(unsigned long mask)
{
int shift = 1;
+
/* count # of bits in mask */
- while ((mask = (mask >> 1))) shift++;
+ while ((mask = (mask >> 1)))
+ shift++;
/* cmap entry is an unsigned char so adjust it by size of that */
shift = shift - sizeof(unsigned char) * 8;
- if (shift < 0) shift = 0;
+ if (shift < 0)
+ shift = 0;
return shift;
}
void
hostx_set_cmap_entry(unsigned char idx,
- unsigned char r,
- unsigned char g,
- unsigned char b)
+ unsigned char r, unsigned char g, unsigned char b)
{
/* need to calculate the shifts for RGB because server could be BGR. */
/* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/
static int rshift, bshift, gshift = 0;
static int first_time = 1;
+
if (first_time) {
- first_time = 0;
- rshift = hostx_calculate_color_shift(HostX.visual->red_mask);
- gshift = hostx_calculate_color_shift(HostX.visual->green_mask);
- bshift = hostx_calculate_color_shift(HostX.visual->blue_mask);
+ first_time = 0;
+ rshift = hostx_calculate_color_shift(HostX.visual->red_mask);
+ gshift = hostx_calculate_color_shift(HostX.visual->green_mask);
+ bshift = hostx_calculate_color_shift(HostX.visual->blue_mask);
}
HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) |
- ((g << gshift) & HostX.visual->green_mask) |
- ((b << bshift) & HostX.visual->blue_mask);
+ ((g << gshift) & HostX.visual->green_mask) |
+ ((b << bshift) & HostX.visual->blue_mask);
}
/**
@@ -651,813 +611,765 @@ hostx_set_cmap_entry(unsigned char idx,
* buffer_height can be used to create a larger offscreen buffer, which is used
* by fakexa for storing offscreen pixmap data.
*/
-void*
-hostx_screen_init (EphyrScreenInfo screen,
- int width, int height,
- int buffer_height)
+void *
+hostx_screen_init(EphyrScreenInfo screen,
+ int width, int height, int buffer_height)
{
- int bitmap_pad;
- Bool shm_success = False;
- XSizeHints *size_hints;
-
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
- if (!host_screen)
- {
- fprintf (stderr, "%s: Error in accessing hostx data\n", __func__ );
- exit(1);
+ int bitmap_pad;
+ Bool shm_success = False;
+ XSizeHints *size_hints;
+
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
+
+ if (!host_screen) {
+ fprintf(stderr, "%s: Error in accessing hostx data\n", __func__);
+ exit(1);
}
- EPHYR_DBG ("host_screen=%p wxh=%dx%d, buffer_height=%d",
- host_screen, width, height, buffer_height);
-
- if (host_screen->ximg != NULL)
- {
- /* Free up the image data if previously used
- * i.ie called by server reset
- */
-
- if (HostX.have_shm)
- {
- XShmDetach(HostX.dpy, &host_screen->shminfo);
- XDestroyImage (host_screen->ximg);
- shmdt(host_screen->shminfo.shmaddr);
- shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
- }
- else
- {
- free(host_screen->ximg->data);
- host_screen->ximg->data = NULL;
-
- XDestroyImage(host_screen->ximg);
- }
+ EPHYR_DBG("host_screen=%p wxh=%dx%d, buffer_height=%d",
+ host_screen, width, height, buffer_height);
+
+ if (host_screen->ximg != NULL) {
+ /* Free up the image data if previously used
+ * i.ie called by server reset
+ */
+
+ if (HostX.have_shm) {
+ XShmDetach(HostX.dpy, &host_screen->shminfo);
+ XDestroyImage(host_screen->ximg);
+ shmdt(host_screen->shminfo.shmaddr);
+ shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+ }
+ else {
+ free(host_screen->ximg->data);
+ host_screen->ximg->data = NULL;
+
+ XDestroyImage(host_screen->ximg);
+ }
}
- if (HostX.have_shm)
- {
- host_screen->ximg = XShmCreateImage (HostX.dpy, HostX.visual, HostX.depth,
- ZPixmap, NULL, &host_screen->shminfo,
- width, buffer_height );
-
- host_screen->shminfo.shmid =
- shmget(IPC_PRIVATE,
- host_screen->ximg->bytes_per_line * buffer_height,
- IPC_CREAT|0777);
- host_screen->ximg->data = shmat(host_screen->shminfo.shmid, 0, 0);
- host_screen->shminfo.shmaddr = host_screen->ximg->data;
-
- if (host_screen->ximg->data == (char *)-1)
- {
- EPHYR_DBG("Can't attach SHM Segment, falling back to plain XImages");
- HostX.have_shm = False;
- XDestroyImage(host_screen->ximg);
- shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
- }
- else
- {
- EPHYR_DBG("SHM segment attached %p", host_screen->shminfo.shmaddr);
- host_screen->shminfo.readOnly = False;
- XShmAttach(HostX.dpy, &host_screen->shminfo);
- shm_success = True;
- }
+ if (HostX.have_shm) {
+ host_screen->ximg =
+ XShmCreateImage(HostX.dpy, HostX.visual, HostX.depth, ZPixmap, NULL,
+ &host_screen->shminfo, width, buffer_height);
+
+ host_screen->shminfo.shmid =
+ shmget(IPC_PRIVATE,
+ host_screen->ximg->bytes_per_line * buffer_height,
+ IPC_CREAT | 0777);
+ host_screen->ximg->data = shmat(host_screen->shminfo.shmid, 0, 0);
+ host_screen->shminfo.shmaddr = host_screen->ximg->data;
+
+ if (host_screen->ximg->data == (char *) -1) {
+ EPHYR_DBG
+ ("Can't attach SHM Segment, falling back to plain XImages");
+ HostX.have_shm = False;
+ XDestroyImage(host_screen->ximg);
+ shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+ }
+ else {
+ EPHYR_DBG("SHM segment attached %p", host_screen->shminfo.shmaddr);
+ host_screen->shminfo.readOnly = False;
+ XShmAttach(HostX.dpy, &host_screen->shminfo);
+ shm_success = True;
+ }
}
- if (!shm_success)
- {
- bitmap_pad = ( HostX.depth > 16 )? 32 : (( HostX.depth > 8 )? 16 : 8 );
-
- EPHYR_DBG("Creating image %dx%d for screen host_screen=%p\n",
- width, buffer_height, host_screen );
- host_screen->ximg = XCreateImage (HostX.dpy,
- HostX.visual,
- HostX.depth,
- ZPixmap, 0, 0,
- width,
- buffer_height,
- bitmap_pad,
- 0);
-
- host_screen->ximg->data =
- malloc (host_screen->ximg->bytes_per_line * buffer_height);
+ if (!shm_success) {
+ bitmap_pad = (HostX.depth > 16) ? 32 : ((HostX.depth > 8) ? 16 : 8);
+
+ EPHYR_DBG("Creating image %dx%d for screen host_screen=%p\n",
+ width, buffer_height, host_screen);
+ host_screen->ximg = XCreateImage(HostX.dpy,
+ HostX.visual,
+ HostX.depth,
+ ZPixmap, 0, 0,
+ width, buffer_height, bitmap_pad, 0);
+
+ host_screen->ximg->data =
+ malloc(host_screen->ximg->bytes_per_line * buffer_height);
}
- XResizeWindow (HostX.dpy, host_screen->win, width, height);
+ XResizeWindow(HostX.dpy, host_screen->win, width, height);
- /* Ask the WM to keep our size static */
- size_hints = XAllocSizeHints();
- size_hints->max_width = size_hints->min_width = width;
- size_hints->max_height = size_hints->min_height = height;
- size_hints->flags = PMinSize|PMaxSize;
- XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
- XFree(size_hints);
+ /* Ask the WM to keep our size static */
+ size_hints = XAllocSizeHints();
+ size_hints->max_width = size_hints->min_width = width;
+ size_hints->max_height = size_hints->min_height = height;
+ size_hints->flags = PMinSize | PMaxSize;
+ XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
+ XFree(size_hints);
- XMapWindow(HostX.dpy, host_screen->win);
+ XMapWindow(HostX.dpy, host_screen->win);
- XSync(HostX.dpy, False);
+ XSync(HostX.dpy, False);
- host_screen->win_width = width;
- host_screen->win_height = height;
+ host_screen->win_width = width;
+ host_screen->win_height = height;
- if (host_depth_matches_server(host_screen))
- {
- EPHYR_DBG("Host matches server");
- return host_screen->ximg->data;
+ if (host_depth_matches_server(host_screen)) {
+ EPHYR_DBG("Host matches server");
+ return host_screen->ximg->data;
}
- else
- {
- EPHYR_DBG("server bpp %i", host_screen->server_depth>>3);
- host_screen->fb_data = malloc(width*buffer_height*(host_screen->server_depth>>3));
- return host_screen->fb_data;
+ else {
+ EPHYR_DBG("server bpp %i", host_screen->server_depth >> 3);
+ host_screen->fb_data =
+ malloc(width * buffer_height * (host_screen->server_depth >> 3));
+ return host_screen->fb_data;
}
}
-static void hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
- int x, int y,
- int width, int height);
+static void hostx_paint_debug_rect(struct EphyrHostScreen *host_screen,
+ int x, int y, int width, int height);
void
-hostx_paint_rect (EphyrScreenInfo screen,
- int sx, int sy,
- int dx, int dy,
- int width, int height)
+hostx_paint_rect(EphyrScreenInfo screen,
+ int sx, int sy, int dx, int dy, int width, int height)
{
- struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info(screen);
- EPHYR_DBG ("painting in screen %d\n", host_screen->mynum) ;
+ EPHYR_DBG("painting in screen %d\n", host_screen->mynum);
- /*
- * Copy the image data updated by the shadow layer
- * on to the window
- */
+ /*
+ * Copy the image data updated by the shadow layer
+ * on to the window
+ */
- if (HostXWantDamageDebug)
- {
- hostx_paint_debug_rect(host_screen, dx, dy, width, height);
+ if (HostXWantDamageDebug) {
+ hostx_paint_debug_rect(host_screen, dx, dy, width, height);
}
- /*
- * If the depth of the ephyr server is less than that of the host,
- * the kdrive fb does not point to the ximage data but to a buffer
- * ( fb_data ), we shift the various bits from this onto the XImage
- * so they match the host.
- *
- * Note, This code is pretty new ( and simple ) so may break on
- * endian issues, 32 bpp host etc.
- * Not sure if 8bpp case is right either.
- * ... and it will be slower than the matching depth case.
- */
-
- if (!host_depth_matches_server(host_screen))
- {
- int x,y,idx, bytes_per_pixel = (host_screen->server_depth>>3);
- unsigned char r,g,b;
- unsigned long host_pixel;
-
- EPHYR_DBG("Unmatched host depth host_screen=%p\n", host_screen);
- for (y=sy; y<sy+height; y++)
- for (x=sx; x<sx+width; x++)
- {
- idx = (host_screen->win_width*y*bytes_per_pixel)+(x*bytes_per_pixel);
-
- switch (host_screen->server_depth)
- {
- case 16:
- {
- unsigned short pixel = *(unsigned short*)(host_screen->fb_data+idx);
-
- r = ((pixel & 0xf800) >> 8);
- g = ((pixel & 0x07e0) >> 3);
- b = ((pixel & 0x001f) << 3);
-
- host_pixel = (r << 16) | (g << 8) | (b);
-
- XPutPixel(host_screen->ximg, x, y, host_pixel);
- break;
- }
- case 8:
- {
- unsigned char pixel = *(unsigned char*)(host_screen->fb_data+idx);
- XPutPixel(host_screen->ximg, x, y, HostX.cmap[pixel]);
- break;
- }
- default:
- break;
- }
- }
+ /*
+ * If the depth of the ephyr server is less than that of the host,
+ * the kdrive fb does not point to the ximage data but to a buffer
+ * ( fb_data ), we shift the various bits from this onto the XImage
+ * so they match the host.
+ *
+ * Note, This code is pretty new ( and simple ) so may break on
+ * endian issues, 32 bpp host etc.
+ * Not sure if 8bpp case is right either.
+ * ... and it will be slower than the matching depth case.
+ */
+
+ if (!host_depth_matches_server(host_screen)) {
+ int x, y, idx, bytes_per_pixel = (host_screen->server_depth >> 3);
+ unsigned char r, g, b;
+ unsigned long host_pixel;
+
+ EPHYR_DBG("Unmatched host depth host_screen=%p\n", host_screen);
+ for (y = sy; y < sy + height; y++)
+ for (x = sx; x < sx + width; x++) {
+ idx =
+ (host_screen->win_width * y * bytes_per_pixel) +
+ (x * bytes_per_pixel);
+
+ switch (host_screen->server_depth) {
+ case 16:
+ {
+ unsigned short pixel =
+ *(unsigned short *) (host_screen->fb_data + idx);
+
+ r = ((pixel & 0xf800) >> 8);
+ g = ((pixel & 0x07e0) >> 3);
+ b = ((pixel & 0x001f) << 3);
+
+ host_pixel = (r << 16) | (g << 8) | (b);
+
+ XPutPixel(host_screen->ximg, x, y, host_pixel);
+ break;
+ }
+ case 8:
+ {
+ unsigned char pixel =
+ *(unsigned char *) (host_screen->fb_data + idx);
+ XPutPixel(host_screen->ximg, x, y, HostX.cmap[pixel]);
+ break;
+ }
+ default:
+ break;
+ }
+ }
}
- if (HostX.have_shm)
- {
- XShmPutImage (HostX.dpy, host_screen->win,
- HostX.gc, host_screen->ximg,
- sx, sy, dx, dy, width, height, False);
+ if (HostX.have_shm) {
+ XShmPutImage(HostX.dpy, host_screen->win,
+ HostX.gc, host_screen->ximg,
+ sx, sy, dx, dy, width, height, False);
}
- else
- {
- XPutImage (HostX.dpy, host_screen->win, HostX.gc, host_screen->ximg,
- sx, sy, dx, dy, width, height);
+ else {
+ XPutImage(HostX.dpy, host_screen->win, HostX.gc, host_screen->ximg,
+ sx, sy, dx, dy, width, height);
}
- XSync (HostX.dpy, False);
+ XSync(HostX.dpy, False);
}
static void
-hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
- int x, int y,
- int width, int height)
+hostx_paint_debug_rect(struct EphyrHostScreen *host_screen,
+ int x, int y, int width, int height)
{
- struct timespec tspec;
+ struct timespec tspec;
- tspec.tv_sec = HostX.damage_debug_msec / (1000000);
- tspec.tv_nsec = (HostX.damage_debug_msec % 1000000) * 1000;
+ tspec.tv_sec = HostX.damage_debug_msec / (1000000);
+ tspec.tv_nsec = (HostX.damage_debug_msec % 1000000) * 1000;
- EPHYR_DBG("msec: %li tv_sec %li, tv_msec %li",
- HostX.damage_debug_msec, tspec.tv_sec, tspec.tv_nsec);
+ EPHYR_DBG("msec: %li tv_sec %li, tv_msec %li",
+ HostX.damage_debug_msec, tspec.tv_sec, tspec.tv_nsec);
- /* fprintf(stderr, "Xephyr updating: %i+%i %ix%i\n", x, y, width, height); */
+ /* fprintf(stderr, "Xephyr updating: %i+%i %ix%i\n", x, y, width, height); */
- XFillRectangle (HostX.dpy, host_screen->win, HostX.gc, x, y, width,height);
- XSync (HostX.dpy, False);
+ XFillRectangle(HostX.dpy, host_screen->win, HostX.gc, x, y, width, height);
+ XSync(HostX.dpy, False);
- /* nanosleep seems to work better than usleep for me... */
- nanosleep(&tspec, NULL);
+ /* nanosleep seems to work better than usleep for me... */
+ nanosleep(&tspec, NULL);
}
void
hostx_load_keymap(void)
{
- XID *keymap;
- int host_width, min_keycode, max_keycode, width;
- int i,j;
-
- XDisplayKeycodes (HostX.dpy, &min_keycode, &max_keycode);
-
- EPHYR_DBG ("min: %d, max: %d", min_keycode, max_keycode);
-
- keymap = XGetKeyboardMapping (HostX.dpy,
- min_keycode,
- max_keycode - min_keycode + 1,
- &host_width);
-
- /* Try and copy the hosts keymap into our keymap to avoid loads
- * of messing around.
- *
- * kdrive cannot can have more than 4 keysyms per keycode
- * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 )
- */
- width = (host_width > 4) ? 4 : host_width;
-
- ephyrKeySyms.map = (CARD32 *)calloc(sizeof(CARD32),
- (max_keycode - min_keycode + 1) *
- width);
- if (!ephyrKeySyms.map)
+ XID *keymap;
+ int host_width, min_keycode, max_keycode, width;
+ int i, j;
+
+ XDisplayKeycodes(HostX.dpy, &min_keycode, &max_keycode);
+
+ EPHYR_DBG("min: %d, max: %d", min_keycode, max_keycode);
+
+ keymap = XGetKeyboardMapping(HostX.dpy,
+ min_keycode,
+ max_keycode - min_keycode + 1, &host_width);
+
+ /* Try and copy the hosts keymap into our keymap to avoid loads
+ * of messing around.
+ *
+ * kdrive cannot can have more than 4 keysyms per keycode
+ * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 )
+ */
+ width = (host_width > 4) ? 4 : host_width;
+
+ ephyrKeySyms.map = (CARD32 *) calloc(sizeof(CARD32),
+ (max_keycode - min_keycode + 1) *
+ width);
+ if (!ephyrKeySyms.map)
return;
- for (i=0; i<(max_keycode - min_keycode+1); i++)
- for (j=0; j<width; j++)
- ephyrKeySyms.map[(i*width)+j] = (CARD32) keymap[(i*host_width) + j];
+ for (i = 0; i < (max_keycode - min_keycode + 1); i++)
+ for (j = 0; j < width; j++)
+ ephyrKeySyms.map[(i * width) + j] =
+ (CARD32) keymap[(i * host_width) + j];
- EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
+ EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
- ephyrKeySyms.minKeyCode = min_keycode;
- ephyrKeySyms.maxKeyCode = max_keycode;
- ephyrKeySyms.mapWidth = width;
+ ephyrKeySyms.minKeyCode = min_keycode;
+ ephyrKeySyms.maxKeyCode = max_keycode;
+ ephyrKeySyms.mapWidth = width;
- XFree(keymap);
+ XFree(keymap);
}
static struct EphyrHostScreen *
-host_screen_from_window (Window w)
+host_screen_from_window(Window w)
{
- int index = 0;
- struct EphyrHostScreen *result = NULL;
+ int index = 0;
+ struct EphyrHostScreen *result = NULL;
- for (index = 0 ; index < HostX.n_screens ; index++)
- {
- if (HostX.screens[index].win == w || HostX.screens[index].peer_win == w)
- {
- result = &HostX.screens[index];
- goto out;
+ for (index = 0; index < HostX.n_screens; index++) {
+ if (HostX.screens[index].win == w || HostX.screens[index].peer_win == w) {
+ result = &HostX.screens[index];
+ goto out;
}
}
-out:
- return result;
+ out:
+ return result;
}
int
-hostx_get_event(EphyrHostXEvent *ev)
+hostx_get_event(EphyrHostXEvent * ev)
{
- XEvent xev;
- static int grabbed_screen = -1;
-
- if (XPending(HostX.dpy))
- {
- XNextEvent(HostX.dpy, &xev);
-
- switch (xev.type)
- {
- case Expose:
- /* Not so great event compression, but works ok */
- while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window,
- Expose, &xev));
- {
- struct EphyrHostScreen *host_screen =
- host_screen_from_window (xev.xexpose.window);
- if (host_screen)
- {
- hostx_paint_rect (host_screen->info, 0, 0, 0, 0,
- host_screen->win_width,
- host_screen->win_height);
- }
- else
- {
- EPHYR_LOG_ERROR ("failed to get host screen\n");
- ev->type = EPHYR_EV_EXPOSE;
- ev->data.expose.window = xev.xexpose.window;
- return 1;
- }
- }
- return 0;
-
- case MotionNotify:
- {
- struct EphyrHostScreen *host_screen =
- host_screen_from_window (xev.xmotion.window);
-
- ev->type = EPHYR_EV_MOUSE_MOTION;
- ev->data.mouse_motion.x = xev.xmotion.x;
- ev->data.mouse_motion.y = xev.xmotion.y;
- ev->data.mouse_motion.window = xev.xmotion.window;
- ev->data.mouse_motion.screen = (host_screen ? host_screen->mynum : -1);
- }
- return 1;
-
- case ButtonPress:
- ev->type = EPHYR_EV_MOUSE_PRESS;
- ev->key_state = xev.xkey.state;
- /*
- * This is a bit hacky. will break for button 5 ( defined as 0x10 )
- * Check KD_BUTTON defines in kdrive.h
- */
- ev->data.mouse_down.button_num = 1<<(xev.xbutton.button-1);
- return 1;
-
- case ButtonRelease:
- ev->type = EPHYR_EV_MOUSE_RELEASE;
- ev->key_state = xev.xkey.state;
- ev->data.mouse_up.button_num = 1<<(xev.xbutton.button-1);
- return 1;
-
- case KeyPress:
- {
- ev->type = EPHYR_EV_KEY_PRESS;
- ev->key_state = xev.xkey.state;
- ev->data.key_down.scancode = xev.xkey.keycode;
- return 1;
- }
- case KeyRelease:
-
- if ((XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_L
- || XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_R)
- && (xev.xkey.state & ControlMask))
- {
- struct EphyrHostScreen *host_screen =
- host_screen_from_window (xev.xexpose.window);
-
- if (grabbed_screen != -1)
- {
- XUngrabKeyboard (HostX.dpy, CurrentTime);
- XUngrabPointer (HostX.dpy, CurrentTime);
- grabbed_screen = -1;
- hostx_set_win_title (host_screen->info,
- "(ctrl+shift grabs mouse and keyboard)");
- }
- else
- {
- /* Attempt grab */
- if (XGrabKeyboard (HostX.dpy, host_screen->win, True,
- GrabModeAsync,
- GrabModeAsync,
- CurrentTime) == 0)
- {
- if (XGrabPointer (HostX.dpy, host_screen->win, True,
- NoEventMask,
- GrabModeAsync,
- GrabModeAsync,
- host_screen->win, None, CurrentTime) == 0)
- {
- grabbed_screen = host_screen->mynum;
- hostx_set_win_title
- (host_screen->info,
- "(ctrl+shift releases mouse and keyboard)");
- }
- else /* Failed pointer grabm ungrab keyboard */
- XUngrabKeyboard (HostX.dpy, CurrentTime);
- }
- }
- }
-
- /* Still send the release event even if above has happened
- * server will get confused with just an up event.
- * Maybe it would be better to just block shift+ctrls getting to
- * kdrive all togeather.
- */
- ev->type = EPHYR_EV_KEY_RELEASE;
- ev->key_state = xev.xkey.state;
- ev->data.key_up.scancode = xev.xkey.keycode;
- return 1;
-
- default:
- break;
-
- }
+ XEvent xev;
+ static int grabbed_screen = -1;
+
+ if (XPending(HostX.dpy)) {
+ XNextEvent(HostX.dpy, &xev);
+
+ switch (xev.type) {
+ case Expose:
+ /* Not so great event compression, but works ok */
+ while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window,
+ Expose, &xev));
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window(xev.xexpose.window);
+ if (host_screen) {
+ hostx_paint_rect(host_screen->info, 0, 0, 0, 0,
+ host_screen->win_width,
+ host_screen->win_height);
+ }
+ else {
+ EPHYR_LOG_ERROR("failed to get host screen\n");
+ ev->type = EPHYR_EV_EXPOSE;
+ ev->data.expose.window = xev.xexpose.window;
+ return 1;
+ }
+ }
+ return 0;
+
+ case MotionNotify:
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window(xev.xmotion.window);
+
+ ev->type = EPHYR_EV_MOUSE_MOTION;
+ ev->data.mouse_motion.x = xev.xmotion.x;
+ ev->data.mouse_motion.y = xev.xmotion.y;
+ ev->data.mouse_motion.window = xev.xmotion.window;
+ ev->data.mouse_motion.screen =
+ (host_screen ? host_screen->mynum : -1);
+ }
+ return 1;
+
+ case ButtonPress:
+ ev->type = EPHYR_EV_MOUSE_PRESS;
+ ev->key_state = xev.xkey.state;
+ /*
+ * This is a bit hacky. will break for button 5 ( defined as 0x10 )
+ * Check KD_BUTTON defines in kdrive.h
+ */
+ ev->data.mouse_down.button_num = 1 << (xev.xbutton.button - 1);
+ return 1;
+
+ case ButtonRelease:
+ ev->type = EPHYR_EV_MOUSE_RELEASE;
+ ev->key_state = xev.xkey.state;
+ ev->data.mouse_up.button_num = 1 << (xev.xbutton.button - 1);
+ return 1;
+
+ case KeyPress:
+ {
+ ev->type = EPHYR_EV_KEY_PRESS;
+ ev->key_state = xev.xkey.state;
+ ev->data.key_down.scancode = xev.xkey.keycode;
+ return 1;
+ }
+ case KeyRelease:
+
+ if ((XKeycodeToKeysym(HostX.dpy, xev.xkey.keycode, 0) == XK_Shift_L
+ || XKeycodeToKeysym(HostX.dpy, xev.xkey.keycode,
+ 0) == XK_Shift_R)
+ && (xev.xkey.state & ControlMask)) {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window(xev.xexpose.window);
+
+ if (grabbed_screen != -1) {
+ XUngrabKeyboard(HostX.dpy, CurrentTime);
+ XUngrabPointer(HostX.dpy, CurrentTime);
+ grabbed_screen = -1;
+ hostx_set_win_title(host_screen->info,
+ "(ctrl+shift grabs mouse and keyboard)");
+ }
+ else {
+ /* Attempt grab */
+ if (XGrabKeyboard(HostX.dpy, host_screen->win, True,
+ GrabModeAsync,
+ GrabModeAsync, CurrentTime) == 0) {
+ if (XGrabPointer(HostX.dpy, host_screen->win, True,
+ NoEventMask,
+ GrabModeAsync,
+ GrabModeAsync,
+ host_screen->win, None,
+ CurrentTime) == 0) {
+ grabbed_screen = host_screen->mynum;
+ hostx_set_win_title
+ (host_screen->info,
+ "(ctrl+shift releases mouse and keyboard)");
+ }
+ else /* Failed pointer grabm ungrab keyboard */
+ XUngrabKeyboard(HostX.dpy, CurrentTime);
+ }
+ }
+ }
+
+ /* Still send the release event even if above has happened
+ * server will get confused with just an up event.
+ * Maybe it would be better to just block shift+ctrls getting to
+ * kdrive all togeather.
+ */
+ ev->type = EPHYR_EV_KEY_RELEASE;
+ ev->key_state = xev.xkey.state;
+ ev->data.key_up.scancode = xev.xkey.keycode;
+ return 1;
+
+ default:
+ break;
+
+ }
}
- return 0;
+ return 0;
}
-void*
+void *
hostx_get_display(void)
{
- return HostX.dpy ;
+ return HostX.dpy;
}
int
-hostx_get_window (int a_screen_number)
+hostx_get_window(int a_screen_number)
{
if (a_screen_number < 0 || a_screen_number >= HostX.n_screens) {
- EPHYR_LOG_ERROR ("bad screen number:%d\n", a_screen_number) ;
+ EPHYR_LOG_ERROR("bad screen number:%d\n", a_screen_number);
return 0;
}
- return HostX.screens[a_screen_number].win ;
+ return HostX.screens[a_screen_number].win;
}
int
-hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attrs)
+hostx_get_window_attributes(int a_window, EphyrHostWindowAttributes * a_attrs)
{
- XWindowAttributes attrs ;
+ XWindowAttributes attrs;
- memset (&attrs, 0, sizeof (attrs)) ;
+ memset(&attrs, 0, sizeof(attrs));
- if (!XGetWindowAttributes (hostx_get_display (),
- a_window,
- &attrs)) {
- return FALSE ;
+ if (!XGetWindowAttributes(hostx_get_display(), a_window, &attrs)) {
+ return FALSE;
}
- a_attrs->x = attrs.x ;
- a_attrs->y = attrs.y ;
- a_attrs->width = attrs.width ;
- a_attrs->height = attrs.height ;
+ a_attrs->x = attrs.x;
+ a_attrs->y = attrs.y;
+ a_attrs->width = attrs.width;
+ a_attrs->height = attrs.height;
if (attrs.visual)
- a_attrs->visualid = attrs.visual->visualid ;
- return TRUE ;
+ a_attrs->visualid = attrs.visual->visualid;
+ return TRUE;
}
int
-hostx_get_extension_info (const char *a_ext_name,
- int *a_major_opcode,
- int *a_first_event,
- int *a_first_error)
+hostx_get_extension_info(const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event, int *a_first_error)
{
if (!a_ext_name || !a_major_opcode || !a_first_event || !a_first_error)
- return 0 ;
- if (!XQueryExtension (HostX.dpy,
+ return 0;
+ if (!XQueryExtension(HostX.dpy,
a_ext_name,
- a_major_opcode,
- a_first_event,
- a_first_error))
- {
- return 0 ;
- }
- return 1 ;
+ a_major_opcode, a_first_event, a_first_error)) {
+ return 0;
+ }
+ return 1;
}
int
-hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
- int *a_num_entries)
+hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries)
{
- Display *dpy=hostx_get_display () ;
- Bool is_ok=False ;
- XVisualInfo templ, *visuals=NULL;
- EphyrHostVisualInfo *host_visuals=NULL ;
- int nb_items=0, i=0;
-
- EPHYR_RETURN_VAL_IF_FAIL (a_visuals && a_num_entries && dpy,
- False) ;
- EPHYR_LOG ("enter\n") ;
- memset (&templ, 0, sizeof (templ)) ;
- visuals = XGetVisualInfo (dpy, VisualNoMask, &templ, &nb_items) ;
+ Display *dpy = hostx_get_display();
+ Bool is_ok = False;
+ XVisualInfo templ, *visuals = NULL;
+ EphyrHostVisualInfo *host_visuals = NULL;
+ int nb_items = 0, i = 0;
+
+ EPHYR_RETURN_VAL_IF_FAIL(a_visuals && a_num_entries && dpy, False);
+ EPHYR_LOG("enter\n");
+ memset(&templ, 0, sizeof(templ));
+ visuals = XGetVisualInfo(dpy, VisualNoMask, &templ, &nb_items);
if (!visuals) {
- EPHYR_LOG_ERROR ("host does not advertise any visual\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("host does not advertise any visual\n");
+ goto out;
}
- EPHYR_LOG ("host advertises %d visuals\n", nb_items) ;
- host_visuals = calloc (nb_items, sizeof (EphyrHostVisualInfo)) ;
- for (i=0; i<nb_items; i++) {
- host_visuals[i].visualid = visuals[i].visualid ;
- host_visuals[i].screen = visuals[i].screen ;
- host_visuals[i].depth = visuals[i].depth ;
- host_visuals[i].class = visuals[i].class ;
- host_visuals[i].red_mask = visuals[i].red_mask ;
- host_visuals[i].green_mask = visuals[i].green_mask ;
- host_visuals[i].blue_mask = visuals[i].blue_mask ;
- host_visuals[i].colormap_size = visuals[i].colormap_size ;
- host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb ;
+ EPHYR_LOG("host advertises %d visuals\n", nb_items);
+ host_visuals = calloc(nb_items, sizeof(EphyrHostVisualInfo));
+ for (i = 0; i < nb_items; i++) {
+ host_visuals[i].visualid = visuals[i].visualid;
+ host_visuals[i].screen = visuals[i].screen;
+ host_visuals[i].depth = visuals[i].depth;
+ host_visuals[i].class = visuals[i].class;
+ host_visuals[i].red_mask = visuals[i].red_mask;
+ host_visuals[i].green_mask = visuals[i].green_mask;
+ host_visuals[i].blue_mask = visuals[i].blue_mask;
+ host_visuals[i].colormap_size = visuals[i].colormap_size;
+ host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb;
}
- *a_visuals = host_visuals ;
+ *a_visuals = host_visuals;
*a_num_entries = nb_items;
- host_visuals=NULL;
+ host_visuals = NULL;
is_ok = TRUE;
-out:
+ out:
if (visuals) {
- XFree (visuals) ;
+ XFree(visuals);
visuals = NULL;
}
free(host_visuals);
host_visuals = NULL;
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
int
-hostx_create_window (int a_screen_number,
- EphyrBox *a_geometry,
- int a_visual_id,
- int *a_host_peer /*out parameter*/)
+hostx_create_window(int a_screen_number,
+ EphyrBox * a_geometry,
+ int a_visual_id, int *a_host_peer /*out parameter */ )
{
- Bool is_ok=FALSE ;
- Display *dpy=hostx_get_display () ;
- XVisualInfo *visual_info=NULL, visual_info_templ;
- int visual_mask=VisualIDMask ;
- Window win=None ;
- int nb_visuals=0, winmask=0;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ XVisualInfo *visual_info = NULL, visual_info_templ;
+ int visual_mask = VisualIDMask;
+ Window win = None;
+ int nb_visuals = 0, winmask = 0;
XSetWindowAttributes attrs;
- EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geometry, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy && a_geometry, FALSE);
- EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG("enter\n");
- /*get visual*/
- memset (&visual_info, 0, sizeof (visual_info)) ;
- visual_info_templ.visualid = a_visual_id ;
- visual_info = XGetVisualInfo (dpy, visual_mask,
- &visual_info_templ,
- &nb_visuals) ;
+ /*get visual */
+ memset(&visual_info, 0, sizeof(visual_info));
+ visual_info_templ.visualid = a_visual_id;
+ visual_info = XGetVisualInfo(dpy, visual_mask,
+ &visual_info_templ, &nb_visuals);
if (!visual_info) {
- EPHYR_LOG_ERROR ("argh, could not find a remote visual with id:%d\n",
- a_visual_id) ;
- goto out ;
+ EPHYR_LOG_ERROR("argh, could not find a remote visual with id:%d\n",
+ a_visual_id);
+ goto out;
}
- memset (&attrs, 0, sizeof (attrs)) ;
- attrs.colormap = XCreateColormap (dpy,
- RootWindow (dpy,
- visual_info->screen),
- visual_info->visual,
- AllocNone) ;
+ memset(&attrs, 0, sizeof(attrs));
+ attrs.colormap = XCreateColormap(dpy,
+ RootWindow(dpy,
+ visual_info->screen),
+ visual_info->visual, AllocNone);
attrs.event_mask = ButtonPressMask
- |ButtonReleaseMask
- |PointerMotionMask
- |KeyPressMask
- |KeyReleaseMask
- |ExposureMask;
- winmask = CWColormap|CWEventMask;
-
- win = XCreateWindow (dpy, hostx_get_window (a_screen_number),
- a_geometry->x, a_geometry->y,
- a_geometry->width, a_geometry->height, 0,
- visual_info->depth, CopyFromParent,
- visual_info->visual, winmask, &attrs) ;
+ | ButtonReleaseMask
+ | PointerMotionMask | KeyPressMask | KeyReleaseMask | ExposureMask;
+ winmask = CWColormap | CWEventMask;
+
+ win = XCreateWindow(dpy, hostx_get_window(a_screen_number),
+ a_geometry->x, a_geometry->y,
+ a_geometry->width, a_geometry->height, 0,
+ visual_info->depth, CopyFromParent,
+ visual_info->visual, winmask, &attrs);
if (win == None) {
- EPHYR_LOG_ERROR ("failed to create peer window\n") ;
- goto out ;
+ EPHYR_LOG_ERROR("failed to create peer window\n");
+ goto out;
}
if (HostX.screens[a_screen_number].peer_win == None) {
- HostX.screens[a_screen_number].peer_win = win;
- } else {
- EPHYR_LOG_ERROR ("multiple peer windows created for same screen\n") ;
+ HostX.screens[a_screen_number].peer_win = win;
+ }
+ else {
+ EPHYR_LOG_ERROR("multiple peer windows created for same screen\n");
}
- XFlush (dpy) ;
- XMapWindow (dpy, win) ;
- *a_host_peer = win ;
- is_ok = TRUE ;
-out:
- EPHYR_LOG ("leave\n") ;
- return is_ok ;
+ XFlush(dpy);
+ XMapWindow(dpy, win);
+ *a_host_peer = win;
+ is_ok = TRUE;
+ out:
+ EPHYR_LOG("leave\n");
+ return is_ok;
}
int
-hostx_destroy_window (int a_win)
+hostx_destroy_window(int a_win)
{
- Display *dpy=hostx_get_display () ;
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
- XDestroyWindow (dpy, a_win) ;
- XFlush (dpy) ;
- return TRUE ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy, FALSE);
+ XDestroyWindow(dpy, a_win);
+ XFlush(dpy);
+ return TRUE;
}
int
-hostx_set_window_geometry (int a_win, EphyrBox *a_geo)
+hostx_set_window_geometry(int a_win, EphyrBox * a_geo)
{
- Display *dpy=hostx_get_display ();
+ Display *dpy = hostx_get_display();
- EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geo, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL(dpy && a_geo, FALSE);
- EPHYR_LOG ("enter. x,y,w,h:(%d,%d,%d,%d)\n",
- a_geo->x, a_geo->y,
- a_geo->width, a_geo->height) ;
+ EPHYR_LOG("enter. x,y,w,h:(%d,%d,%d,%d)\n",
+ a_geo->x, a_geo->y, a_geo->width, a_geo->height);
- XMoveWindow (dpy, a_win, a_geo->x, a_geo->y) ;
- XResizeWindow (dpy, a_win, a_geo->width, a_geo->height) ;
- EPHYR_LOG ("leave\n") ;
+ XMoveWindow(dpy, a_win, a_geo->x, a_geo->y);
+ XResizeWindow(dpy, a_win, a_geo->width, a_geo->height);
+ EPHYR_LOG("leave\n");
return TRUE;
}
int
-hostx_set_window_bounding_rectangles (int a_window,
- EphyrRect *a_rects,
- int a_num_rects)
+hostx_set_window_bounding_rectangles(int a_window,
+ EphyrRect * a_rects, int a_num_rects)
{
- Bool is_ok=FALSE;
- Display *dpy=hostx_get_display () ;
- int i=0 ;
- XRectangle *rects=NULL ;
-
- EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ;
-
- EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ;
-
- rects = calloc (a_num_rects, sizeof (XRectangle)) ;
- for (i=0; i<a_num_rects; i++) {
- rects[i].x = a_rects[i].x1 ;
- rects[i].y = a_rects[i].y1 ;
- rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1);
- rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ;
- EPHYR_LOG ("borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
- rects[i].x, rects[i].y,
- rects[i].width, rects[i].height) ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int i = 0;
+ XRectangle *rects = NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL(dpy && a_rects, FALSE);
+
+ EPHYR_LOG("enter. num rects:%d\n", a_num_rects);
+
+ rects = calloc(a_num_rects, sizeof(XRectangle));
+ for (i = 0; i < a_num_rects; i++) {
+ rects[i].x = a_rects[i].x1;
+ rects[i].y = a_rects[i].y1;
+ rects[i].width = abs(a_rects[i].x2 - a_rects[i].x1);
+ rects[i].height = abs(a_rects[i].y2 - a_rects[i].y1);
+ EPHYR_LOG("borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
+ rects[i].x, rects[i].y, rects[i].width, rects[i].height);
}
- /*this aways returns 1*/
- XShapeCombineRectangles (dpy, a_window, ShapeBounding, 0, 0,
- rects, a_num_rects, ShapeSet, YXBanded) ;
- is_ok = TRUE ;
+ /*this aways returns 1 */
+ XShapeCombineRectangles(dpy, a_window, ShapeBounding, 0, 0,
+ rects, a_num_rects, ShapeSet, YXBanded);
+ is_ok = TRUE;
free(rects);
rects = NULL;
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return is_ok;
}
int
-hostx_set_window_clipping_rectangles (int a_window,
- EphyrRect *a_rects,
- int a_num_rects)
+hostx_set_window_clipping_rectangles(int a_window,
+ EphyrRect * a_rects, int a_num_rects)
{
- Bool is_ok=FALSE;
- Display *dpy=hostx_get_display () ;
- int i=0 ;
- XRectangle *rects=NULL ;
-
- EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ;
-
- EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ;
-
- rects = calloc (a_num_rects, sizeof (XRectangle)) ;
- for (i=0; i<a_num_rects; i++) {
- rects[i].x = a_rects[i].x1 ;
- rects[i].y = a_rects[i].y1 ;
- rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1);
- rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ;
- EPHYR_LOG ("clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
- rects[i].x, rects[i].y,
- rects[i].width, rects[i].height) ;
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display();
+ int i = 0;
+ XRectangle *rects = NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL(dpy && a_rects, FALSE);
+
+ EPHYR_LOG("enter. num rects:%d\n", a_num_rects);
+
+ rects = calloc(a_num_rects, sizeof(XRectangle));
+ for (i = 0; i < a_num_rects; i++) {
+ rects[i].x = a_rects[i].x1;
+ rects[i].y = a_rects[i].y1;
+ rects[i].width = abs(a_rects[i].x2 - a_rects[i].x1);
+ rects[i].height = abs(a_rects[i].y2 - a_rects[i].y1);
+ EPHYR_LOG("clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
+ rects[i].x, rects[i].y, rects[i].width, rects[i].height);
}
- /*this aways returns 1*/
- XShapeCombineRectangles (dpy, a_window, ShapeClip, 0, 0,
- rects, a_num_rects, ShapeSet, YXBanded) ;
- is_ok = TRUE ;
+ /*this aways returns 1 */
+ XShapeCombineRectangles(dpy, a_window, ShapeClip, 0, 0,
+ rects, a_num_rects, ShapeSet, YXBanded);
+ is_ok = TRUE;
free(rects);
rects = NULL;
- EPHYR_LOG ("leave\n") ;
+ EPHYR_LOG("leave\n");
return is_ok;
}
int
-hostx_has_xshape (void)
+hostx_has_xshape(void)
{
- int event_base=0, error_base=0 ;
- Display *dpy=hostx_get_display () ;
- if (!XShapeQueryExtension (dpy,
- &event_base,
- &error_base)) {
- return FALSE ;
+ int event_base = 0, error_base = 0;
+ Display *dpy = hostx_get_display();
+
+ if (!XShapeQueryExtension(dpy, &event_base, &error_base)) {
+ return FALSE;
}
return TRUE;
}
#ifdef XF86DRI
typedef struct {
- int is_valid ;
- int local_id ;
- int remote_id ;
-} ResourcePair ;
+ int is_valid;
+ int local_id;
+ int remote_id;
+} ResourcePair;
#define RESOURCE_PEERS_SIZE 1024*10
-static ResourcePair resource_peers[RESOURCE_PEERS_SIZE] ;
-
+static ResourcePair resource_peers[RESOURCE_PEERS_SIZE];
int
-hostx_allocate_resource_id_peer (int a_local_resource_id,
- int *a_remote_resource_id)
+hostx_allocate_resource_id_peer(int a_local_resource_id,
+ int *a_remote_resource_id)
{
- int i=0 ;
- ResourcePair *peer=NULL ;
- Display *dpy=hostx_get_display ();
+ int i = 0;
+ ResourcePair *peer = NULL;
+ Display *dpy = hostx_get_display();
/*
* first make sure a resource peer
* does not exist already for
* a_local_resource_id
*/
- for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
if (resource_peers[i].is_valid
&& resource_peers[i].local_id == a_local_resource_id) {
- peer = &resource_peers[i] ;
- break ;
+ peer = &resource_peers[i];
+ break;
}
}
/*
* find one free peer entry, an feed it with
*/
if (!peer) {
- for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
if (!resource_peers[i].is_valid) {
- peer = &resource_peers[i] ;
- break ;
+ peer = &resource_peers[i];
+ break;
}
}
if (peer) {
- peer->remote_id = XAllocID (dpy);
- peer->local_id = a_local_resource_id ;
- peer->is_valid = TRUE ;
+ peer->remote_id = XAllocID(dpy);
+ peer->local_id = a_local_resource_id;
+ peer->is_valid = TRUE;
}
}
if (peer) {
- *a_remote_resource_id = peer->remote_id ;
- return TRUE ;
+ *a_remote_resource_id = peer->remote_id;
+ return TRUE;
}
- return FALSE ;
+ return FALSE;
}
int
-hostx_get_resource_id_peer (int a_local_resource_id,
- int *a_remote_resource_id)
+hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id)
{
- int i=0 ;
- ResourcePair *peer=NULL ;
- for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ int i = 0;
+ ResourcePair *peer = NULL;
+
+ for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
if (resource_peers[i].is_valid
&& resource_peers[i].local_id == a_local_resource_id) {
- peer = &resource_peers[i] ;
- break ;
+ peer = &resource_peers[i];
+ break;
}
}
if (peer) {
- *a_remote_resource_id = peer->remote_id ;
- return TRUE ;
+ *a_remote_resource_id = peer->remote_id;
+ return TRUE;
}
- return FALSE ;
+ return FALSE;
}
int
-hostx_has_dri (void)
+hostx_has_dri(void)
{
- int event_base=0, error_base=0 ;
- Display *dpy=hostx_get_display () ;
+ int event_base = 0, error_base = 0;
+ Display *dpy = hostx_get_display();
if (!dpy)
- return FALSE ;
+ return FALSE;
- if (!XF86DRIQueryExtension (dpy,
- &event_base,
- &error_base)) {
- return FALSE ;
+ if (!XF86DRIQueryExtension(dpy, &event_base, &error_base)) {
+ return FALSE;
}
- return TRUE ;
+ return TRUE;
}
int
-hostx_has_glx (void)
+hostx_has_glx(void)
{
- Display *dpy=hostx_get_display () ;
- int event_base=0, error_base=0 ;
+ Display *dpy = hostx_get_display();
+ int event_base = 0, error_base = 0;
- if (!glXQueryExtension (dpy, &event_base, &error_base)) {
- return FALSE ;
+ if (!glXQueryExtension(dpy, &event_base, &error_base)) {
+ return FALSE;
}
- return TRUE ;
+ return TRUE;
}
-#endif /* XF86DRI */
+#endif /* XF86DRI */
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.h b/xorg-server/hw/kdrive/ephyr/hostx.h
index 42578576a..d6217119a 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.h
+++ b/xorg-server/hw/kdrive/ephyr/hostx.h
@@ -35,230 +35,212 @@
#define EPHYR_DBG(x, a...) \
fprintf(stderr, __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
#else
-#define EPHYR_DBG(x, a...) do {} while (0)
+#define EPHYR_DBG(x, a...) do {} while (0)
#endif
-typedef struct EphyrHostXVars EphyrHostXVars;
+typedef struct EphyrHostXVars EphyrHostXVars;
typedef struct EphyrHostXEvent EphyrHostXEvent;
-typedef void* EphyrScreenInfo ;
-typedef enum EphyrHostXEventType
-{
- EPHYR_EV_MOUSE_MOTION,
- EPHYR_EV_MOUSE_PRESS,
- EPHYR_EV_MOUSE_RELEASE,
- EPHYR_EV_KEY_PRESS,
- EPHYR_EV_KEY_RELEASE,
- EPHYR_EV_EXPOSE
-}
-EphyrHostXEventType;
+typedef void *EphyrScreenInfo;
+typedef enum EphyrHostXEventType {
+ EPHYR_EV_MOUSE_MOTION,
+ EPHYR_EV_MOUSE_PRESS,
+ EPHYR_EV_MOUSE_RELEASE,
+ EPHYR_EV_KEY_PRESS,
+ EPHYR_EV_KEY_RELEASE,
+ EPHYR_EV_EXPOSE
+} EphyrHostXEventType;
/* I can't believe it's not a KeySymsRec. */
typedef struct {
- int minKeyCode;
- int maxKeyCode;
- int mapWidth;
- CARD32 *map;
+ int minKeyCode;
+ int maxKeyCode;
+ int mapWidth;
+ CARD32 *map;
} EphyrKeySyms;
-struct EphyrHostXEvent
-{
- EphyrHostXEventType type;
+struct EphyrHostXEvent {
+ EphyrHostXEventType type;
- union
- {
- struct mouse_motion {
- int x;
- int y;
- int screen;
- int window;
- } mouse_motion;
+ union {
+ struct mouse_motion {
+ int x;
+ int y;
+ int screen;
+ int window;
+ } mouse_motion;
- struct mouse_down {
- int button_num;
- } mouse_down;
+ struct mouse_down {
+ int button_num;
+ } mouse_down;
- struct mouse_up {
- int button_num;
- } mouse_up;
+ struct mouse_up {
+ int button_num;
+ } mouse_up;
- struct key_up {
- int scancode;
- } key_up;
+ struct key_up {
+ int scancode;
+ } key_up;
- struct key_down {
- int scancode;
- } key_down;
+ struct key_down {
+ int scancode;
+ } key_down;
- struct expose {
- int window;
- } expose;
+ struct expose {
+ int window;
+ } expose;
- } data;
+ } data;
- int key_state;
+ int key_state;
};
typedef struct {
- VisualID visualid;
- int screen;
- int depth;
- int class;
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- int colormap_size;
- int bits_per_rgb;
+ VisualID visualid;
+ int screen;
+ int depth;
+ int class;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
} EphyrHostVisualInfo;
typedef struct {
int x, y;
- int width, height ;
- int visualid ;
+ int width, height;
+ int visualid;
} EphyrHostWindowAttributes;
typedef struct {
- int x,y,width,height;
+ int x, y, width, height;
} EphyrBox;
typedef struct {
- short x1,y1,x2,y2;
+ short x1, y1, x2, y2;
} EphyrRect;
int
-hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height);
+ hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height);
int
-hostx_want_host_cursor(void);
+ hostx_want_host_cursor(void);
void
-hostx_use_host_cursor(void);
+ hostx_use_host_cursor(void);
void
-hostx_use_fullscreen(void);
+ hostx_use_fullscreen(void);
int
-hostx_want_fullscreen(void);
+ hostx_want_fullscreen(void);
int
-hostx_want_preexisting_window(EphyrScreenInfo screen);
+ hostx_want_preexisting_window(EphyrScreenInfo screen);
void
-hostx_use_preexisting_window(unsigned long win_id);
+ hostx_use_preexisting_window(unsigned long win_id);
void
-hostx_use_resname (char *name, int fromcmd);
+ hostx_use_resname(char *name, int fromcmd);
void
-hostx_set_title(char *name);
+ hostx_set_title(char *name);
-void
-hostx_handle_signal(int signum);
+void
+ hostx_handle_signal(int signum);
int
-hostx_init(void);
+ hostx_init(void);
void
-hostx_add_screen(EphyrScreenInfo screen, unsigned long win_id, int screen_num);
+ hostx_add_screen(EphyrScreenInfo screen, unsigned long win_id, int screen_num);
void
-hostx_set_display_name(char *name);
+ hostx_set_display_name(char *name);
void
-hostx_set_screen_number(EphyrScreenInfo screen, int number);
+ hostx_set_screen_number(EphyrScreenInfo screen, int number);
void
-hostx_set_win_title(EphyrScreenInfo screen, char *extra_text);
+ hostx_set_win_title(EphyrScreenInfo screen, char *extra_text);
int
-hostx_get_depth (void);
+ hostx_get_depth(void);
int
-hostx_get_server_depth (EphyrScreenInfo screen);
+ hostx_get_server_depth(EphyrScreenInfo screen);
void
-hostx_set_server_depth(EphyrScreenInfo screen, int depth);
+ hostx_set_server_depth(EphyrScreenInfo screen, int depth);
int
-hostx_get_bpp(void *info);
+ hostx_get_bpp(void *info);
void
-hostx_get_visual_masks (void *info,
- CARD32 *rmsk,
- CARD32 *gmsk,
- CARD32 *bmsk);
+ hostx_get_visual_masks(void *info, CARD32 *rmsk, CARD32 *gmsk, CARD32 *bmsk);
void
-hostx_set_cmap_entry(unsigned char idx,
- unsigned char r,
- unsigned char g,
- unsigned char b);
-void*
-hostx_screen_init (EphyrScreenInfo screen,
- int width, int height,
- int buffer_height);
+hostx_set_cmap_entry(unsigned char idx,
+ unsigned char r, unsigned char g, unsigned char b);
+
+void *hostx_screen_init(EphyrScreenInfo screen,
+ int width, int height, int buffer_height);
void
-hostx_paint_rect(EphyrScreenInfo screen,
- int sx, int sy,
- int dx, int dy,
- int width, int height);
+hostx_paint_rect(EphyrScreenInfo screen,
+ int sx, int sy, int dx, int dy, int width, int height);
void
-hostx_load_keymap (void);
+ hostx_load_keymap(void);
int
-hostx_get_event (EphyrHostXEvent *ev);
+ hostx_get_event(EphyrHostXEvent * ev);
-void*
-hostx_get_display (void) ;
+void *hostx_get_display(void);
int
-hostx_get_window (int a_screen_number) ;
+ hostx_get_window(int a_screen_number);
int
-hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attr) ;
+ hostx_get_window_attributes(int a_window, EphyrHostWindowAttributes * a_attr);
int
-hostx_get_extension_info (const char *a_ext_name,
- int *a_major_opcode,
- int *a_first_even,
- int *a_first_error) ;
-int
-hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
- int *a_num_entries) ;
-int hostx_create_window (int a_screen_number,
- EphyrBox *a_geometry,
- int a_visual_id,
- int *a_host_win /*out parameter*/) ;
+hostx_get_extension_info(const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_even, int *a_first_error);
+int
+ hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries);
-int hostx_destroy_window (int a_win) ;
+int hostx_create_window(int a_screen_number,
+ EphyrBox * a_geometry,
+ int a_visual_id, int *a_host_win /*out parameter */ );
-int hostx_set_window_geometry (int a_win, EphyrBox *a_geo) ;
+int hostx_destroy_window(int a_win);
+int hostx_set_window_geometry(int a_win, EphyrBox * a_geo);
-int hostx_set_window_bounding_rectangles (int a_window,
- EphyrRect *a_rects,
- int a_num_rects) ;
+int hostx_set_window_bounding_rectangles(int a_window,
+ EphyrRect * a_rects, int a_num_rects);
-int hostx_set_window_clipping_rectangles (int a_window,
- EphyrRect *a_rects,
- int a_num_rects) ;
-int hostx_has_xshape (void) ;
+int hostx_set_window_clipping_rectangles(int a_window,
+ EphyrRect * a_rects, int a_num_rects);
+int hostx_has_xshape(void);
#ifdef XF86DRI
-int hostx_lookup_peer_window (void *a_local_window,
- int *a_host_peer /*out parameter*/) ;
+int hostx_lookup_peer_window(void *a_local_window,
+ int *a_host_peer /*out parameter */ );
int
-hostx_allocate_resource_id_peer (int a_local_resource_id,
- int *a_remote_resource_id) ;
+
+hostx_allocate_resource_id_peer(int a_local_resource_id,
+ int *a_remote_resource_id);
int
-hostx_get_resource_id_peer (int a_local_resource_id,
- int *a_remote_resource_id) ;
-int hostx_has_dri (void) ;
+ hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id);
+int hostx_has_dri(void);
-int hostx_has_glx (void) ;
-#endif /* XF86DRI */
+int hostx_has_glx(void);
+#endif /* XF86DRI */
#endif /*_XLIBS_STUFF_H_*/
diff --git a/xorg-server/hw/kdrive/ephyr/os.c b/xorg-server/hw/kdrive/ephyr/os.c
index e4dc6787d..a2a705dd9 100644
--- a/xorg-server/hw/kdrive/ephyr/os.c
+++ b/xorg-server/hw/kdrive/ephyr/os.c
@@ -28,24 +28,22 @@
#endif
#include "ephyr.h"
-extern void processScreenArg (char *screen_size, char *parent_id) ;
+extern void processScreenArg(char *screen_size, char *parent_id);
static int
-EphyrInit (void)
+EphyrInit(void)
{
- /*
- * make sure at least one screen
- * has been added to the system.
- */
- if (!KdCardInfoLast ())
- {
- processScreenArg ("640x480", NULL) ;
+ /*
+ * make sure at least one screen
+ * has been added to the system.
+ */
+ if (!KdCardInfoLast()) {
+ processScreenArg("640x480", NULL);
}
- return hostx_init();
+ return hostx_init();
}
-KdOsFuncs EphyrOsFuncs = {
+KdOsFuncs EphyrOsFuncs = {
.Init = EphyrInit,
.pollEvents = ephyrPoll,
};
-
diff --git a/xorg-server/hw/kdrive/ephyr/xf86dri.h b/xorg-server/hw/kdrive/ephyr/xf86dri.h
index cd650b582..88d3f3bf1 100644
--- a/xorg-server/hw/kdrive/ephyr/xf86dri.h
+++ b/xorg-server/hw/kdrive/ephyr/xf86dri.h
@@ -54,8 +54,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define X_XF86DRIGetDrawableInfo 9
#define X_XF86DRIGetDeviceInfo 10
#define X_XF86DRIAuthConnection 11
-#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
-#define X_XF86DRICloseFullScreen 13 /* Deprecated */
+#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
+#define X_XF86DRICloseFullScreen 13 /* Deprecated */
#define XF86DRINumberEvents 0
@@ -67,54 +67,58 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
_XFUNCPROTOBEGIN
-Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+Bool XF86DRIQueryExtension(Display * dpy, int *event_base, int *error_base);
-Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
- int *patchVersion );
+Bool XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion);
-Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
- Bool *isCapable );
+Bool XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen,
+ Bool *isCapable);
-Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
- char **busIDString );
+Bool XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA,
+ char **busIDString);
-Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+Bool XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic);
-Bool XF86DRICloseConnection( Display *dpy, int screen );
+Bool XF86DRICloseConnection(Display * dpy, int screen);
-Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
- int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
- int *ddxDriverPatchVersion, char **clientDriverName );
+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 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 XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID,
+ XID *ptr_to_returned_context_id,
+ drm_context_t * hHWContext);
-extern GLboolean XF86DRIDestroyContext( Display *dpy, int screen,
- XID context_id );
+extern GLboolean XF86DRIDestroyContext(Display * dpy, int screen,
+ XID context_id);
-extern GLboolean XF86DRICreateDrawable( Display *dpy, int screen,
- XID drawable, drm_drawable_t *hHWDrawable );
+extern GLboolean XF86DRICreateDrawable(Display * dpy, int screen,
+ XID drawable,
+ drm_drawable_t * hHWDrawable);
-extern GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen,
- XID drawable);
+extern GLboolean XF86DRIDestroyDrawable(Display * dpy, int screen,
+ XID 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 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 );
+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_ */
-
+#endif /* _XF86DRI_SERVER_ */
+#endif /* _XF86DRI_H_ */
diff --git a/xorg-server/hw/kdrive/fake/fake.c b/xorg-server/hw/kdrive/fake/fake.c
index 21360b16d..90e3ec9a6 100644
--- a/xorg-server/hw/kdrive/fake/fake.c
+++ b/xorg-server/hw/kdrive/fake/fake.c
@@ -1,472 +1,450 @@
-/*
- * Copyright © 2004 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "fake.h"
-
-extern int KdTsPhyScreen;
-
-Bool
-fakeInitialize (KdCardInfo *card, FakePriv *priv)
-{
- priv->base = 0;
- priv->bytes_per_line = 0;
- return TRUE;
-}
-
-Bool
-fakeCardInit (KdCardInfo *card)
-{
- FakePriv *priv;
-
- priv = (FakePriv *) malloc(sizeof (FakePriv));
- if (!priv)
- return FALSE;
-
- if (!fakeInitialize (card, priv))
- {
- free(priv);
- return FALSE;
- }
- card->driver = priv;
-
- return TRUE;
-}
-
-Bool
-fakeScreenInitialize (KdScreenInfo *screen, FakeScrPriv *scrpriv)
-{
- if (!screen->width || !screen->height)
- {
- screen->width = 1024;
- screen->height = 768;
- screen->rate = 72;
- }
-
- if (screen->width <= 0)
- screen->width = 1;
- if (screen->height <= 0)
- screen->height = 1;
-
- if (!screen->fb.depth)
- screen->fb.depth = 16;
-
- if (screen->fb.depth <= 8)
- {
- screen->fb.visuals = ((1 << StaticGray) |
- (1 << GrayScale) |
- (1 << StaticColor) |
- (1 << PseudoColor) |
- (1 << TrueColor) |
- (1 << DirectColor));
- }
- else
- {
- screen->fb.visuals = (1 << TrueColor);
-#define Mask(o,l) (((1 << l) - 1) << o)
- if (screen->fb.depth <= 15)
- {
- screen->fb.depth = 15;
- screen->fb.bitsPerPixel = 16;
- screen->fb.redMask = Mask (10, 5);
- screen->fb.greenMask = Mask (5, 5);
- screen->fb.blueMask = Mask (0, 5);
- }
- else if (screen->fb.depth <= 16)
- {
- screen->fb.depth = 16;
- screen->fb.bitsPerPixel = 16;
- screen->fb.redMask = Mask (11, 5);
- screen->fb.greenMask = Mask (5, 6);
- screen->fb.blueMask = Mask (0, 5);
- }
- else
- {
- screen->fb.depth = 24;
- screen->fb.bitsPerPixel = 32;
- screen->fb.redMask = Mask (16, 8);
- screen->fb.greenMask = Mask (8, 8);
- screen->fb.blueMask = Mask (0, 8);
- }
- }
-
- scrpriv->randr = screen->randr;
-
- return fakeMapFramebuffer (screen);
-}
-
-Bool
-fakeScreenInit (KdScreenInfo *screen)
-{
- FakeScrPriv *scrpriv;
-
- scrpriv = calloc(1, sizeof (FakeScrPriv));
- if (!scrpriv)
- return FALSE;
- screen->driver = scrpriv;
- if (!fakeScreenInitialize (screen, scrpriv))
- {
- screen->driver = 0;
- free(scrpriv);
- return FALSE;
- }
- return TRUE;
-}
-
-void *
-fakeWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure)
-{
- KdScreenPriv(pScreen);
- FakePriv *priv = pScreenPriv->card->driver;
-
- if (!pScreenPriv->enabled)
- return 0;
- *size = priv->bytes_per_line;
- return priv->base + row * priv->bytes_per_line;
-}
-
-Bool
-fakeMapFramebuffer (KdScreenInfo *screen)
-{
- FakeScrPriv *scrpriv = screen->driver;
- KdPointerMatrix m;
- FakePriv *priv = screen->card->driver;
-
- if (scrpriv->randr != RR_Rotate_0)
- scrpriv->shadow = TRUE;
- else
- scrpriv->shadow = FALSE;
-
- KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
-
- KdSetPointerMatrix (&m);
-
- priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
- free(priv->base);
- priv->base = malloc (priv->bytes_per_line * screen->height);
-
- if (scrpriv->shadow)
- {
- if (!KdShadowFbAlloc (screen, scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
- return FALSE;
- }
- else
- {
- screen->fb.byteStride = priv->bytes_per_line;
- screen->fb.pixelStride = (priv->bytes_per_line * 8/
- screen->fb.bitsPerPixel);
- screen->fb.frameBuffer = (CARD8 *) (priv->base);
- }
-
- return TRUE;
-}
-
-void
-fakeSetScreenSizes (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FakeScrPriv *scrpriv = screen->driver;
-
- if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- pScreen->width = screen->width;
- pScreen->height = screen->height;
- pScreen->mmWidth = screen->width_mm;
- pScreen->mmHeight = screen->height_mm;
- }
- else
- {
- pScreen->width = screen->width;
- pScreen->height = screen->height;
- pScreen->mmWidth = screen->height_mm;
- pScreen->mmHeight = screen->width_mm;
- }
-}
-
-Bool
-fakeUnmapFramebuffer (KdScreenInfo *screen)
-{
- FakePriv *priv = screen->card->driver;
- KdShadowFbFree (screen);
- free(priv->base);
- priv->base = NULL;
- return TRUE;
-}
-
-Bool
-fakeSetShadow (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FakeScrPriv *scrpriv = screen->driver;
- ShadowUpdateProc update;
- ShadowWindowProc window;
-
- window = fakeWindowLinear;
- update = 0;
- if (scrpriv->randr)
- update = shadowUpdateRotatePacked;
- else
- update = shadowUpdatePacked;
- return KdShadowSet (pScreen, scrpriv->randr, update, window);
-}
-
-
-#ifdef RANDR
-Bool
-fakeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FakeScrPriv *scrpriv = screen->driver;
- RRScreenSizePtr pSize;
- Rotation randr;
- int n;
-
- *rotations = RR_Rotate_All|RR_Reflect_All;
-
- for (n = 0; n < pScreen->numDepths; n++)
- if (pScreen->allowedDepths[n].numVids)
- break;
- if (n == pScreen->numDepths)
- return FALSE;
-
- pSize = RRRegisterSize (pScreen,
- screen->width,
- screen->height,
- screen->width_mm,
- screen->height_mm);
-
- randr = KdSubRotation (scrpriv->randr, screen->randr);
-
- RRSetCurrentConfig (pScreen, randr, 0, pSize);
-
- return TRUE;
-}
-
-Bool
-fakeRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FakeScrPriv *scrpriv = screen->driver;
- Bool wasEnabled = pScreenPriv->enabled;
- FakeScrPriv oldscr;
- int oldwidth;
- int oldheight;
- int oldmmwidth;
- int oldmmheight;
- int newwidth, newheight;
-
- if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- newwidth = pSize->width;
- newheight = pSize->height;
- }
- else
- {
- newwidth = pSize->height;
- newheight = pSize->width;
- }
-
- if (wasEnabled)
- KdDisableScreen (pScreen);
-
- oldscr = *scrpriv;
-
- oldwidth = screen->width;
- oldheight = screen->height;
- oldmmwidth = pScreen->mmWidth;
- oldmmheight = pScreen->mmHeight;
-
- /*
- * Set new configuration
- */
-
- scrpriv->randr = KdAddRotation (screen->randr, randr);
-
- fakeUnmapFramebuffer (screen);
-
- if (!fakeMapFramebuffer (screen))
- goto bail4;
-
- KdShadowUnset (screen->pScreen);
-
- if (!fakeSetShadow (screen->pScreen))
- goto bail4;
-
- fakeSetScreenSizes (screen->pScreen);
-
- /*
- * Set frame buffer mapping
- */
- (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
- pScreen->width,
- pScreen->height,
- screen->fb.depth,
- screen->fb.bitsPerPixel,
- screen->fb.byteStride,
- screen->fb.frameBuffer);
-
- /* set the subpixel order */
-
- KdSetSubpixelOrder (pScreen, scrpriv->randr);
- if (wasEnabled)
- KdEnableScreen (pScreen);
-
- return TRUE;
-
-bail4:
- fakeUnmapFramebuffer (screen);
- *scrpriv = oldscr;
- (void) fakeMapFramebuffer (screen);
- pScreen->width = oldwidth;
- pScreen->height = oldheight;
- pScreen->mmWidth = oldmmwidth;
- pScreen->mmHeight = oldmmheight;
-
- if (wasEnabled)
- KdEnableScreen (pScreen);
- return FALSE;
-}
-
-Bool
-fakeRandRInit (ScreenPtr pScreen)
-{
- rrScrPrivPtr pScrPriv;
-
- if (!RRScreenInit (pScreen))
- return FALSE;
-
- pScrPriv = rrGetScrPriv(pScreen);
- pScrPriv->rrGetInfo = fakeRandRGetInfo;
- pScrPriv->rrSetConfig = fakeRandRSetConfig;
- return TRUE;
-}
-#endif
-
-Bool
-fakeCreateColormap (ColormapPtr pmap)
-{
- return fbInitializeColormap (pmap);
-}
-
-Bool
-fakeInitScreen (ScreenPtr pScreen)
-{
-#ifdef TOUCHSCREEN
- KdTsPhyScreen = pScreen->myNum;
-#endif
-
- pScreen->CreateColormap = fakeCreateColormap;
- return TRUE;
-}
-
-Bool
-fakeFinishInitScreen (ScreenPtr pScreen)
-{
- if (!shadowSetup (pScreen))
- return FALSE;
-
-#ifdef RANDR
- if (!fakeRandRInit (pScreen))
- return FALSE;
-#endif
-
- return TRUE;
-}
-
-
-Bool
-fakeCreateResources (ScreenPtr pScreen)
-{
- return fakeSetShadow (pScreen);
-}
-
-void
-fakePreserve (KdCardInfo *card)
-{
-}
-
-Bool
-fakeEnable (ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-Bool
-fakeDPMS (ScreenPtr pScreen, int mode)
-{
- return TRUE;
-}
-
-void
-fakeDisable (ScreenPtr pScreen)
-{
-}
-
-void
-fakeRestore (KdCardInfo *card)
-{
-}
-
-void
-fakeScreenFini (KdScreenInfo *screen)
-{
-}
-
-void
-fakeCardFini (KdCardInfo *card)
-{
- FakePriv *priv = card->driver;
-
- free (priv->base);
- free(priv);
-}
-
-void
-fakeGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
-{
- while (n--)
- {
- pdefs->red = 0;
- pdefs->green = 0;
- pdefs->blue = 0;
- pdefs++;
- }
-}
-
-void
-fakePutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
-{
-}
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "fake.h"
+
+extern int KdTsPhyScreen;
+
+Bool
+fakeInitialize(KdCardInfo * card, FakePriv * priv)
+{
+ priv->base = 0;
+ priv->bytes_per_line = 0;
+ return TRUE;
+}
+
+Bool
+fakeCardInit(KdCardInfo * card)
+{
+ FakePriv *priv;
+
+ priv = (FakePriv *) malloc(sizeof(FakePriv));
+ if (!priv)
+ return FALSE;
+
+ if (!fakeInitialize(card, priv)) {
+ free(priv);
+ return FALSE;
+ }
+ card->driver = priv;
+
+ return TRUE;
+}
+
+Bool
+fakeScreenInitialize(KdScreenInfo * screen, FakeScrPriv * scrpriv)
+{
+ if (!screen->width || !screen->height) {
+ screen->width = 1024;
+ screen->height = 768;
+ screen->rate = 72;
+ }
+
+ if (screen->width <= 0)
+ screen->width = 1;
+ if (screen->height <= 0)
+ screen->height = 1;
+
+ if (!screen->fb.depth)
+ screen->fb.depth = 16;
+
+ if (screen->fb.depth <= 8) {
+ screen->fb.visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) | (1 << DirectColor));
+ }
+ else {
+ screen->fb.visuals = (1 << TrueColor);
+#define Mask(o,l) (((1 << l) - 1) << o)
+ if (screen->fb.depth <= 15) {
+ screen->fb.depth = 15;
+ screen->fb.bitsPerPixel = 16;
+ screen->fb.redMask = Mask (10, 5);
+ screen->fb.greenMask = Mask (5, 5);
+ screen->fb.blueMask = Mask (0, 5);
+ }
+ else if (screen->fb.depth <= 16) {
+ screen->fb.depth = 16;
+ screen->fb.bitsPerPixel = 16;
+ screen->fb.redMask = Mask (11, 5);
+ screen->fb.greenMask = Mask (5, 6);
+ screen->fb.blueMask = Mask (0, 5);
+ }
+ else {
+ screen->fb.depth = 24;
+ screen->fb.bitsPerPixel = 32;
+ screen->fb.redMask = Mask (16, 8);
+ screen->fb.greenMask = Mask (8, 8);
+ screen->fb.blueMask = Mask (0, 8);
+ }
+ }
+
+ scrpriv->randr = screen->randr;
+
+ return fakeMapFramebuffer(screen);
+}
+
+Bool
+fakeScreenInit(KdScreenInfo * screen)
+{
+ FakeScrPriv *scrpriv;
+
+ scrpriv = calloc(1, sizeof(FakeScrPriv));
+ if (!scrpriv)
+ return FALSE;
+ screen->driver = scrpriv;
+ if (!fakeScreenInitialize(screen, scrpriv)) {
+ screen->driver = 0;
+ free(scrpriv);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void *
+fakeWindowLinear(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset, int mode, CARD32 *size, void *closure)
+{
+ KdScreenPriv(pScreen);
+ FakePriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ *size = priv->bytes_per_line;
+ return priv->base + row * priv->bytes_per_line;
+}
+
+Bool
+fakeMapFramebuffer(KdScreenInfo * screen)
+{
+ FakeScrPriv *scrpriv = screen->driver;
+ KdPointerMatrix m;
+ FakePriv *priv = screen->card->driver;
+
+ if (scrpriv->randr != RR_Rotate_0)
+ scrpriv->shadow = TRUE;
+ else
+ scrpriv->shadow = FALSE;
+
+ KdComputePointerMatrix(&m, scrpriv->randr, screen->width, screen->height);
+
+ KdSetPointerMatrix(&m);
+
+ priv->bytes_per_line =
+ ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
+ free(priv->base);
+ priv->base = malloc(priv->bytes_per_line * screen->height);
+
+ if (scrpriv->shadow) {
+ if (!KdShadowFbAlloc
+ (screen, scrpriv->randr & (RR_Rotate_90 | RR_Rotate_270)))
+ return FALSE;
+ }
+ else {
+ screen->fb.byteStride = priv->bytes_per_line;
+ screen->fb.pixelStride = (priv->bytes_per_line * 8 /
+ screen->fb.bitsPerPixel);
+ screen->fb.frameBuffer = (CARD8 *) (priv->base);
+ }
+
+ return TRUE;
+}
+
+void
+fakeSetScreenSizes(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0 | RR_Rotate_180)) {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
+ }
+ else {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
+ }
+}
+
+Bool
+fakeUnmapFramebuffer(KdScreenInfo * screen)
+{
+ FakePriv *priv = screen->card->driver;
+
+ KdShadowFbFree(screen);
+ free(priv->base);
+ priv->base = NULL;
+ return TRUE;
+}
+
+Bool
+fakeSetShadow(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+
+ window = fakeWindowLinear;
+ update = 0;
+ if (scrpriv->randr)
+ update = shadowUpdateRotatePacked;
+ else
+ update = shadowUpdatePacked;
+ return KdShadowSet(pScreen, scrpriv->randr, update, window);
+}
+
+#ifdef RANDR
+Bool
+fakeRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n;
+
+ *rotations = RR_Rotate_All | RR_Reflect_All;
+
+ for (n = 0; n < pScreen->numDepths; n++)
+ if (pScreen->allowedDepths[n].numVids)
+ break;
+ if (n == pScreen->numDepths)
+ return FALSE;
+
+ pSize = RRRegisterSize(pScreen,
+ screen->width,
+ screen->height, screen->width_mm, screen->height_mm);
+
+ randr = KdSubRotation(scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig(pScreen, randr, 0, pSize);
+
+ return TRUE;
+}
+
+Bool
+fakeRandRSetConfig(ScreenPtr pScreen,
+ Rotation randr, int rate, RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ FakeScrPriv oldscr;
+ int oldwidth;
+ int oldheight;
+ int oldmmwidth;
+ int oldmmheight;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0 | RR_Rotate_180)) {
+ newwidth = pSize->width;
+ newheight = pSize->height;
+ }
+ else {
+ newwidth = pSize->height;
+ newheight = pSize->width;
+ }
+
+ if (wasEnabled)
+ KdDisableScreen(pScreen);
+
+ oldscr = *scrpriv;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+
+ /*
+ * Set new configuration
+ */
+
+ scrpriv->randr = KdAddRotation(screen->randr, randr);
+
+ fakeUnmapFramebuffer(screen);
+
+ if (!fakeMapFramebuffer(screen))
+ goto bail4;
+
+ KdShadowUnset(screen->pScreen);
+
+ if (!fakeSetShadow(screen->pScreen))
+ goto bail4;
+
+ fakeSetScreenSizes(screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap(pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb.depth,
+ screen->fb.bitsPerPixel,
+ screen->fb.byteStride,
+ screen->fb.frameBuffer);
+
+ /* set the subpixel order */
+
+ KdSetSubpixelOrder(pScreen, scrpriv->randr);
+ if (wasEnabled)
+ KdEnableScreen(pScreen);
+
+ return TRUE;
+
+ bail4:
+ fakeUnmapFramebuffer(screen);
+ *scrpriv = oldscr;
+ (void) fakeMapFramebuffer(screen);
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+ if (wasEnabled)
+ KdEnableScreen(pScreen);
+ return FALSE;
+}
+
+Bool
+fakeRandRInit(ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit(pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = fakeRandRGetInfo;
+ pScrPriv->rrSetConfig = fakeRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+Bool
+fakeCreateColormap(ColormapPtr pmap)
+{
+ return fbInitializeColormap(pmap);
+}
+
+Bool
+fakeInitScreen(ScreenPtr pScreen)
+{
+#ifdef TOUCHSCREEN
+ KdTsPhyScreen = pScreen->myNum;
+#endif
+
+ pScreen->CreateColormap = fakeCreateColormap;
+ return TRUE;
+}
+
+Bool
+fakeFinishInitScreen(ScreenPtr pScreen)
+{
+ if (!shadowSetup(pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!fakeRandRInit(pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+Bool
+fakeCreateResources(ScreenPtr pScreen)
+{
+ return fakeSetShadow(pScreen);
+}
+
+void
+fakePreserve(KdCardInfo * card)
+{
+}
+
+Bool
+fakeEnable(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+fakeDPMS(ScreenPtr pScreen, int mode)
+{
+ return TRUE;
+}
+
+void
+fakeDisable(ScreenPtr pScreen)
+{
+}
+
+void
+fakeRestore(KdCardInfo * card)
+{
+}
+
+void
+fakeScreenFini(KdScreenInfo * screen)
+{
+}
+
+void
+fakeCardFini(KdCardInfo * card)
+{
+ FakePriv *priv = card->driver;
+
+ free(priv->base);
+ free(priv);
+}
+
+void
+fakeGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
+{
+ while (n--) {
+ pdefs->red = 0;
+ pdefs->green = 0;
+ pdefs->blue = 0;
+ pdefs++;
+ }
+}
+
+void
+fakePutColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
+{
+}
diff --git a/xorg-server/hw/kdrive/fake/fake.h b/xorg-server/hw/kdrive/fake/fake.h
index d5058606a..ae33fc6d0 100644
--- a/xorg-server/hw/kdrive/fake/fake.h
+++ b/xorg-server/hw/kdrive/fake/fake.h
@@ -31,106 +31,101 @@
#endif
typedef struct _fakePriv {
- CARD8 *base;
- int bytes_per_line;
+ CARD8 *base;
+ int bytes_per_line;
} FakePriv;
-
+
typedef struct _fakeScrPriv {
- Rotation randr;
- Bool shadow;
+ Rotation randr;
+ Bool shadow;
} FakeScrPriv;
-extern KdCardFuncs fakeFuncs;
+extern KdCardFuncs fakeFuncs;
Bool
-fakeInitialize (KdCardInfo *card, FakePriv *priv);
+ fakeInitialize(KdCardInfo * card, FakePriv * priv);
Bool
-fakeCardInit (KdCardInfo *card);
+ fakeCardInit(KdCardInfo * card);
Bool
-fakeScreenInit (KdScreenInfo *screen);
+ fakeScreenInit(KdScreenInfo * screen);
Bool
-fakeScreenInitialize (KdScreenInfo *screen, FakeScrPriv *scrpriv);
-
+ fakeScreenInitialize(KdScreenInfo * screen, FakeScrPriv * scrpriv);
+
Bool
-fakeInitScreen (ScreenPtr pScreen);
+ fakeInitScreen(ScreenPtr pScreen);
Bool
-fakeFinishInitScreen (ScreenPtr pScreen);
+ fakeFinishInitScreen(ScreenPtr pScreen);
Bool
-fakeCreateResources (ScreenPtr pScreen);
+ fakeCreateResources(ScreenPtr pScreen);
void
-fakePreserve (KdCardInfo *card);
+ fakePreserve(KdCardInfo * card);
Bool
-fakeEnable (ScreenPtr pScreen);
+ fakeEnable(ScreenPtr pScreen);
Bool
-fakeDPMS (ScreenPtr pScreen, int mode);
+ fakeDPMS(ScreenPtr pScreen, int mode);
void
-fakeDisable (ScreenPtr pScreen);
+ fakeDisable(ScreenPtr pScreen);
void
-fakeRestore (KdCardInfo *card);
+ fakeRestore(KdCardInfo * card);
void
-fakeScreenFini (KdScreenInfo *screen);
+ fakeScreenFini(KdScreenInfo * screen);
void
-fakeCardFini (KdCardInfo *card);
+ fakeCardFini(KdCardInfo * card);
void
-fakeGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+ fakeGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs);
void
-fakePutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+ fakePutColors(ScreenPtr pScreen, int n, xColorItem * pdefs);
Bool
-fakeMapFramebuffer (KdScreenInfo *screen);
+ fakeMapFramebuffer(KdScreenInfo * screen);
-void *
-fakeWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure);
+void *fakeWindowLinear(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset, int mode, CARD32 *size, void *closure);
void
-fakeSetScreenSizes (ScreenPtr pScreen);
+ fakeSetScreenSizes(ScreenPtr pScreen);
Bool
-fakeUnmapFramebuffer (KdScreenInfo *screen);
+ fakeUnmapFramebuffer(KdScreenInfo * screen);
Bool
-fakeSetShadow (ScreenPtr pScreen);
+ fakeSetShadow(ScreenPtr pScreen);
Bool
-fakeCreateColormap (ColormapPtr pmap);
-
+ fakeCreateColormap(ColormapPtr pmap);
+
#ifdef RANDR
Bool
-fakeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+ fakeRandRGetInfo(ScreenPtr pScreen, Rotation * rotations);
Bool
-fakeRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize);
+
+fakeRandRSetConfig(ScreenPtr pScreen,
+ Rotation randr, int rate, RRScreenSizePtr pSize);
Bool
-fakeRandRInit (ScreenPtr pScreen);
+ fakeRandRInit(ScreenPtr pScreen);
#endif
extern KdPointerDriver FakePointerDriver;
-extern KdKeyboardDriver FakeKeyboardDriver;
+extern KdKeyboardDriver FakeKeyboardDriver;
-extern KdOsFuncs FakeOsFuncs;
+extern KdOsFuncs FakeOsFuncs;
-#endif /* _FBDEV_H_ */
+#endif /* _FBDEV_H_ */
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.c b/xorg-server/hw/kdrive/fbdev/fbdev.c
index 661e5b491..fd14afa92 100644
--- a/xorg-server/hw/kdrive/fbdev/fbdev.c
+++ b/xorg-server/hw/kdrive/fbdev/fbdev.c
@@ -33,46 +33,43 @@ extern int KdTsPhyScreen;
char *fbdevDevicePath = NULL;
static Bool
-fbdevInitialize (KdCardInfo *card, FbdevPriv *priv)
+fbdevInitialize(KdCardInfo * card, FbdevPriv * priv)
{
- unsigned long off;
+ unsigned long off;
if (fbdevDevicePath == NULL)
- fbdevDevicePath = "/dev/fb0";
+ fbdevDevicePath = "/dev/fb0";
- if ((priv->fd = open(fbdevDevicePath, O_RDWR)) < 0)
- {
- ErrorF("Error opening framebuffer %s: %s\n",
- fbdevDevicePath, strerror(errno));
+ if ((priv->fd = open(fbdevDevicePath, O_RDWR)) < 0) {
+ ErrorF("Error opening framebuffer %s: %s\n",
+ fbdevDevicePath, strerror(errno));
return FALSE;
- }
+ }
/* quiet valgrind */
- memset (&priv->fix, '\0', sizeof (priv->fix));
+ memset(&priv->fix, '\0', sizeof(priv->fix));
if (ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix) < 0) {
- perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
- close (priv->fd);
- return FALSE;
+ perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
+ close(priv->fd);
+ return FALSE;
}
/* quiet valgrind */
- memset (&priv->var, '\0', sizeof (priv->var));
+ memset(&priv->var, '\0', sizeof(priv->var));
if (ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var) < 0) {
- perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
- close (priv->fd);
- return FALSE;
+ perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
+ close(priv->fd);
+ return FALSE;
}
- priv->fb_base = (char *) mmap ((caddr_t) NULL,
- priv->fix.smem_len,
- PROT_READ|PROT_WRITE,
- MAP_SHARED,
- priv->fd, 0);
+ priv->fb_base = (char *) mmap((caddr_t) NULL,
+ priv->fix.smem_len,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, priv->fd, 0);
- if (priv->fb_base == (char *)-1)
- {
+ if (priv->fb_base == (char *) -1) {
perror("ERROR: mmap framebuffer fails!");
- close (priv->fd);
- return FALSE;
+ close(priv->fd);
+ return FALSE;
}
off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize();
priv->fb = priv->fb_base + off;
@@ -80,18 +77,17 @@ fbdevInitialize (KdCardInfo *card, FbdevPriv *priv)
}
Bool
-fbdevCardInit (KdCardInfo *card)
+fbdevCardInit(KdCardInfo * card)
{
- FbdevPriv *priv;
+ FbdevPriv *priv;
- priv = (FbdevPriv *) malloc(sizeof (FbdevPriv));
+ priv = (FbdevPriv *) malloc(sizeof(FbdevPriv));
if (!priv)
- return FALSE;
+ return FALSE;
- if (!fbdevInitialize (card, priv))
- {
- free(priv);
- return FALSE;
+ if (!fbdevInitialize(card, priv)) {
+ free(priv);
+ return FALSE;
}
card->driver = priv;
@@ -99,30 +95,29 @@ fbdevCardInit (KdCardInfo *card)
}
static Pixel
-fbdevMakeContig (Pixel orig, Pixel others)
+fbdevMakeContig(Pixel orig, Pixel others)
{
- Pixel low;
+ Pixel low;
- low = lowbit (orig) >> 1;
- while (low && (others & low) == 0)
- {
- orig |= low;
- low >>= 1;
+ low = lowbit(orig) >> 1;
+ while (low && (others & low) == 0) {
+ orig |= low;
+ low >>= 1;
}
return orig;
}
static Bool
-fbdevModeSupported (KdScreenInfo *screen,
- const KdMonitorTiming *t)
+fbdevModeSupported(KdScreenInfo * screen, const KdMonitorTiming * t)
{
return TRUE;
}
static void
-fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *var)
+fbdevConvertMonitorTiming(const KdMonitorTiming * t,
+ struct fb_var_screeninfo *var)
{
- memset (var, 0, sizeof (struct fb_var_screeninfo));
+ memset(var, 0, sizeof(struct fb_var_screeninfo));
var->xres = t->horizontal;
var->yres = t->vertical;
@@ -142,56 +137,51 @@ fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *v
var->vmode = 0;
if (t->hpol == KdSyncPositive)
- var->sync |= FB_SYNC_HOR_HIGH_ACT;
+ var->sync |= FB_SYNC_HOR_HIGH_ACT;
if (t->vpol == KdSyncPositive)
- var->sync |= FB_SYNC_VERT_HIGH_ACT;
+ var->sync |= FB_SYNC_VERT_HIGH_ACT;
}
static Bool
-fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
+fbdevScreenInitialize(KdScreenInfo * screen, FbdevScrPriv * scrpriv)
{
- FbdevPriv *priv = screen->card->driver;
- Pixel allbits;
- int depth;
- Bool gray;
+ FbdevPriv *priv = screen->card->driver;
+ Pixel allbits;
+ int depth;
+ Bool gray;
struct fb_var_screeninfo var;
const KdMonitorTiming *t;
int k;
- k = ioctl (priv->fd, FBIOGET_VSCREENINFO, &var);
-
- if (!screen->width || !screen->height)
- {
- if (k >= 0)
- {
- screen->width = var.xres;
- screen->height = var.yres;
- }
- else
- {
- screen->width = 1024;
- screen->height = 768;
- }
- screen->rate = 103; /* FIXME: should get proper value from fb driver */
+ k = ioctl(priv->fd, FBIOGET_VSCREENINFO, &var);
+
+ if (!screen->width || !screen->height) {
+ if (k >= 0) {
+ screen->width = var.xres;
+ screen->height = var.yres;
+ }
+ else {
+ screen->width = 1024;
+ screen->height = 768;
+ }
+ screen->rate = 103; /* FIXME: should get proper value from fb driver */
}
- if (!screen->fb.depth)
- {
- if (k >= 0)
- screen->fb.depth = var.bits_per_pixel;
- else
- screen->fb.depth = 16;
+ if (!screen->fb.depth) {
+ if (k >= 0)
+ screen->fb.depth = var.bits_per_pixel;
+ else
+ screen->fb.depth = 16;
}
- if ((screen->width != var.xres) || (screen->height != var.yres))
- {
- t = KdFindMode (screen, fbdevModeSupported);
- screen->rate = t->rate;
- screen->width = t->horizontal;
- screen->height = t->vertical;
+ if ((screen->width != var.xres) || (screen->height != var.yres)) {
+ t = KdFindMode(screen, fbdevModeSupported);
+ screen->rate = t->rate;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
- /* Now try setting the mode */
- if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres))
- fbdevConvertMonitorTiming (t, &var);
+ /* Now try setting the mode */
+ if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres))
+ fbdevConvertMonitorTiming(t, &var);
}
var.activate = FB_ACTIVATE_NOW;
@@ -199,163 +189,154 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
var.nonstd = 0;
var.grayscale = 0;
- k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &var);
+ k = ioctl(priv->fd, FBIOPUT_VSCREENINFO, &var);
- if (k < 0)
- {
- fprintf (stderr, "error: %s\n", strerror (errno));
- return FALSE;
+ if (k < 0) {
+ fprintf(stderr, "error: %s\n", strerror(errno));
+ return FALSE;
}
/* Re-get the "fixed" parameters since they might have changed */
- k = ioctl (priv->fd, FBIOGET_FSCREENINFO, &priv->fix);
+ k = ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix);
if (k < 0)
- perror ("FBIOGET_FSCREENINFO");
+ perror("FBIOGET_FSCREENINFO");
/* Now get the new screeninfo */
- ioctl (priv->fd, FBIOGET_VSCREENINFO, &priv->var);
+ ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var);
depth = priv->var.bits_per_pixel;
gray = priv->var.grayscale;
switch (priv->fix.visual) {
case FB_VISUAL_PSEUDOCOLOR:
- if (gray)
- {
- screen->fb.visuals = (1 << StaticGray);
- /* could also support GrayScale, but what's the point? */
- }
- else
- {
- screen->fb.visuals = ((1 << StaticGray) |
- (1 << GrayScale) |
- (1 << StaticColor) |
- (1 << PseudoColor) |
- (1 << TrueColor) |
- (1 << DirectColor));
- }
- screen->fb.blueMask = 0x00;
- screen->fb.greenMask = 0x00;
- screen->fb.redMask = 0x00;
- break;
+ if (gray) {
+ screen->fb.visuals = (1 << StaticGray);
+ /* could also support GrayScale, but what's the point? */
+ }
+ else {
+ screen->fb.visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) | (1 << DirectColor));
+ }
+ screen->fb.blueMask = 0x00;
+ screen->fb.greenMask = 0x00;
+ screen->fb.redMask = 0x00;
+ break;
case FB_VISUAL_STATIC_PSEUDOCOLOR:
- if (gray)
- {
- screen->fb.visuals = (1 << StaticGray);
- }
- else
- {
- screen->fb.visuals = (1 << StaticColor);
- }
- screen->fb.blueMask = 0x00;
- screen->fb.greenMask = 0x00;
- screen->fb.redMask = 0x00;
- break;
+ if (gray) {
+ screen->fb.visuals = (1 << StaticGray);
+ }
+ else {
+ screen->fb.visuals = (1 << StaticColor);
+ }
+ screen->fb.blueMask = 0x00;
+ screen->fb.greenMask = 0x00;
+ screen->fb.redMask = 0x00;
+ break;
case FB_VISUAL_TRUECOLOR:
case FB_VISUAL_DIRECTCOLOR:
- screen->fb.visuals = (1 << TrueColor);
+ screen->fb.visuals = (1 << TrueColor);
#define Mask(o,l) (((1 << l) - 1) << o)
- screen->fb.redMask = Mask (priv->var.red.offset, priv->var.red.length);
- screen->fb.greenMask = Mask (priv->var.green.offset, priv->var.green.length);
- screen->fb.blueMask = Mask (priv->var.blue.offset, priv->var.blue.length);
-
- /*
- * This is a kludge so that Render will work -- fill in the gaps
- * in the pixel
- */
- screen->fb.redMask = fbdevMakeContig (screen->fb.redMask,
- screen->fb.greenMask|
- screen->fb.blueMask);
-
- screen->fb.greenMask = fbdevMakeContig (screen->fb.greenMask,
- screen->fb.redMask|
- screen->fb.blueMask);
-
- screen->fb.blueMask = fbdevMakeContig (screen->fb.blueMask,
- screen->fb.redMask|
- screen->fb.greenMask);
-
- allbits = screen->fb.redMask | screen->fb.greenMask | screen->fb.blueMask;
- depth = 32;
- while (depth && !(allbits & (1 << (depth - 1))))
- depth--;
- break;
+ screen->fb.redMask = Mask (priv->var.red.offset, priv->var.red.length);
+ screen->fb.greenMask =
+ Mask (priv->var.green.offset, priv->var.green.length);
+ screen->fb.blueMask =
+ Mask (priv->var.blue.offset, priv->var.blue.length);
+
+ /*
+ * This is a kludge so that Render will work -- fill in the gaps
+ * in the pixel
+ */
+ screen->fb.redMask = fbdevMakeContig(screen->fb.redMask,
+ screen->fb.greenMask |
+ screen->fb.blueMask);
+
+ screen->fb.greenMask = fbdevMakeContig(screen->fb.greenMask,
+ screen->fb.redMask |
+ screen->fb.blueMask);
+
+ screen->fb.blueMask = fbdevMakeContig(screen->fb.blueMask,
+ screen->fb.redMask |
+ screen->fb.greenMask);
+
+ allbits =
+ screen->fb.redMask | screen->fb.greenMask | screen->fb.blueMask;
+ depth = 32;
+ while (depth && !(allbits & (1 << (depth - 1))))
+ depth--;
+ break;
default:
- return FALSE;
- break;
+ return FALSE;
+ break;
}
screen->fb.depth = depth;
screen->fb.bitsPerPixel = priv->var.bits_per_pixel;
scrpriv->randr = screen->randr;
- return fbdevMapFramebuffer (screen);
+ return fbdevMapFramebuffer(screen);
}
Bool
-fbdevScreenInit (KdScreenInfo *screen)
+fbdevScreenInit(KdScreenInfo * screen)
{
FbdevScrPriv *scrpriv;
- scrpriv = calloc(1, sizeof (FbdevScrPriv));
+ scrpriv = calloc(1, sizeof(FbdevScrPriv));
if (!scrpriv)
- return FALSE;
+ return FALSE;
screen->driver = scrpriv;
- if (!fbdevScreenInitialize (screen, scrpriv))
- {
- screen->driver = 0;
- free(scrpriv);
- return FALSE;
+ if (!fbdevScreenInitialize(screen, scrpriv)) {
+ screen->driver = 0;
+ free(scrpriv);
+ return FALSE;
}
return TRUE;
}
static void *
-fbdevWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure)
+fbdevWindowLinear(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset, int mode, CARD32 *size, void *closure)
{
KdScreenPriv(pScreen);
- FbdevPriv *priv = pScreenPriv->card->driver;
+ FbdevPriv *priv = pScreenPriv->card->driver;
if (!pScreenPriv->enabled)
- return 0;
+ return 0;
*size = priv->fix.line_length;
return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
}
Bool
-fbdevMapFramebuffer (KdScreenInfo *screen)
+fbdevMapFramebuffer(KdScreenInfo * screen)
{
- FbdevScrPriv *scrpriv = screen->driver;
- KdPointerMatrix m;
- FbdevPriv *priv = screen->card->driver;
+ FbdevScrPriv *scrpriv = screen->driver;
+ KdPointerMatrix m;
+ FbdevPriv *priv = screen->card->driver;
if (scrpriv->randr != RR_Rotate_0)
- scrpriv->shadow = TRUE;
+ scrpriv->shadow = TRUE;
else
- scrpriv->shadow = FALSE;
+ scrpriv->shadow = FALSE;
- KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+ KdComputePointerMatrix(&m, scrpriv->randr, screen->width, screen->height);
- KdSetPointerMatrix (&m);
+ KdSetPointerMatrix(&m);
screen->width = priv->var.xres;
screen->height = priv->var.yres;
- if (scrpriv->shadow)
- {
- if (!KdShadowFbAlloc (screen,
- scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
- return FALSE;
+ if (scrpriv->shadow) {
+ if (!KdShadowFbAlloc(screen,
+ scrpriv->randr & (RR_Rotate_90 | RR_Rotate_270)))
+ return FALSE;
}
- else
- {
+ else {
screen->fb.byteStride = priv->fix.line_length;
screen->fb.pixelStride = (priv->fix.line_length * 8 /
- priv->var.bits_per_pixel);
+ priv->var.bits_per_pixel);
screen->fb.frameBuffer = (CARD8 *) (priv->fb);
}
@@ -363,46 +344,44 @@ fbdevMapFramebuffer (KdScreenInfo *screen)
}
static void
-fbdevSetScreenSizes (ScreenPtr pScreen)
+fbdevSetScreenSizes(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FbdevScrPriv *scrpriv = screen->driver;
- FbdevPriv *priv = screen->card->driver;
-
- if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- pScreen->width = priv->var.xres;
- pScreen->height = priv->var.yres;
- pScreen->mmWidth = screen->width_mm;
- pScreen->mmHeight = screen->height_mm;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ FbdevPriv *priv = screen->card->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0 | RR_Rotate_180)) {
+ pScreen->width = priv->var.xres;
+ pScreen->height = priv->var.yres;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
}
- else
- {
- pScreen->width = priv->var.yres;
- pScreen->height = priv->var.xres;
- pScreen->mmWidth = screen->height_mm;
- pScreen->mmHeight = screen->width_mm;
+ else {
+ pScreen->width = priv->var.yres;
+ pScreen->height = priv->var.xres;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
}
}
static Bool
-fbdevUnmapFramebuffer (KdScreenInfo *screen)
+fbdevUnmapFramebuffer(KdScreenInfo * screen)
{
- KdShadowFbFree (screen);
+ KdShadowFbFree(screen);
return TRUE;
}
static Bool
-fbdevSetShadow (ScreenPtr pScreen)
+fbdevSetShadow(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FbdevScrPriv *scrpriv = screen->driver;
- FbdevPriv *priv = screen->card->driver;
- ShadowUpdateProc update;
- ShadowWindowProc window;
- int useYX = 0;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ FbdevPriv *priv = screen->card->driver;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+ int useYX = 0;
#ifdef __arm__
/* Use variant copy routines that always read left to right in the
@@ -414,97 +393,91 @@ fbdevSetShadow (ScreenPtr pScreen)
window = fbdevWindowLinear;
update = 0;
if (scrpriv->randr)
- if (priv->var.bits_per_pixel == 16) {
- switch (scrpriv->randr) {
- case RR_Rotate_90:
- if (useYX)
- update = shadowUpdateRotate16_90YX;
- else
- update = shadowUpdateRotate16_90;
- break;
- case RR_Rotate_180:
- update = shadowUpdateRotate16_180;
- break;
- case RR_Rotate_270:
- if (useYX)
- update = shadowUpdateRotate16_270YX;
- else
- update = shadowUpdateRotate16_270;
- break;
- default:
- update = shadowUpdateRotate16;
- break;
- }
- } else
- update = shadowUpdateRotatePacked;
+ if (priv->var.bits_per_pixel == 16) {
+ switch (scrpriv->randr) {
+ case RR_Rotate_90:
+ if (useYX)
+ update = shadowUpdateRotate16_90YX;
+ else
+ update = shadowUpdateRotate16_90;
+ break;
+ case RR_Rotate_180:
+ update = shadowUpdateRotate16_180;
+ break;
+ case RR_Rotate_270:
+ if (useYX)
+ update = shadowUpdateRotate16_270YX;
+ else
+ update = shadowUpdateRotate16_270;
+ break;
+ default:
+ update = shadowUpdateRotate16;
+ break;
+ }
+ }
+ else
+ update = shadowUpdateRotatePacked;
else
- update = shadowUpdatePacked;
- return KdShadowSet (pScreen, scrpriv->randr, update, window);
+ update = shadowUpdatePacked;
+ return KdShadowSet(pScreen, scrpriv->randr, update, window);
}
-
#ifdef RANDR
static Bool
-fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+fbdevRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FbdevScrPriv *scrpriv = screen->driver;
- RRScreenSizePtr pSize;
- Rotation randr;
- int n;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n;
- *rotations = RR_Rotate_All|RR_Reflect_All;
+ *rotations = RR_Rotate_All | RR_Reflect_All;
for (n = 0; n < pScreen->numDepths; n++)
- if (pScreen->allowedDepths[n].numVids)
- break;
+ if (pScreen->allowedDepths[n].numVids)
+ break;
if (n == pScreen->numDepths)
- return FALSE;
+ return FALSE;
- pSize = RRRegisterSize (pScreen,
- screen->width,
- screen->height,
- screen->width_mm,
- screen->height_mm);
+ pSize = RRRegisterSize(pScreen,
+ screen->width,
+ screen->height, screen->width_mm, screen->height_mm);
- randr = KdSubRotation (scrpriv->randr, screen->randr);
+ randr = KdSubRotation(scrpriv->randr, screen->randr);
- RRSetCurrentConfig (pScreen, randr, 0, pSize);
+ RRSetCurrentConfig(pScreen, randr, 0, pSize);
return TRUE;
}
static Bool
-fbdevRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize)
+fbdevRandRSetConfig(ScreenPtr pScreen,
+ Rotation randr, int rate, RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- FbdevScrPriv *scrpriv = screen->driver;
- Bool wasEnabled = pScreenPriv->enabled;
- FbdevScrPriv oldscr;
- int oldwidth;
- int oldheight;
- int oldmmwidth;
- int oldmmheight;
- int newwidth, newheight;
-
- if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
- {
- newwidth = pSize->width;
- newheight = pSize->height;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ FbdevScrPriv oldscr;
+ int oldwidth;
+ int oldheight;
+ int oldmmwidth;
+ int oldmmheight;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0 | RR_Rotate_180)) {
+ newwidth = pSize->width;
+ newheight = pSize->height;
}
- else
- {
- newwidth = pSize->height;
- newheight = pSize->width;
+ else {
+ newwidth = pSize->height;
+ newheight = pSize->width;
}
if (wasEnabled)
- KdDisableScreen (pScreen);
+ KdDisableScreen(pScreen);
oldscr = *scrpriv;
@@ -517,60 +490,60 @@ fbdevRandRSetConfig (ScreenPtr pScreen,
* Set new configuration
*/
- scrpriv->randr = KdAddRotation (screen->randr, randr);
+ scrpriv->randr = KdAddRotation(screen->randr, randr);
- fbdevUnmapFramebuffer (screen);
+ fbdevUnmapFramebuffer(screen);
- if (!fbdevMapFramebuffer (screen))
- goto bail4;
+ if (!fbdevMapFramebuffer(screen))
+ goto bail4;
- KdShadowUnset (screen->pScreen);
+ KdShadowUnset(screen->pScreen);
- if (!fbdevSetShadow (screen->pScreen))
- goto bail4;
+ if (!fbdevSetShadow(screen->pScreen))
+ goto bail4;
- fbdevSetScreenSizes (screen->pScreen);
+ fbdevSetScreenSizes(screen->pScreen);
/*
* Set frame buffer mapping
*/
- (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
- pScreen->width,
- pScreen->height,
- screen->fb.depth,
- screen->fb.bitsPerPixel,
- screen->fb.byteStride,
- screen->fb.frameBuffer);
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap(pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb.depth,
+ screen->fb.bitsPerPixel,
+ screen->fb.byteStride,
+ screen->fb.frameBuffer);
/* set the subpixel order */
- KdSetSubpixelOrder (pScreen, scrpriv->randr);
+ KdSetSubpixelOrder(pScreen, scrpriv->randr);
if (wasEnabled)
- KdEnableScreen (pScreen);
+ KdEnableScreen(pScreen);
return TRUE;
-bail4:
- fbdevUnmapFramebuffer (screen);
+ bail4:
+ fbdevUnmapFramebuffer(screen);
*scrpriv = oldscr;
- (void) fbdevMapFramebuffer (screen);
+ (void) fbdevMapFramebuffer(screen);
pScreen->width = oldwidth;
pScreen->height = oldheight;
pScreen->mmWidth = oldmmwidth;
pScreen->mmHeight = oldmmheight;
if (wasEnabled)
- KdEnableScreen (pScreen);
+ KdEnableScreen(pScreen);
return FALSE;
}
static Bool
-fbdevRandRInit (ScreenPtr pScreen)
+fbdevRandRInit(ScreenPtr pScreen)
{
- rrScrPrivPtr pScrPriv;
+ rrScrPrivPtr pScrPriv;
- if (!RRScreenInit (pScreen))
- return FALSE;
+ if (!RRScreenInit(pScreen))
+ return FALSE;
pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = fbdevRandRGetInfo;
@@ -580,41 +553,41 @@ fbdevRandRInit (ScreenPtr pScreen)
#endif
static Bool
-fbdevCreateColormap (ColormapPtr pmap)
+fbdevCreateColormap(ColormapPtr pmap)
{
- ScreenPtr pScreen = pmap->pScreen;
+ ScreenPtr pScreen = pmap->pScreen;
+
KdScreenPriv(pScreen);
- FbdevPriv *priv = pScreenPriv->card->driver;
- VisualPtr pVisual;
- int i;
- int nent;
- xColorItem *pdefs;
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ VisualPtr pVisual;
+ int i;
+ int nent;
+ xColorItem *pdefs;
switch (priv->fix.visual) {
case FB_VISUAL_STATIC_PSEUDOCOLOR:
- pVisual = pmap->pVisual;
- nent = pVisual->ColormapEntries;
- pdefs = malloc(nent * sizeof (xColorItem));
- if (!pdefs)
- return FALSE;
- for (i = 0; i < nent; i++)
- pdefs[i].pixel = i;
- fbdevGetColors (pScreen, nent, pdefs);
- for (i = 0; i < nent; i++)
- {
- pmap->red[i].co.local.red = pdefs[i].red;
- pmap->red[i].co.local.green = pdefs[i].green;
- pmap->red[i].co.local.blue = pdefs[i].blue;
- }
- free(pdefs);
- return TRUE;
+ pVisual = pmap->pVisual;
+ nent = pVisual->ColormapEntries;
+ pdefs = malloc(nent * sizeof(xColorItem));
+ if (!pdefs)
+ return FALSE;
+ for (i = 0; i < nent; i++)
+ pdefs[i].pixel = i;
+ fbdevGetColors(pScreen, nent, pdefs);
+ for (i = 0; i < nent; i++) {
+ pmap->red[i].co.local.red = pdefs[i].red;
+ pmap->red[i].co.local.green = pdefs[i].green;
+ pmap->red[i].co.local.blue = pdefs[i].blue;
+ }
+ free(pdefs);
+ return TRUE;
default:
- return fbInitializeColormap (pmap);
+ return fbInitializeColormap(pmap);
}
}
Bool
-fbdevInitScreen (ScreenPtr pScreen)
+fbdevInitScreen(ScreenPtr pScreen)
{
#ifdef TOUCHSCREEN
KdTsPhyScreen = pScreen->myNum;
@@ -625,33 +598,32 @@ fbdevInitScreen (ScreenPtr pScreen)
}
Bool
-fbdevFinishInitScreen (ScreenPtr pScreen)
+fbdevFinishInitScreen(ScreenPtr pScreen)
{
- if (!shadowSetup (pScreen))
- return FALSE;
+ if (!shadowSetup(pScreen))
+ return FALSE;
#ifdef RANDR
- if (!fbdevRandRInit (pScreen))
- return FALSE;
+ if (!fbdevRandRInit(pScreen))
+ return FALSE;
#endif
return TRUE;
}
-
Bool
-fbdevCreateResources (ScreenPtr pScreen)
+fbdevCreateResources(ScreenPtr pScreen)
{
- return fbdevSetShadow (pScreen);
+ return fbdevSetShadow(pScreen);
}
void
-fbdevPreserve (KdCardInfo *card)
+fbdevPreserve(KdCardInfo * card)
{
}
static int
-fbdevUpdateFbColormap(FbdevPriv *priv, int minidx, int maxidx)
+fbdevUpdateFbColormap(FbdevPriv * priv, int minidx, int maxidx)
{
struct fb_cmap cmap;
@@ -666,89 +638,84 @@ fbdevUpdateFbColormap(FbdevPriv *priv, int minidx, int maxidx)
}
Bool
-fbdevEnable (ScreenPtr pScreen)
+fbdevEnable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- FbdevPriv *priv = pScreenPriv->card->driver;
- int k;
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ int k;
- priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
+ priv->var.activate = FB_ACTIVATE_NOW | FB_CHANGE_CMAP_VBL;
/* display it on the LCD */
- k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
- if (k < 0)
- {
- perror ("FBIOPUT_VSCREENINFO");
- return FALSE;
+ k = ioctl(priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
+ if (k < 0) {
+ perror("FBIOPUT_VSCREENINFO");
+ return FALSE;
}
- if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR)
- {
- int i;
-
- for (i = 0;
- i < (1 << priv->var.red.length) ||
- i < (1 << priv->var.green.length) ||
- i < (1 << priv->var.blue.length); i++)
- {
- priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
- priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
- priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
- }
-
- fbdevUpdateFbColormap(priv, 0, i);
+ if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) {
+ int i;
+
+ for (i = 0;
+ i < (1 << priv->var.red.length) ||
+ i < (1 << priv->var.green.length) ||
+ i < (1 << priv->var.blue.length); i++) {
+ priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
+ priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
+ priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
+ }
+
+ fbdevUpdateFbColormap(priv, 0, i);
}
return TRUE;
}
Bool
-fbdevDPMS (ScreenPtr pScreen, int mode)
+fbdevDPMS(ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
- FbdevPriv *priv = pScreenPriv->card->driver;
+ FbdevPriv *priv = pScreenPriv->card->driver;
static int oldmode = -1;
if (mode == oldmode)
- return TRUE;
+ return TRUE;
#ifdef FBIOPUT_POWERMODE
- if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0)
- {
- oldmode = mode;
- return TRUE;
+ if (ioctl(priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) {
+ oldmode = mode;
+ return TRUE;
}
#endif
#ifdef FBIOBLANK
- if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0)
- {
- oldmode = mode;
- return TRUE;
+ if (ioctl(priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) {
+ oldmode = mode;
+ return TRUE;
}
#endif
return FALSE;
}
void
-fbdevDisable (ScreenPtr pScreen)
+fbdevDisable(ScreenPtr pScreen)
{
}
void
-fbdevRestore (KdCardInfo *card)
+fbdevRestore(KdCardInfo * card)
{
}
void
-fbdevScreenFini (KdScreenInfo *screen)
+fbdevScreenFini(KdScreenInfo * screen)
{
}
void
-fbdevCardFini (KdCardInfo *card)
+fbdevCardFini(KdCardInfo * card)
{
- FbdevPriv *priv = card->driver;
+ FbdevPriv *priv = card->driver;
- munmap (priv->fb_base, priv->fix.smem_len);
- close (priv->fd);
+ munmap(priv->fb_base, priv->fix.smem_len);
+ close(priv->fd);
free(priv);
}
@@ -756,23 +723,22 @@ fbdevCardFini (KdCardInfo *card)
* Retrieve actual colormap and return selected n entries in pdefs.
*/
void
-fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
+fbdevGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
{
KdScreenPriv(pScreen);
- FbdevPriv *priv = pScreenPriv->card->driver;
- struct fb_cmap cmap;
- int p;
- int k;
- int min, max;
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ struct fb_cmap cmap;
+ int p;
+ int k;
+ int min, max;
min = 256;
max = 0;
- for (k = 0; k < n; k++)
- {
- if (pdefs[k].pixel < min)
- min = pdefs[k].pixel;
- if (pdefs[k].pixel > max)
- max = pdefs[k].pixel;
+ for (k = 0; k < n; k++) {
+ if (pdefs[k].pixel < min)
+ min = pdefs[k].pixel;
+ if (pdefs[k].pixel > max)
+ max = pdefs[k].pixel;
}
cmap.start = min;
cmap.len = max - min + 1;
@@ -780,19 +746,17 @@ fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
cmap.green = &priv->green[min];
cmap.blue = &priv->blue[min];
cmap.transp = 0;
- k = ioctl (priv->fd, FBIOGETCMAP, &cmap);
- if (k < 0)
- {
- perror ("can't get colormap");
- return;
+ k = ioctl(priv->fd, FBIOGETCMAP, &cmap);
+ if (k < 0) {
+ perror("can't get colormap");
+ return;
}
- while (n--)
- {
- p = pdefs->pixel;
- pdefs->red = priv->red[p];
- pdefs->green = priv->green[p];
- pdefs->blue = priv->blue[p];
- pdefs++;
+ while (n--) {
+ p = pdefs->pixel;
+ pdefs->red = priv->red[p];
+ pdefs->green = priv->green[p];
+ pdefs->blue = priv->blue[p];
+ pdefs++;
}
}
@@ -800,26 +764,25 @@ fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
* Change colormap by updating n entries described in pdefs.
*/
void
-fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
+fbdevPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
{
KdScreenPriv(pScreen);
- FbdevPriv *priv = pScreenPriv->card->driver;
- int p;
- int min, max;
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ int p;
+ int min, max;
min = 256;
max = 0;
- while (n--)
- {
- p = pdefs->pixel;
- priv->red[p] = pdefs->red;
- priv->green[p] = pdefs->green;
- priv->blue[p] = pdefs->blue;
- if (p < min)
- min = p;
- if (p > max)
- max = p;
- pdefs++;
+ while (n--) {
+ p = pdefs->pixel;
+ priv->red[p] = pdefs->red;
+ priv->green[p] = pdefs->green;
+ priv->blue[p] = pdefs->blue;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+ pdefs++;
}
fbdevUpdateFbColormap(priv, min, max);
diff --git a/xorg-server/hw/kdrive/fbdev/fbinit.c b/xorg-server/hw/kdrive/fbdev/fbinit.c
index 1d66fce32..d2a14019d 100644
--- a/xorg-server/hw/kdrive/fbdev/fbinit.c
+++ b/xorg-server/hw/kdrive/fbdev/fbinit.c
@@ -26,82 +26,80 @@
#include <fbdev.h>
void
-InitCard (char *name)
+InitCard(char *name)
{
- KdCardInfoAdd (&fbdevFuncs, 0);
+ KdCardInfoAdd(&fbdevFuncs, 0);
}
void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{
- KdInitOutput (pScreenInfo, argc, argv);
+ KdInitOutput(pScreenInfo, argc, argv);
}
void
-InitInput (int argc, char **argv)
+InitInput(int argc, char **argv)
{
- KdOsAddInputDrivers ();
- KdInitInput ();
+ KdOsAddInputDrivers();
+ KdInitInput();
}
void
-CloseInput (void)
+CloseInput(void)
{
- KdCloseInput ();
+ KdCloseInput();
}
void
-ddxUseMsg (void)
+ddxUseMsg(void)
{
- KdUseMsg();
- ErrorF("\nXfbdev Device Usage:\n");
- ErrorF("-fb path Framebuffer device to use. Defaults to /dev/fb0\n");
- ErrorF("\n");
+ KdUseMsg();
+ ErrorF("\nXfbdev Device Usage:\n");
+ ErrorF
+ ("-fb path Framebuffer device to use. Defaults to /dev/fb0\n");
+ ErrorF("\n");
}
int
-ddxProcessArgument (int argc, char **argv, int i)
+ddxProcessArgument(int argc, char **argv, int i)
{
- if (!strcmp (argv[i], "-fb"))
- {
- if (i+1 < argc)
- {
- fbdevDevicePath = argv[i+1];
- return 2;
- }
- UseMsg();
- exit(1);
+ if (!strcmp(argv[i], "-fb")) {
+ if (i + 1 < argc) {
+ fbdevDevicePath = argv[i + 1];
+ return 2;
+ }
+ UseMsg();
+ exit(1);
}
- return KdProcessArgument (argc, argv, i);
+ return KdProcessArgument(argc, argv, i);
}
+KdCardFuncs fbdevFuncs = {
+ fbdevCardInit, /* cardinit */
+ fbdevScreenInit, /* scrinit */
+ fbdevInitScreen, /* initScreen */
+ fbdevFinishInitScreen, /* finishInitScreen */
+ fbdevCreateResources, /* createRes */
+ fbdevPreserve, /* preserve */
+ fbdevEnable, /* enable */
+ fbdevDPMS, /* dpms */
+ fbdevDisable, /* disable */
+ fbdevRestore, /* restore */
+ fbdevScreenFini, /* scrfini */
+ fbdevCardFini, /* cardfini */
-KdCardFuncs fbdevFuncs = {
- fbdevCardInit, /* cardinit */
- fbdevScreenInit, /* scrinit */
- fbdevInitScreen, /* initScreen */
- fbdevFinishInitScreen, /* finishInitScreen */
- fbdevCreateResources, /* createRes */
- fbdevPreserve, /* preserve */
- fbdevEnable, /* enable */
- fbdevDPMS, /* dpms */
- fbdevDisable, /* disable */
- fbdevRestore, /* restore */
- fbdevScreenFini, /* scrfini */
- fbdevCardFini, /* cardfini */
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
- 0, /* initCursor */
- 0, /* enableCursor */
- 0, /* disableCursor */
- 0, /* finiCursor */
- 0, /* recolorCursor */
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
- 0, /* initAccel */
- 0, /* enableAccel */
- 0, /* disableAccel */
- 0, /* finiAccel */
-
- fbdevGetColors, /* getColors */
- fbdevPutColors, /* putColors */
+ fbdevGetColors, /* getColors */
+ fbdevPutColors, /* putColors */
};
diff --git a/xorg-server/hw/kdrive/linux/evdev.c b/xorg-server/hw/kdrive/linux/evdev.c
index 20df77b99..9982fad36 100644
--- a/xorg-server/hw/kdrive/linux/evdev.c
+++ b/xorg-server/hw/kdrive/linux/evdev.c
@@ -1,539 +1,519 @@
-/*
- * Copyright © 2004 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include <errno.h>
-#include <linux/input.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/Xpoll.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "kdrive.h"
-
-#define NUM_EVENTS 128
-#define ABS_UNSET -65535
-
-#define BITS_PER_LONG (sizeof(long) * 8)
-#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
-#define ISBITSET(x,y) ((x)[LONG(y)] & BIT(y))
-#define OFF(x) ((x)%BITS_PER_LONG)
-#define LONG(x) ((x)/BITS_PER_LONG)
-#define BIT(x) (1 << OFF(x))
-
-typedef struct _kevdev {
- /* current device state */
- int rel[REL_MAX + 1];
- int abs[ABS_MAX + 1];
- int prevabs[ABS_MAX + 1];
- long key[NBITS(KEY_MAX + 1)];
-
- /* supported device info */
- long relbits[NBITS(REL_MAX + 1)];
- long absbits[NBITS(ABS_MAX + 1)];
- long keybits[NBITS(KEY_MAX + 1)];
- struct input_absinfo absinfo[ABS_MAX + 1];
- int max_rel;
- int max_abs;
-
- int fd;
-} Kevdev;
-
-static void
-EvdevPtrBtn (KdPointerInfo *pi, struct input_event *ev)
-{
- int flags = KD_MOUSE_DELTA | pi->buttonState;
-
- if (ev->code >= BTN_MOUSE && ev->code < BTN_JOYSTICK) {
- switch (ev->code) {
- case BTN_LEFT:
- if (ev->value == 1)
- flags |= KD_BUTTON_1;
- else
- flags &= ~KD_BUTTON_1;
- break;
- case BTN_MIDDLE:
- if (ev->value == 1)
- flags |= KD_BUTTON_2;
- else
- flags &= ~KD_BUTTON_2;
- break;
- case BTN_RIGHT:
- if (ev->value == 1)
- flags |= KD_BUTTON_3;
- else
- flags &= ~KD_BUTTON_3;
- break;
- default:
- /* Unknow button */
- break;
- }
-
- KdEnqueuePointerEvent (pi, flags, 0, 0, 0);
- }
-}
-static void
-EvdevPtrMotion (KdPointerInfo *pi, struct input_event *ev)
-{
- Kevdev *ke = pi->driverPrivate;
- int i;
- int flags = KD_MOUSE_DELTA | pi->buttonState;
-
- for (i = 0; i <= ke->max_rel; i++)
- if (ke->rel[i])
- {
- int a;
- for (a = 0; a <= ke->max_rel; a++)
- {
- if (ISBITSET (ke->relbits, a))
- {
- if (a == 0)
- KdEnqueuePointerEvent(pi, flags, ke->rel[a], 0, 0);
- else if (a == 1)
- KdEnqueuePointerEvent(pi, flags, 0, ke->rel[a], 0);
- }
- ke->rel[a] = 0;
- }
- break;
- }
- for (i = 0; i < ke->max_abs; i++)
- if (ke->abs[i] != ke->prevabs[i])
- {
- int a;
- ErrorF ("abs");
- for (a = 0; a <= ke->max_abs; a++)
- {
- if (ISBITSET (ke->absbits, a))
- ErrorF (" %d=%d", a, ke->abs[a]);
- ke->prevabs[a] = ke->abs[a];
- }
- ErrorF ("\n");
- break;
- }
-
- if (ev->code == REL_WHEEL) {
- for (i = 0; i < abs (ev->value); i++)
- {
- if (ev->value > 0)
- flags |= KD_BUTTON_4;
- else
- flags |= KD_BUTTON_5;
-
- KdEnqueuePointerEvent (pi, flags, 0, 0, 0);
-
- if (ev->value > 0)
- flags &= ~KD_BUTTON_4;
- else
- flags &= ~KD_BUTTON_5;
-
- KdEnqueuePointerEvent (pi, flags, 0, 0, 0);
- }
- }
-
-}
-
-static void
-EvdevPtrRead (int evdevPort, void *closure)
-{
- KdPointerInfo *pi = closure;
- Kevdev *ke = pi->driverPrivate;
- int i;
- struct input_event events[NUM_EVENTS];
- int n;
-
- n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
- if (n <= 0) {
- if (errno == ENODEV)
- DeleteInputDeviceRequest(pi->dixdev);
- return;
- }
-
- n /= sizeof (struct input_event);
- for (i = 0; i < n; i++)
- {
- switch (events[i].type) {
- case EV_SYN:
- break;
- case EV_KEY:
- EvdevPtrBtn (pi, &events[i]);
- break;
- case EV_REL:
- ke->rel[events[i].code] += events[i].value;
- EvdevPtrMotion (pi, &events[i]);
- break;
- case EV_ABS:
- ke->abs[events[i].code] = events[i].value;
- EvdevPtrMotion (pi, &events[i]);
- break;
- }
- }
-}
-
-char *kdefaultEvdev[] = {
- "/dev/input/event0",
- "/dev/input/event1",
- "/dev/input/event2",
- "/dev/input/event3",
-};
-
-#define NUM_DEFAULT_EVDEV (sizeof (kdefaultEvdev) / sizeof (kdefaultEvdev[0]))
-
-static Status
-EvdevPtrInit (KdPointerInfo *pi)
-{
- int i;
- int fd;
-
- if (!pi->path) {
- for (i = 0; i < NUM_DEFAULT_EVDEV; i++) {
- fd = open (kdefaultEvdev[i], 2);
- if (fd >= 0) {
- pi->path = strdup (kdefaultEvdev[i]);
- break;
- }
- }
- }
- else {
- fd = open (pi->path, O_RDWR);
- if (fd < 0) {
- ErrorF("Failed to open evdev device %s\n", pi->path);
- return BadMatch;
- }
- }
-
- close(fd);
-
- pi->name = strdup("Evdev mouse");
-
- return Success;
-}
-
-static Status
-EvdevPtrEnable (KdPointerInfo *pi)
-{
- int fd;
- unsigned long ev[NBITS(EV_MAX)];
- Kevdev *ke;
-
- if (!pi || !pi->path)
- return BadImplementation;
-
- fd = open(pi->path, 2);
- if (fd < 0)
- return BadMatch;
-
- if (ioctl (fd, EVIOCGRAB, 1) < 0)
- perror ("Grabbing evdev mouse device failed");
-
- if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
- {
- perror ("EVIOCGBIT 0");
- close (fd);
- return BadMatch;
- }
- ke = calloc(1, sizeof (Kevdev));
- if (!ke)
- {
- close (fd);
- return BadAlloc;
- }
- if (ISBITSET (ev, EV_KEY))
- {
- if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
- ke->keybits) < 0)
- {
- perror ("EVIOCGBIT EV_KEY");
- free(ke);
- close (fd);
- return BadMatch;
- }
- }
- if (ISBITSET (ev, EV_REL))
- {
- if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
- ke->relbits) < 0)
- {
- perror ("EVIOCGBIT EV_REL");
- free(ke);
- close (fd);
- return BadMatch;
- }
- for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
- if (ISBITSET(ke->relbits, ke->max_rel))
- break;
- }
- if (ISBITSET (ev, EV_ABS))
- {
- int i;
-
- if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
- ke->absbits) < 0)
- {
- perror ("EVIOCGBIT EV_ABS");
- free(ke);
- close (fd);
- return BadMatch;
- }
- for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
- if (ISBITSET(ke->absbits, ke->max_abs))
- break;
- for (i = 0; i <= ke->max_abs; i++)
- {
- if (ISBITSET (ke->absbits, i))
- if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
- {
- perror ("EVIOCGABS");
- break;
- }
- ke->prevabs[i] = ABS_UNSET;
- }
- if (i <= ke->max_abs)
- {
- free(ke);
- close (fd);
- return BadValue;
- }
- }
- if (!KdRegisterFd (fd, EvdevPtrRead, pi)) {
- free(ke);
- close (fd);
- return BadAlloc;
- }
- pi->driverPrivate = ke;
- ke->fd = fd;
-
- return Success;
-}
-
-static void
-EvdevPtrDisable (KdPointerInfo *pi)
-{
- Kevdev *ke;
-
- ke = pi->driverPrivate;
-
- if (!pi || !pi->driverPrivate)
- return;
-
- KdUnregisterFd (pi, ke->fd, TRUE);
-
- if (ioctl (ke->fd, EVIOCGRAB, 0) < 0)
- perror ("Ungrabbing evdev mouse device failed");
-
- free(ke);
- pi->driverPrivate = 0;
-}
-
-static void
-EvdevPtrFini (KdPointerInfo *pi)
-{
-}
-
-
-/*
- * Evdev keyboard functions
- */
-
-static void
-readMapping (KdKeyboardInfo *ki)
-{
- if (!ki)
- return;
-
- ki->minScanCode = 0;
- ki->maxScanCode = 247;
-}
-
-static void
-EvdevKbdRead (int evdevPort, void *closure)
-{
- KdKeyboardInfo *ki = closure;
- struct input_event events[NUM_EVENTS];
- int i, n;
-
- n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
- if (n <= 0) {
- if (errno == ENODEV)
- DeleteInputDeviceRequest(ki->dixdev);
- return;
- }
-
- n /= sizeof (struct input_event);
- for (i = 0; i < n; i++)
- {
- if (events[i].type == EV_KEY)
- KdEnqueueKeyboardEvent (ki, events[i].code, !events[i].value);
-/* FIXME: must implement other types of events
- else
- ErrorF("Event type (%d) not delivered\n", events[i].type);
-*/
- }
-}
-
-static Status
-EvdevKbdInit (KdKeyboardInfo *ki)
-{
- int fd;
-
- if (!ki->path) {
- ErrorF("Couldn't find evdev device path\n");
- return BadValue;
- }
- else {
- fd = open (ki->path, O_RDWR);
- if (fd < 0) {
- ErrorF("Failed to open evdev device %s\n", ki->path);
- return BadMatch;
- }
- }
-
- close (fd);
-
- ki->name = strdup("Evdev keyboard");
-
- readMapping(ki);
-
- return Success;
-}
-
-static Status
-EvdevKbdEnable (KdKeyboardInfo *ki)
-{
- unsigned long ev[NBITS(EV_MAX)];
- Kevdev *ke;
- int fd;
-
- if (!ki || !ki->path)
- return BadImplementation;
-
- fd = open(ki->path, O_RDWR);
- if (fd < 0)
- return BadMatch;
-
- if (ioctl (fd, EVIOCGRAB, 1) < 0)
- perror ("Grabbing evdev keyboard device failed");
-
- if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0) {
- perror ("EVIOCGBIT 0");
- close (fd);
- return BadMatch;
- }
-
- ke = calloc(1, sizeof (Kevdev));
- if (!ke) {
- close (fd);
- return BadAlloc;
- }
-
- if (!KdRegisterFd (fd, EvdevKbdRead, ki)) {
- free(ke);
- close (fd);
- return BadAlloc;
- }
- ki->driverPrivate = ke;
- ke->fd = fd;
-
- return Success;
-}
-
-static void
-EvdevKbdLeds (KdKeyboardInfo *ki, int leds)
-{
-/* struct input_event event;
- Kevdev *ke;
-
- ki->driverPrivate = ke;
-
- memset(&event, 0, sizeof(event));
-
- event.type = EV_LED;
- event.code = LED_CAPSL;
- event.value = leds & (1 << 0) ? 1 : 0;
- write(ke->fd, (char *) &event, sizeof(event));
-
- event.type = EV_LED;
- event.code = LED_NUML;
- event.value = leds & (1 << 1) ? 1 : 0;
- write(ke->fd, (char *) &event, sizeof(event));
-
- event.type = EV_LED;
- event.code = LED_SCROLLL;
- event.value = leds & (1 << 2) ? 1 : 0;
- write(ke->fd, (char *) &event, sizeof(event));
-
- event.type = EV_LED;
- event.code = LED_COMPOSE;
- event.value = leds & (1 << 3) ? 1 : 0;
- write(ke->fd, (char *) &event, sizeof(event));
-*/
-}
-
-static void
-EvdevKbdBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
-{
-}
-
-static void
-EvdevKbdDisable (KdKeyboardInfo *ki)
-{
- Kevdev *ke;
-
- ke = ki->driverPrivate;
-
- if (!ki || !ki->driverPrivate)
- return;
-
- KdUnregisterFd (ki, ke->fd, TRUE);
-
- if (ioctl (ke->fd, EVIOCGRAB, 0) < 0)
- perror ("Ungrabbing evdev keyboard device failed");
-
- free(ke);
- ki->driverPrivate = 0;
-}
-
-static void
-EvdevKbdFini (KdKeyboardInfo *ki)
-{
-}
-
-KdPointerDriver LinuxEvdevMouseDriver = {
- "evdev",
- EvdevPtrInit,
- EvdevPtrEnable,
- EvdevPtrDisable,
- EvdevPtrFini,
- NULL,
-};
-
-KdKeyboardDriver LinuxEvdevKeyboardDriver = {
- "evdev",
- EvdevKbdInit,
- EvdevKbdEnable,
- EvdevKbdLeds,
- EvdevKbdBell,
- EvdevKbdDisable,
- EvdevKbdFini,
- NULL,
-};
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include <errno.h>
+#include <linux/input.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+#define NUM_EVENTS 128
+#define ABS_UNSET -65535
+
+#define BITS_PER_LONG (sizeof(long) * 8)
+#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
+#define ISBITSET(x,y) ((x)[LONG(y)] & BIT(y))
+#define OFF(x) ((x)%BITS_PER_LONG)
+#define LONG(x) ((x)/BITS_PER_LONG)
+#define BIT(x) (1 << OFF(x))
+
+typedef struct _kevdev {
+ /* current device state */
+ int rel[REL_MAX + 1];
+ int abs[ABS_MAX + 1];
+ int prevabs[ABS_MAX + 1];
+ long key[NBITS(KEY_MAX + 1)];
+
+ /* supported device info */
+ long relbits[NBITS(REL_MAX + 1)];
+ long absbits[NBITS(ABS_MAX + 1)];
+ long keybits[NBITS(KEY_MAX + 1)];
+ struct input_absinfo absinfo[ABS_MAX + 1];
+ int max_rel;
+ int max_abs;
+
+ int fd;
+} Kevdev;
+
+static void
+EvdevPtrBtn(KdPointerInfo * pi, struct input_event *ev)
+{
+ int flags = KD_MOUSE_DELTA | pi->buttonState;
+
+ if (ev->code >= BTN_MOUSE && ev->code < BTN_JOYSTICK) {
+ switch (ev->code) {
+ case BTN_LEFT:
+ if (ev->value == 1)
+ flags |= KD_BUTTON_1;
+ else
+ flags &= ~KD_BUTTON_1;
+ break;
+ case BTN_MIDDLE:
+ if (ev->value == 1)
+ flags |= KD_BUTTON_2;
+ else
+ flags &= ~KD_BUTTON_2;
+ break;
+ case BTN_RIGHT:
+ if (ev->value == 1)
+ flags |= KD_BUTTON_3;
+ else
+ flags &= ~KD_BUTTON_3;
+ break;
+ default:
+ /* Unknow button */
+ break;
+ }
+
+ KdEnqueuePointerEvent(pi, flags, 0, 0, 0);
+ }
+}
+
+static void
+EvdevPtrMotion(KdPointerInfo * pi, struct input_event *ev)
+{
+ Kevdev *ke = pi->driverPrivate;
+ int i;
+ int flags = KD_MOUSE_DELTA | pi->buttonState;
+
+ for (i = 0; i <= ke->max_rel; i++)
+ if (ke->rel[i]) {
+ int a;
+
+ for (a = 0; a <= ke->max_rel; a++) {
+ if (ISBITSET(ke->relbits, a)) {
+ if (a == 0)
+ KdEnqueuePointerEvent(pi, flags, ke->rel[a], 0, 0);
+ else if (a == 1)
+ KdEnqueuePointerEvent(pi, flags, 0, ke->rel[a], 0);
+ }
+ ke->rel[a] = 0;
+ }
+ break;
+ }
+ for (i = 0; i < ke->max_abs; i++)
+ if (ke->abs[i] != ke->prevabs[i]) {
+ int a;
+
+ ErrorF("abs");
+ for (a = 0; a <= ke->max_abs; a++) {
+ if (ISBITSET(ke->absbits, a))
+ ErrorF(" %d=%d", a, ke->abs[a]);
+ ke->prevabs[a] = ke->abs[a];
+ }
+ ErrorF("\n");
+ break;
+ }
+
+ if (ev->code == REL_WHEEL) {
+ for (i = 0; i < abs(ev->value); i++) {
+ if (ev->value > 0)
+ flags |= KD_BUTTON_4;
+ else
+ flags |= KD_BUTTON_5;
+
+ KdEnqueuePointerEvent(pi, flags, 0, 0, 0);
+
+ if (ev->value > 0)
+ flags &= ~KD_BUTTON_4;
+ else
+ flags &= ~KD_BUTTON_5;
+
+ KdEnqueuePointerEvent(pi, flags, 0, 0, 0);
+ }
+ }
+
+}
+
+static void
+EvdevPtrRead(int evdevPort, void *closure)
+{
+ KdPointerInfo *pi = closure;
+ Kevdev *ke = pi->driverPrivate;
+ int i;
+ struct input_event events[NUM_EVENTS];
+ int n;
+
+ n = read(evdevPort, &events, NUM_EVENTS * sizeof(struct input_event));
+ if (n <= 0) {
+ if (errno == ENODEV)
+ DeleteInputDeviceRequest(pi->dixdev);
+ return;
+ }
+
+ n /= sizeof(struct input_event);
+ for (i = 0; i < n; i++) {
+ switch (events[i].type) {
+ case EV_SYN:
+ break;
+ case EV_KEY:
+ EvdevPtrBtn(pi, &events[i]);
+ break;
+ case EV_REL:
+ ke->rel[events[i].code] += events[i].value;
+ EvdevPtrMotion(pi, &events[i]);
+ break;
+ case EV_ABS:
+ ke->abs[events[i].code] = events[i].value;
+ EvdevPtrMotion(pi, &events[i]);
+ break;
+ }
+ }
+}
+
+char *kdefaultEvdev[] = {
+ "/dev/input/event0",
+ "/dev/input/event1",
+ "/dev/input/event2",
+ "/dev/input/event3",
+};
+
+#define NUM_DEFAULT_EVDEV (sizeof (kdefaultEvdev) / sizeof (kdefaultEvdev[0]))
+
+static Status
+EvdevPtrInit(KdPointerInfo * pi)
+{
+ int i;
+ int fd;
+
+ if (!pi->path) {
+ for (i = 0; i < NUM_DEFAULT_EVDEV; i++) {
+ fd = open(kdefaultEvdev[i], 2);
+ if (fd >= 0) {
+ pi->path = strdup(kdefaultEvdev[i]);
+ break;
+ }
+ }
+ }
+ else {
+ fd = open(pi->path, O_RDWR);
+ if (fd < 0) {
+ ErrorF("Failed to open evdev device %s\n", pi->path);
+ return BadMatch;
+ }
+ }
+
+ close(fd);
+
+ pi->name = strdup("Evdev mouse");
+
+ return Success;
+}
+
+static Status
+EvdevPtrEnable(KdPointerInfo * pi)
+{
+ int fd;
+ unsigned long ev[NBITS(EV_MAX)];
+ Kevdev *ke;
+
+ if (!pi || !pi->path)
+ return BadImplementation;
+
+ fd = open(pi->path, 2);
+ if (fd < 0)
+ return BadMatch;
+
+ if (ioctl(fd, EVIOCGRAB, 1) < 0)
+ perror("Grabbing evdev mouse device failed");
+
+ if (ioctl(fd, EVIOCGBIT(0 /*EV*/, sizeof(ev)), ev) < 0) {
+ perror("EVIOCGBIT 0");
+ close(fd);
+ return BadMatch;
+ }
+ ke = calloc(1, sizeof(Kevdev));
+ if (!ke) {
+ close(fd);
+ return BadAlloc;
+ }
+ if (ISBITSET(ev, EV_KEY)) {
+ if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(ke->keybits)), ke->keybits) < 0) {
+ perror("EVIOCGBIT EV_KEY");
+ free(ke);
+ close(fd);
+ return BadMatch;
+ }
+ }
+ if (ISBITSET(ev, EV_REL)) {
+ if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(ke->relbits)), ke->relbits) < 0) {
+ perror("EVIOCGBIT EV_REL");
+ free(ke);
+ close(fd);
+ return BadMatch;
+ }
+ for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
+ if (ISBITSET(ke->relbits, ke->max_rel))
+ break;
+ }
+ if (ISBITSET(ev, EV_ABS)) {
+ int i;
+
+ if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(ke->absbits)), ke->absbits) < 0) {
+ perror("EVIOCGBIT EV_ABS");
+ free(ke);
+ close(fd);
+ return BadMatch;
+ }
+ for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
+ if (ISBITSET(ke->absbits, ke->max_abs))
+ break;
+ for (i = 0; i <= ke->max_abs; i++) {
+ if (ISBITSET(ke->absbits, i))
+ if (ioctl(fd, EVIOCGABS(i), &ke->absinfo[i]) < 0) {
+ perror("EVIOCGABS");
+ break;
+ }
+ ke->prevabs[i] = ABS_UNSET;
+ }
+ if (i <= ke->max_abs) {
+ free(ke);
+ close(fd);
+ return BadValue;
+ }
+ }
+ if (!KdRegisterFd(fd, EvdevPtrRead, pi)) {
+ free(ke);
+ close(fd);
+ return BadAlloc;
+ }
+ pi->driverPrivate = ke;
+ ke->fd = fd;
+
+ return Success;
+}
+
+static void
+EvdevPtrDisable(KdPointerInfo * pi)
+{
+ Kevdev *ke;
+
+ ke = pi->driverPrivate;
+
+ if (!pi || !pi->driverPrivate)
+ return;
+
+ KdUnregisterFd(pi, ke->fd, TRUE);
+
+ if (ioctl(ke->fd, EVIOCGRAB, 0) < 0)
+ perror("Ungrabbing evdev mouse device failed");
+
+ free(ke);
+ pi->driverPrivate = 0;
+}
+
+static void
+EvdevPtrFini(KdPointerInfo * pi)
+{
+}
+
+/*
+ * Evdev keyboard functions
+ */
+
+static void
+readMapping(KdKeyboardInfo * ki)
+{
+ if (!ki)
+ return;
+
+ ki->minScanCode = 0;
+ ki->maxScanCode = 247;
+}
+
+static void
+EvdevKbdRead(int evdevPort, void *closure)
+{
+ KdKeyboardInfo *ki = closure;
+ struct input_event events[NUM_EVENTS];
+ int i, n;
+
+ n = read(evdevPort, &events, NUM_EVENTS * sizeof(struct input_event));
+ if (n <= 0) {
+ if (errno == ENODEV)
+ DeleteInputDeviceRequest(ki->dixdev);
+ return;
+ }
+
+ n /= sizeof(struct input_event);
+ for (i = 0; i < n; i++) {
+ if (events[i].type == EV_KEY)
+ KdEnqueueKeyboardEvent(ki, events[i].code, !events[i].value);
+/* FIXME: must implement other types of events
+ else
+ ErrorF("Event type (%d) not delivered\n", events[i].type);
+*/
+ }
+}
+
+static Status
+EvdevKbdInit(KdKeyboardInfo * ki)
+{
+ int fd;
+
+ if (!ki->path) {
+ ErrorF("Couldn't find evdev device path\n");
+ return BadValue;
+ }
+ else {
+ fd = open(ki->path, O_RDWR);
+ if (fd < 0) {
+ ErrorF("Failed to open evdev device %s\n", ki->path);
+ return BadMatch;
+ }
+ }
+
+ close(fd);
+
+ ki->name = strdup("Evdev keyboard");
+
+ readMapping(ki);
+
+ return Success;
+}
+
+static Status
+EvdevKbdEnable(KdKeyboardInfo * ki)
+{
+ unsigned long ev[NBITS(EV_MAX)];
+ Kevdev *ke;
+ int fd;
+
+ if (!ki || !ki->path)
+ return BadImplementation;
+
+ fd = open(ki->path, O_RDWR);
+ if (fd < 0)
+ return BadMatch;
+
+ if (ioctl(fd, EVIOCGRAB, 1) < 0)
+ perror("Grabbing evdev keyboard device failed");
+
+ if (ioctl(fd, EVIOCGBIT(0 /*EV*/, sizeof(ev)), ev) < 0) {
+ perror("EVIOCGBIT 0");
+ close(fd);
+ return BadMatch;
+ }
+
+ ke = calloc(1, sizeof(Kevdev));
+ if (!ke) {
+ close(fd);
+ return BadAlloc;
+ }
+
+ if (!KdRegisterFd(fd, EvdevKbdRead, ki)) {
+ free(ke);
+ close(fd);
+ return BadAlloc;
+ }
+ ki->driverPrivate = ke;
+ ke->fd = fd;
+
+ return Success;
+}
+
+static void
+EvdevKbdLeds(KdKeyboardInfo * ki, int leds)
+{
+/* struct input_event event;
+ Kevdev *ke;
+
+ ki->driverPrivate = ke;
+
+ memset(&event, 0, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_CAPSL;
+ event.value = leds & (1 << 0) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_NUML;
+ event.value = leds & (1 << 1) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_SCROLLL;
+ event.value = leds & (1 << 2) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_COMPOSE;
+ event.value = leds & (1 << 3) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+*/
+}
+
+static void
+EvdevKbdBell(KdKeyboardInfo * ki, int volume, int frequency, int duration)
+{
+}
+
+static void
+EvdevKbdDisable(KdKeyboardInfo * ki)
+{
+ Kevdev *ke;
+
+ ke = ki->driverPrivate;
+
+ if (!ki || !ki->driverPrivate)
+ return;
+
+ KdUnregisterFd(ki, ke->fd, TRUE);
+
+ if (ioctl(ke->fd, EVIOCGRAB, 0) < 0)
+ perror("Ungrabbing evdev keyboard device failed");
+
+ free(ke);
+ ki->driverPrivate = 0;
+}
+
+static void
+EvdevKbdFini(KdKeyboardInfo * ki)
+{
+}
+
+KdPointerDriver LinuxEvdevMouseDriver = {
+ "evdev",
+ EvdevPtrInit,
+ EvdevPtrEnable,
+ EvdevPtrDisable,
+ EvdevPtrFini,
+ NULL,
+};
+
+KdKeyboardDriver LinuxEvdevKeyboardDriver = {
+ "evdev",
+ EvdevKbdInit,
+ EvdevKbdEnable,
+ EvdevKbdLeds,
+ EvdevKbdBell,
+ EvdevKbdDisable,
+ EvdevKbdFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/linux/keyboard.c b/xorg-server/hw/kdrive/linux/keyboard.c
index ba2637b58..9a6ee2d93 100644
--- a/xorg-server/hw/kdrive/linux/keyboard.c
+++ b/xorg-server/hw/kdrive/linux/keyboard.c
@@ -44,70 +44,70 @@
extern int LinuxConsoleFd;
static const KeySym linux_to_x[256] = {
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, XK_Escape,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
- XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
- XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
- XK_comma, XK_minus, XK_period, XK_slash,
- XK_0, XK_1, XK_2, XK_3,
- XK_4, XK_5, XK_6, XK_7,
- XK_8, XK_9, XK_colon, XK_semicolon,
- XK_less, XK_equal, XK_greater, XK_question,
- XK_at, XK_A, XK_B, XK_C,
- XK_D, XK_E, XK_F, XK_G,
- XK_H, XK_I, XK_J, XK_K,
- XK_L, XK_M, XK_N, XK_O,
- XK_P, XK_Q, XK_R, XK_S,
- XK_T, XK_U, XK_V, XK_W,
- XK_X, XK_Y, XK_Z, XK_bracketleft,
- XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
- XK_grave, XK_a, XK_b, XK_c,
- XK_d, XK_e, XK_f, XK_g,
- XK_h, XK_i, XK_j, XK_k,
- XK_l, XK_m, XK_n, XK_o,
- XK_p, XK_q, XK_r, XK_s,
- XK_t, XK_u, XK_v, XK_w,
- XK_x, XK_y, XK_z, XK_braceleft,
- XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
- XK_currency, XK_yen, XK_brokenbar, XK_section,
- XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
- XK_notsign, XK_hyphen, XK_registered, XK_macron,
- XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
- XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
- XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
- XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
- XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
- XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
- XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
- XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
- XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
- XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
- XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
- XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
- XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
- XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
- XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
- XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
- XK_eth, XK_ntilde, XK_ograve, XK_oacute,
- XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
- XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
- XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright, XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace, XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters, XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
};
/*
@@ -135,80 +135,78 @@ static const KeySym linux_to_x[256] = {
corresponds to the Xkb keymap.
*/
#if 0
-static unsigned char at2lnx[] =
-{
- 0x0, /* no valid scancode */
- 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
- 0x03, /* KEY_2 */ 0x04, /* KEY_3 */
- 0x05, /* KEY_4 */ 0x06, /* KEY_5 */
- 0x07, /* KEY_6 */ 0x08, /* KEY_7 */
- 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */
- 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */
- 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */
- 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */
- 0x11, /* KEY_W */ 0x12, /* KEY_E */
- 0x13, /* KEY_R */ 0x14, /* KEY_T */
- 0x15, /* KEY_Y */ 0x16, /* KEY_U */
- 0x17, /* KEY_I */ 0x18, /* KEY_O */
- 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */
- 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */
- 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */
- 0x1f, /* KEY_S */ 0x20, /* KEY_D */
- 0x21, /* KEY_F */ 0x22, /* KEY_G */
- 0x23, /* KEY_H */ 0x24, /* KEY_J */
- 0x25, /* KEY_K */ 0x26, /* KEY_L */
- 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */
- 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */
- 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */
- 0x2d, /* KEY_X */ 0x2e, /* KEY_C */
- 0x2f, /* KEY_V */ 0x30, /* KEY_B */
- 0x31, /* KEY_N */ 0x32, /* KEY_M */
- 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */
- 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */
- 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */
- 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */
- 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */
- 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */
- 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */
- 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */
- 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */
- 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */
- 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */
- 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */
- 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */
- 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */
- 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */
- 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */
- 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */
- 0x00, /* 0x55 */ 0x56, /* KEY_Less */
- 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */
- 0x66, /* KEY_Home */ 0x67, /* KEY_Up */
- 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */
- 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */
- 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */
- 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */
- 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */
- 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */
- 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */
- 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */
- 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */
- 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */
- 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */
- 0x00, /* 0x71 */ 0x00, /* 0x72 */
- 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
- 0x00, /* 0x75 */ 0x00, /* 0x76 */
- 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
- 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
- 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
- 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
- 0x00, /* 0x7f */
+static unsigned char at2lnx[] = {
+ 0x0, /* no valid scancode */
+ 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
+ 0x03, /* KEY_2 */ 0x04, /* KEY_3 */
+ 0x05, /* KEY_4 */ 0x06, /* KEY_5 */
+ 0x07, /* KEY_6 */ 0x08, /* KEY_7 */
+ 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */
+ 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */
+ 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */
+ 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */
+ 0x11, /* KEY_W */ 0x12, /* KEY_E */
+ 0x13, /* KEY_R */ 0x14, /* KEY_T */
+ 0x15, /* KEY_Y */ 0x16, /* KEY_U */
+ 0x17, /* KEY_I */ 0x18, /* KEY_O */
+ 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */
+ 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */
+ 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */
+ 0x1f, /* KEY_S */ 0x20, /* KEY_D */
+ 0x21, /* KEY_F */ 0x22, /* KEY_G */
+ 0x23, /* KEY_H */ 0x24, /* KEY_J */
+ 0x25, /* KEY_K */ 0x26, /* KEY_L */
+ 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */
+ 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */
+ 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */
+ 0x2d, /* KEY_X */ 0x2e, /* KEY_C */
+ 0x2f, /* KEY_V */ 0x30, /* KEY_B */
+ 0x31, /* KEY_N */ 0x32, /* KEY_M */
+ 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */
+ 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */
+ 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */
+ 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */
+ 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */
+ 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */
+ 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */
+ 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */
+ 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */
+ 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */
+ 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */
+ 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */
+ 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */
+ 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */
+ 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */
+ 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */
+ 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */
+ 0x00, /* 0x55 */ 0x56, /* KEY_Less */
+ 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */
+ 0x66, /* KEY_Home */ 0x67, /* KEY_Up */
+ 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */
+ 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */
+ 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */
+ 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */
+ 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */
+ 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */
+ 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */
+ 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */
+ 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */
+ 0x7A, /* KEY_Menu/FOCUS_PF11 */ 0x00, /* 0x6e */
+ 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */
+ 0x00, /* 0x71 */ 0x00, /* 0x72 */
+ 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
+ 0x00, /* 0x75 */ 0x00, /* 0x76 */
+ 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
+ 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
+ 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
+ 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
+ 0x00, /* 0x7f */
};
#define NUM_AT_KEYS (sizeof(at2lnx)/sizeof(at2lnx[0]))
#define LNX_KEY_INDEX(n) n < NUM_AT_KEYS ? at2lnx[n] : 0
-static unsigned char tbl[KD_MAX_WIDTH] =
-{
+static unsigned char tbl[KD_MAX_WIDTH] = {
0,
1 << KG_SHIFT,
(1 << KG_ALTGR),
@@ -217,15 +215,15 @@ static unsigned char tbl[KD_MAX_WIDTH] =
#endif
static void
-readKernelMapping(KdKeyboardInfo *ki)
+readKernelMapping(KdKeyboardInfo * ki)
{
#if 0
- KeySym *k;
- int i, j;
- struct kbentry kbe;
- int minKeyCode, maxKeyCode;
- int row;
- int fd;
+ KeySym *k;
+ int i, j;
+ struct kbentry kbe;
+ int minKeyCode, maxKeyCode;
+ int row;
+ int fd;
if (!ki)
return;
@@ -236,252 +234,248 @@ readKernelMapping(KdKeyboardInfo *ki)
maxKeyCode = 0;
row = 0;
ki->keySyms.mapWidth = KD_MAX_WIDTH;
- for (i = 0; i < NR_KEYS && row < KD_MAX_LENGTH; ++i)
- {
+ for (i = 0; i < NR_KEYS && row < KD_MAX_LENGTH; ++i) {
kbe.kb_index = LNX_KEY_INDEX(i);
k = ki->keySyms.map + row * ki->keySyms.mapWidth;
- for (j = 0; j < ki->keySyms.mapWidth; ++j)
- {
- unsigned short kval;
-
- k[j] = NoSymbol;
-
- kbe.kb_table = tbl[j];
- kbe.kb_value = 0;
- if (ioctl(fd, KDGKBENT, &kbe))
- continue;
-
- kval = KVAL(kbe.kb_value);
- switch (KTYP(kbe.kb_value))
- {
- case KT_LATIN:
- case KT_LETTER:
- k[j] = linux_to_x[kval];
- break;
-
- case KT_FN:
- if (kval <= 19)
- k[j] = XK_F1 + kval;
- else switch (kbe.kb_value)
- {
- case K_FIND:
- k[j] = XK_Home; /* or XK_Find */
- break;
- case K_INSERT:
- k[j] = XK_Insert;
- break;
- case K_REMOVE:
- k[j] = XK_Delete;
- break;
- case K_SELECT:
- k[j] = XK_End; /* or XK_Select */
- break;
- case K_PGUP:
- k[j] = XK_Prior;
- break;
- case K_PGDN:
- k[j] = XK_Next;
- break;
- case K_HELP:
- k[j] = XK_Help;
- break;
- case K_DO:
- k[j] = XK_Execute;
- break;
- case K_PAUSE:
- k[j] = XK_Pause;
- break;
- case K_MACRO:
- k[j] = XK_Menu;
- break;
- default:
- break;
- }
- break;
-
- case KT_SPEC:
- switch (kbe.kb_value)
- {
- case K_ENTER:
- k[j] = XK_Return;
- break;
- case K_BREAK:
- k[j] = XK_Break;
- break;
- case K_CAPS:
- k[j] = XK_Caps_Lock;
- break;
- case K_NUM:
- k[j] = XK_Num_Lock;
- break;
- case K_HOLD:
- k[j] = XK_Scroll_Lock;
- break;
- case K_COMPOSE:
- k[j] = XK_Multi_key;
- break;
- default:
- break;
- }
- break;
-
- case KT_PAD:
- switch (kbe.kb_value)
- {
- case K_PPLUS:
- k[j] = XK_KP_Add;
- break;
- case K_PMINUS:
- k[j] = XK_KP_Subtract;
- break;
- case K_PSTAR:
- k[j] = XK_KP_Multiply;
- break;
- case K_PSLASH:
- k[j] = XK_KP_Divide;
- break;
- case K_PENTER:
- k[j] = XK_KP_Enter;
- break;
- case K_PCOMMA:
- k[j] = XK_KP_Separator;
- break;
- case K_PDOT:
- k[j] = XK_KP_Decimal;
- break;
- case K_PPLUSMINUS:
- k[j] = XK_KP_Subtract;
- break;
- default:
- if (kval <= 9)
- k[j] = XK_KP_0 + kval;
- break;
- }
- break;
-
- /*
- * KT_DEAD keys are for accelerated diacritical creation.
- */
- case KT_DEAD:
- switch (kbe.kb_value)
- {
- case K_DGRAVE:
- k[j] = XK_dead_grave;
- break;
- case K_DACUTE:
- k[j] = XK_dead_acute;
- break;
- case K_DCIRCM:
- k[j] = XK_dead_circumflex;
- break;
- case K_DTILDE:
- k[j] = XK_dead_tilde;
- break;
- case K_DDIERE:
- k[j] = XK_dead_diaeresis;
- break;
- }
- break;
-
- case KT_CUR:
- switch (kbe.kb_value)
- {
- case K_DOWN:
- k[j] = XK_Down;
- break;
- case K_LEFT:
- k[j] = XK_Left;
- break;
- case K_RIGHT:
- k[j] = XK_Right;
- break;
- case K_UP:
- k[j] = XK_Up;
- break;
- }
- break;
-
- case KT_SHIFT:
- switch (kbe.kb_value)
- {
- case K_ALTGR:
- k[j] = XK_Mode_switch;
- break;
- case K_ALT:
- k[j] = (kbe.kb_index == 0x64 ?
- XK_Alt_R : XK_Alt_L);
- break;
- case K_CTRL:
- k[j] = (kbe.kb_index == 0x61 ?
- XK_Control_R : XK_Control_L);
- break;
- case K_CTRLL:
- k[j] = XK_Control_L;
- break;
- case K_CTRLR:
- k[j] = XK_Control_R;
- break;
- case K_SHIFT:
- k[j] = (kbe.kb_index == 0x36 ?
- XK_Shift_R : XK_Shift_L);
- break;
- case K_SHIFTL:
- k[j] = XK_Shift_L;
- break;
- case K_SHIFTR:
- k[j] = XK_Shift_R;
- break;
- default:
- break;
- }
- break;
-
- /*
- * KT_ASCII keys accumulate a 3 digit decimal number that gets
- * emitted when the shift state changes. We can't emulate that.
- */
- case KT_ASCII:
- break;
-
- case KT_LOCK:
- if (kbe.kb_value == K_SHIFTLOCK)
- k[j] = XK_Shift_Lock;
- break;
+ for (j = 0; j < ki->keySyms.mapWidth; ++j) {
+ unsigned short kval;
+
+ k[j] = NoSymbol;
+
+ kbe.kb_table = tbl[j];
+ kbe.kb_value = 0;
+ if (ioctl(fd, KDGKBENT, &kbe))
+ continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value)) {
+ case KT_LATIN:
+ case KT_LETTER:
+ k[j] = linux_to_x[kval];
+ break;
+
+ case KT_FN:
+ if (kval <= 19)
+ k[j] = XK_F1 + kval;
+ else
+ switch (kbe.kb_value) {
+ case K_FIND:
+ k[j] = XK_Home; /* or XK_Find */
+ break;
+ case K_INSERT:
+ k[j] = XK_Insert;
+ break;
+ case K_REMOVE:
+ k[j] = XK_Delete;
+ break;
+ case K_SELECT:
+ k[j] = XK_End; /* or XK_Select */
+ break;
+ case K_PGUP:
+ k[j] = XK_Prior;
+ break;
+ case K_PGDN:
+ k[j] = XK_Next;
+ break;
+ case K_HELP:
+ k[j] = XK_Help;
+ break;
+ case K_DO:
+ k[j] = XK_Execute;
+ break;
+ case K_PAUSE:
+ k[j] = XK_Pause;
+ break;
+ case K_MACRO:
+ k[j] = XK_Menu;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_SPEC:
+ switch (kbe.kb_value) {
+ case K_ENTER:
+ k[j] = XK_Return;
+ break;
+ case K_BREAK:
+ k[j] = XK_Break;
+ break;
+ case K_CAPS:
+ k[j] = XK_Caps_Lock;
+ break;
+ case K_NUM:
+ k[j] = XK_Num_Lock;
+ break;
+ case K_HOLD:
+ k[j] = XK_Scroll_Lock;
+ break;
+ case K_COMPOSE:
+ k[j] = XK_Multi_key;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_PAD:
+ switch (kbe.kb_value) {
+ case K_PPLUS:
+ k[j] = XK_KP_Add;
+ break;
+ case K_PMINUS:
+ k[j] = XK_KP_Subtract;
+ break;
+ case K_PSTAR:
+ k[j] = XK_KP_Multiply;
+ break;
+ case K_PSLASH:
+ k[j] = XK_KP_Divide;
+ break;
+ case K_PENTER:
+ k[j] = XK_KP_Enter;
+ break;
+ case K_PCOMMA:
+ k[j] = XK_KP_Separator;
+ break;
+ case K_PDOT:
+ k[j] = XK_KP_Decimal;
+ break;
+ case K_PPLUSMINUS:
+ k[j] = XK_KP_Subtract;
+ break;
+ default:
+ if (kval <= 9)
+ k[j] = XK_KP_0 + kval;
+ break;
+ }
+ break;
+
+ /*
+ * KT_DEAD keys are for accelerated diacritical creation.
+ */
+ case KT_DEAD:
+ switch (kbe.kb_value) {
+ case K_DGRAVE:
+ k[j] = XK_dead_grave;
+ break;
+ case K_DACUTE:
+ k[j] = XK_dead_acute;
+ break;
+ case K_DCIRCM:
+ k[j] = XK_dead_circumflex;
+ break;
+ case K_DTILDE:
+ k[j] = XK_dead_tilde;
+ break;
+ case K_DDIERE:
+ k[j] = XK_dead_diaeresis;
+ break;
+ }
+ break;
+
+ case KT_CUR:
+ switch (kbe.kb_value) {
+ case K_DOWN:
+ k[j] = XK_Down;
+ break;
+ case K_LEFT:
+ k[j] = XK_Left;
+ break;
+ case K_RIGHT:
+ k[j] = XK_Right;
+ break;
+ case K_UP:
+ k[j] = XK_Up;
+ break;
+ }
+ break;
+
+ case KT_SHIFT:
+ switch (kbe.kb_value) {
+ case K_ALTGR:
+ k[j] = XK_Mode_switch;
+ break;
+ case K_ALT:
+ k[j] = (kbe.kb_index == 0x64 ? XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ k[j] = (kbe.kb_index == 0x61 ? XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL:
+ k[j] = XK_Control_L;
+ break;
+ case K_CTRLR:
+ k[j] = XK_Control_R;
+ break;
+ case K_SHIFT:
+ k[j] = (kbe.kb_index == 0x36 ? XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL:
+ k[j] = XK_Shift_L;
+ break;
+ case K_SHIFTR:
+ k[j] = XK_Shift_R;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ /*
+ * KT_ASCII keys accumulate a 3 digit decimal number that gets
+ * emitted when the shift state changes. We can't emulate that.
+ */
+ case KT_ASCII:
+ break;
+
+ case KT_LOCK:
+ if (kbe.kb_value == K_SHIFTLOCK)
+ k[j] = XK_Shift_Lock;
+ break;
#ifdef KT_X
- case KT_X:
- /* depends on new keyboard symbols in file linux/keyboard.h */
- if(kbe.kb_value == K_XMENU) k[j] = XK_Menu;
- if(kbe.kb_value == K_XTELEPHONE) k[j] = XK_telephone;
- break;
+ case KT_X:
+ /* depends on new keyboard symbols in file linux/keyboard.h */
+ if (kbe.kb_value == K_XMENU)
+ k[j] = XK_Menu;
+ if (kbe.kb_value == K_XTELEPHONE)
+ k[j] = XK_telephone;
+ break;
#endif
#ifdef KT_XF
- case KT_XF:
- /* special linux keysyms which map directly to XF86 keysyms */
- k[j] = (kbe.kb_value & 0xFF) + 0x1008FF00;
- break;
+ case KT_XF:
+ /* special linux keysyms which map directly to XF86 keysyms */
+ k[j] = (kbe.kb_value & 0xFF) + 0x1008FF00;
+ break;
#endif
- default:
- break;
- }
- if (i < minKeyCode)
- minKeyCode = i;
- if (i > maxKeyCode)
- maxKeyCode = i;
- }
-
- if (minKeyCode == NR_KEYS)
- continue;
-
- if (k[3] == k[2]) k[3] = NoSymbol;
- if (k[2] == k[1]) k[2] = NoSymbol;
- if (k[1] == k[0]) k[1] = NoSymbol;
- if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
- if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] =NoSymbol;
- row++;
+ default:
+ break;
+ }
+ if (i < minKeyCode)
+ minKeyCode = i;
+ if (i > maxKeyCode)
+ maxKeyCode = i;
+ }
+
+ if (minKeyCode == NR_KEYS)
+ continue;
+
+ if (k[3] == k[2])
+ k[3] = NoSymbol;
+ if (k[2] == k[1])
+ k[2] = NoSymbol;
+ if (k[1] == k[0])
+ k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3])
+ k[2] = k[3] = NoSymbol;
+ if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol)
+ k[3] = NoSymbol;
+ row++;
}
ki->minScanCode = minKeyCode;
ki->maxScanCode = maxKeyCode;
@@ -551,142 +545,166 @@ readKernelMapping(KdKeyboardInfo *ki)
#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
static void
-LinuxKeyboardRead (int fd, void *closure)
+LinuxKeyboardRead(int fd, void *closure)
{
- unsigned char buf[256], *b;
- int n;
- unsigned char prefix = 0, scancode = 0;
+ unsigned char buf[256], *b;
+ int n;
+ unsigned char prefix = 0, scancode = 0;
- while ((n = read (fd, buf, sizeof (buf))) > 0) {
- b = buf;
- while (n--) {
+ while ((n = read(fd, buf, sizeof(buf))) > 0) {
+ b = buf;
+ while (n--) {
/*
* With xkb we use RAW mode for reading the console, which allows us
* process extended scancodes.
*
* See if this is a prefix extending the following keycode
*/
- if (!prefix && ((b[0] & 0x7f) == KEY_Prefix0))
- {
- prefix = KEY_Prefix0;
- /* swallow this up */
- b++;
- continue;
+ if (!prefix && ((b[0] & 0x7f) == KEY_Prefix0)) {
+ prefix = KEY_Prefix0;
+ /* swallow this up */
+ b++;
+ continue;
}
- else if (!prefix && ((b[0] & 0x7f) == KEY_Prefix1))
- {
- prefix = KEY_Prefix1;
- /* swallow this up */
- b++;
- continue;
+ else if (!prefix && ((b[0] & 0x7f) == KEY_Prefix1)) {
+ prefix = KEY_Prefix1;
+ /* swallow this up */
+ b++;
+ continue;
}
scancode = b[0] & 0x7f;
switch (prefix) {
- /* from xf86Events.c */
- case KEY_Prefix0:
- {
- switch (scancode) {
- case KEY_KP_7:
- scancode = KEY_Home; break; /* curs home */
- case KEY_KP_8:
- scancode = KEY_Up; break; /* curs up */
- case KEY_KP_9:
- scancode = KEY_PgUp; break; /* curs pgup */
- case KEY_KP_4:
- scancode = KEY_Left; break; /* curs left */
- case KEY_KP_5:
- scancode = KEY_Begin; break; /* curs begin */
- case KEY_KP_6:
- scancode = KEY_Right; break; /* curs right */
- case KEY_KP_1:
- scancode = KEY_End; break; /* curs end */
- case KEY_KP_2:
- scancode = KEY_Down; break; /* curs down */
- case KEY_KP_3:
- scancode = KEY_PgDown; break; /* curs pgdown */
- case KEY_KP_0:
- scancode = KEY_Insert; break; /* curs insert */
- case KEY_KP_Decimal:
- scancode = KEY_Delete; break; /* curs delete */
- case KEY_Enter:
- scancode = KEY_KP_Enter; break; /* keypad enter */
- case KEY_LCtrl:
- scancode = KEY_RCtrl; break; /* right ctrl */
- case KEY_KP_Multiply:
- scancode = KEY_Print; break; /* print */
- case KEY_Slash:
- scancode = KEY_KP_Divide; break; /* keyp divide */
- case KEY_Alt:
- scancode = KEY_AltLang; break; /* right alt */
- case KEY_ScrollLock:
- scancode = KEY_Break; break; /* curs break */
- case 0x5b:
- scancode = KEY_LMeta; break;
- case 0x5c:
- scancode = KEY_RMeta; break;
- case 0x5d:
- scancode = KEY_Menu; break;
- case KEY_F3:
- scancode = KEY_F13; break;
- case KEY_F4:
- scancode = KEY_F14; break;
- case KEY_F5:
- scancode = KEY_F15; break;
- case KEY_F6:
- scancode = KEY_F16; break;
- case KEY_F7:
- scancode = KEY_F17; break;
- case KEY_KP_Plus:
- scancode = KEY_KP_DEC; break;
- /* Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6) */
- case 0x2A:
- case 0x36:
- b++;
- prefix = 0;
- continue;
- default:
- /*
- * "Internet" keyboards are generating lots of new
- * codes. Let them pass. There is little consistency
- * between them, so don't bother with symbolic names at
- * this level.
- */
- scancode += 0x78;
- }
- break;
- }
+ /* from xf86Events.c */
+ case KEY_Prefix0:
+ {
+ switch (scancode) {
+ case KEY_KP_7:
+ scancode = KEY_Home;
+ break; /* curs home */
+ case KEY_KP_8:
+ scancode = KEY_Up;
+ break; /* curs up */
+ case KEY_KP_9:
+ scancode = KEY_PgUp;
+ break; /* curs pgup */
+ case KEY_KP_4:
+ scancode = KEY_Left;
+ break; /* curs left */
+ case KEY_KP_5:
+ scancode = KEY_Begin;
+ break; /* curs begin */
+ case KEY_KP_6:
+ scancode = KEY_Right;
+ break; /* curs right */
+ case KEY_KP_1:
+ scancode = KEY_End;
+ break; /* curs end */
+ case KEY_KP_2:
+ scancode = KEY_Down;
+ break; /* curs down */
+ case KEY_KP_3:
+ scancode = KEY_PgDown;
+ break; /* curs pgdown */
+ case KEY_KP_0:
+ scancode = KEY_Insert;
+ break; /* curs insert */
+ case KEY_KP_Decimal:
+ scancode = KEY_Delete;
+ break; /* curs delete */
+ case KEY_Enter:
+ scancode = KEY_KP_Enter;
+ break; /* keypad enter */
+ case KEY_LCtrl:
+ scancode = KEY_RCtrl;
+ break; /* right ctrl */
+ case KEY_KP_Multiply:
+ scancode = KEY_Print;
+ break; /* print */
+ case KEY_Slash:
+ scancode = KEY_KP_Divide;
+ break; /* keyp divide */
+ case KEY_Alt:
+ scancode = KEY_AltLang;
+ break; /* right alt */
+ case KEY_ScrollLock:
+ scancode = KEY_Break;
+ break; /* curs break */
+ case 0x5b:
+ scancode = KEY_LMeta;
+ break;
+ case 0x5c:
+ scancode = KEY_RMeta;
+ break;
+ case 0x5d:
+ scancode = KEY_Menu;
+ break;
+ case KEY_F3:
+ scancode = KEY_F13;
+ break;
+ case KEY_F4:
+ scancode = KEY_F14;
+ break;
+ case KEY_F5:
+ scancode = KEY_F15;
+ break;
+ case KEY_F6:
+ scancode = KEY_F16;
+ break;
+ case KEY_F7:
+ scancode = KEY_F17;
+ break;
+ case KEY_KP_Plus:
+ scancode = KEY_KP_DEC;
+ break;
+ /* Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6) */
+ case 0x2A:
+ case 0x36:
+ b++;
+ prefix = 0;
+ continue;
+ default:
+ /*
+ * "Internet" keyboards are generating lots of new
+ * codes. Let them pass. There is little consistency
+ * between them, so don't bother with symbolic names at
+ * this level.
+ */
+ scancode += 0x78;
+ }
+ break;
+ }
- case KEY_Prefix1:
- {
- /* we do no handle these */
- b++;
- prefix = 0;
- continue;
- }
+ case KEY_Prefix1:
+ {
+ /* we do no handle these */
+ b++;
+ prefix = 0;
+ continue;
+ }
- default: /* should not happen*/
- case 0: /* do nothing */
- ;
+ default: /* should not happen */
+ case 0: /* do nothing */
+ ;
}
prefix = 0;
- KdEnqueueKeyboardEvent (closure, scancode, b[0] & 0x80);
- b++;
- }
+ KdEnqueueKeyboardEvent(closure, scancode, b[0] & 0x80);
+ b++;
+ }
}
}
-static int LinuxKbdTrans;
-static struct termios LinuxTermios;
+static int LinuxKbdTrans;
+static struct termios LinuxTermios;
static Status
-LinuxKeyboardEnable (KdKeyboardInfo *ki)
+LinuxKeyboardEnable(KdKeyboardInfo * ki)
{
struct termios nTty;
- unsigned char buf[256];
- int n;
- int fd;
+ unsigned char buf[256];
+ int n;
+ int fd;
if (!ki)
return !Success;
@@ -694,30 +712,29 @@ LinuxKeyboardEnable (KdKeyboardInfo *ki)
fd = LinuxConsoleFd;
ki->driverPrivate = (void *) (intptr_t) fd;
- ioctl (fd, KDGKBMODE, &LinuxKbdTrans);
- tcgetattr (fd, &LinuxTermios);
+ ioctl(fd, KDGKBMODE, &LinuxKbdTrans);
+ tcgetattr(fd, &LinuxTermios);
ioctl(fd, KDSKBMODE, K_RAW);
nTty = LinuxTermios;
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
nTty.c_oflag = 0;
nTty.c_cflag = CREAD | CS8;
nTty.c_lflag = 0;
- nTty.c_cc[VTIME]=0;
- nTty.c_cc[VMIN]=1;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
cfsetispeed(&nTty, 9600);
cfsetospeed(&nTty, 9600);
tcsetattr(fd, TCSANOW, &nTty);
/*
* Flush any pending keystrokes
*/
- while ((n = read (fd, buf, sizeof (buf))) > 0)
- ;
- KdRegisterFd (fd, LinuxKeyboardRead, ki);
+ while ((n = read(fd, buf, sizeof(buf))) > 0);
+ KdRegisterFd(fd, LinuxKeyboardRead, ki);
return Success;
}
static void
-LinuxKeyboardDisable (KdKeyboardInfo *ki)
+LinuxKeyboardDisable(KdKeyboardInfo * ki)
{
int fd;
@@ -732,7 +749,7 @@ LinuxKeyboardDisable (KdKeyboardInfo *ki)
}
static Status
-LinuxKeyboardInit (KdKeyboardInfo *ki)
+LinuxKeyboardInit(KdKeyboardInfo * ki)
{
if (!ki)
return !Success;
@@ -742,18 +759,18 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
free(ki->name);
ki->name = strdup("Linux console keyboard");
- readKernelMapping (ki);
+ readKernelMapping(ki);
return Success;
}
static void
-LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
+LinuxKeyboardLeds(KdKeyboardInfo * ki, int leds)
{
if (!ki)
return;
- ioctl ((int)(intptr_t)ki->driverPrivate, KDSETLED, leds & 7);
+ ioctl((int) (intptr_t) ki->driverPrivate, KDSETLED, leds & 7);
}
KdKeyboardDriver LinuxKeyboardDriver = {
diff --git a/xorg-server/hw/kdrive/linux/linux.c b/xorg-server/hw/kdrive/linux/linux.c
index 194e7cd59..498c2398d 100644
--- a/xorg-server/hw/kdrive/linux/linux.c
+++ b/xorg-server/hw/kdrive/linux/linux.c
@@ -34,51 +34,51 @@
#include <linux/apm_bios.h>
#ifdef KDRIVE_MOUSE
-extern KdPointerDriver LinuxMouseDriver;
-extern KdPointerDriver Ps2MouseDriver;
-extern KdPointerDriver MsMouseDriver;
+extern KdPointerDriver LinuxMouseDriver;
+extern KdPointerDriver Ps2MouseDriver;
+extern KdPointerDriver MsMouseDriver;
#endif
#ifdef TSLIB
-extern KdPointerDriver TsDriver;
+extern KdPointerDriver TsDriver;
#endif
#ifdef KDRIVE_EVDEV
-extern KdPointerDriver LinuxEvdevMouseDriver;
+extern KdPointerDriver LinuxEvdevMouseDriver;
extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
#endif
#ifdef KDRIVE_KBD
-extern KdKeyboardDriver LinuxKeyboardDriver;
+extern KdKeyboardDriver LinuxKeyboardDriver;
#endif
-static int vtno;
-int LinuxConsoleFd;
-int LinuxApmFd = -1;
-static int activeVT;
+static int vtno;
+int LinuxConsoleFd;
+int LinuxApmFd = -1;
+static int activeVT;
static Bool enabled;
static void
-LinuxVTRequest (int sig)
+LinuxVTRequest(int sig)
{
kdSwitchPending = TRUE;
}
/* Check before chowning -- this avoids touching the file system */
static void
-LinuxCheckChown (char *file)
+LinuxCheckChown(char *file)
{
- struct stat st;
- __uid_t u;
- __gid_t g;
-
- if (stat (file, &st) < 0)
- return;
- u = getuid ();
- g = getgid ();
+ struct stat st;
+ __uid_t u;
+ __gid_t g;
+
+ if (stat(file, &st) < 0)
+ return;
+ u = getuid();
+ g = getgid();
if (st.st_uid != u || st.st_gid != g)
- chown (file, u, g);
+ chown(file, u, g);
}
static int
-LinuxInit (void)
+LinuxInit(void)
{
int fd = -1;
char vtname[11];
@@ -86,39 +86,31 @@ LinuxInit (void)
LinuxConsoleFd = -1;
/* check if we're run with euid==0 */
- if (geteuid() != 0)
- {
- FatalError("LinuxInit: Server must be suid root\n");
+ if (geteuid() != 0) {
+ FatalError("LinuxInit: Server must be suid root\n");
}
if (kdVirtualTerminal >= 0)
- vtno = kdVirtualTerminal;
- else
- {
- if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0)
- {
- FatalError(
- "LinuxInit: Cannot open /dev/tty0 (%s)\n",
- strerror(errno));
- }
- if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) ||
- (vtno == -1))
- {
- FatalError("xf86OpenConsole: Cannot find a free VT\n");
- }
- close(fd);
+ vtno = kdVirtualTerminal;
+ else {
+ if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) {
+ FatalError("LinuxInit: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || (vtno == -1)) {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
}
- snprintf(vtname,sizeof(vtname),"/dev/tty%d",vtno); /* /dev/tty1-64 */
+ snprintf(vtname, sizeof(vtname), "/dev/tty%d", vtno); /* /dev/tty1-64 */
- if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
- {
- FatalError("LinuxInit: Cannot open %s (%s)\n",
- vtname, strerror(errno));
+ if ((LinuxConsoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) < 0) {
+ FatalError("LinuxInit: Cannot open %s (%s)\n", vtname, strerror(errno));
}
/* change ownership of the vt */
- LinuxCheckChown (vtname);
+ LinuxCheckChown(vtname);
/*
* the current VT device we're running on is not "console", we want
@@ -126,109 +118,100 @@ LinuxInit (void)
*
* Why is this needed?
*/
- LinuxCheckChown ("/dev/tty0");
+ LinuxCheckChown("/dev/tty0");
/*
* Linux doesn't switch to an active vt after the last close of a vt,
* so we do this ourselves by remembering which is active now.
*/
- memset (&vts, '\0', sizeof (vts)); /* valgrind */
- if (ioctl(LinuxConsoleFd, VT_GETSTATE, &vts) == 0)
- {
- activeVT = vts.v_active;
+ memset(&vts, '\0', sizeof(vts)); /* valgrind */
+ if (ioctl(LinuxConsoleFd, VT_GETSTATE, &vts) == 0) {
+ activeVT = vts.v_active;
}
return 1;
}
static void
-LinuxSetSwitchMode (int mode)
+LinuxSetSwitchMode(int mode)
{
- struct sigaction act;
- struct vt_mode VT;
+ struct sigaction act;
+ struct vt_mode VT;
- if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0)
- {
- FatalError ("LinuxInit: VT_GETMODE failed\n");
+ if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) {
+ FatalError("LinuxInit: VT_GETMODE failed\n");
}
- if (mode == VT_PROCESS)
- {
- act.sa_handler = LinuxVTRequest;
- sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- sigaction (SIGUSR1, &act, 0);
+ if (mode == VT_PROCESS) {
+ act.sa_handler = LinuxVTRequest;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGUSR1, &act, 0);
- VT.mode = mode;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
+ VT.mode = mode;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
}
- else
- {
- act.sa_handler = SIG_IGN;
- sigemptyset (&act.sa_mask);
- act.sa_flags = 0;
- sigaction (SIGUSR1, &act, 0);
-
- VT.mode = mode;
- VT.relsig = 0;
- VT.acqsig = 0;
+ else {
+ act.sa_handler = SIG_IGN;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGUSR1, &act, 0);
+
+ VT.mode = mode;
+ VT.relsig = 0;
+ VT.acqsig = 0;
}
- if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0)
- {
- FatalError("LinuxInit: VT_SETMODE failed\n");
+ if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) {
+ FatalError("LinuxInit: VT_SETMODE failed\n");
}
}
static void
-LinuxApmBlock (pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+LinuxApmBlock(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
{
}
static Bool LinuxApmRunning;
static void
-LinuxApmWakeup (pointer blockData, int result, pointer pReadmask)
+LinuxApmWakeup(pointer blockData, int result, pointer pReadmask)
{
- fd_set *readmask = (fd_set *) pReadmask;
-
- if (result > 0 && LinuxApmFd >= 0 && FD_ISSET (LinuxApmFd, readmask))
- {
- apm_event_t event;
- Bool running = LinuxApmRunning;
- int cmd = APM_IOC_SUSPEND;
-
- while (read (LinuxApmFd, &event, sizeof (event)) == sizeof (event))
- {
- switch (event) {
- case APM_SYS_STANDBY:
- case APM_USER_STANDBY:
- running = FALSE;
- cmd = APM_IOC_STANDBY;
- break;
- case APM_SYS_SUSPEND:
- case APM_USER_SUSPEND:
- case APM_CRITICAL_SUSPEND:
- running = FALSE;
- cmd = APM_IOC_SUSPEND;
- break;
- case APM_NORMAL_RESUME:
- case APM_CRITICAL_RESUME:
- case APM_STANDBY_RESUME:
- running = TRUE;
- break;
- }
- }
- if (running && !LinuxApmRunning)
- {
- KdResume ();
- LinuxApmRunning = TRUE;
- }
- else if (!running && LinuxApmRunning)
- {
- KdSuspend ();
- LinuxApmRunning = FALSE;
- ioctl (LinuxApmFd, cmd, 0);
- }
+ fd_set *readmask = (fd_set *) pReadmask;
+
+ if (result > 0 && LinuxApmFd >= 0 && FD_ISSET(LinuxApmFd, readmask)) {
+ apm_event_t event;
+ Bool running = LinuxApmRunning;
+ int cmd = APM_IOC_SUSPEND;
+
+ while (read(LinuxApmFd, &event, sizeof(event)) == sizeof(event)) {
+ switch (event) {
+ case APM_SYS_STANDBY:
+ case APM_USER_STANDBY:
+ running = FALSE;
+ cmd = APM_IOC_STANDBY;
+ break;
+ case APM_SYS_SUSPEND:
+ case APM_USER_SUSPEND:
+ case APM_CRITICAL_SUSPEND:
+ running = FALSE;
+ cmd = APM_IOC_SUSPEND;
+ break;
+ case APM_NORMAL_RESUME:
+ case APM_CRITICAL_RESUME:
+ case APM_STANDBY_RESUME:
+ running = TRUE;
+ break;
+ }
+ }
+ if (running && !LinuxApmRunning) {
+ KdResume();
+ LinuxApmRunning = TRUE;
+ }
+ else if (!running && LinuxApmRunning) {
+ KdSuspend();
+ LinuxApmRunning = FALSE;
+ ioctl(LinuxApmFd, cmd, 0);
+ }
}
}
@@ -239,127 +222,115 @@ LinuxApmWakeup (pointer blockData, int result, pointer pReadmask)
#endif
static void
-LinuxEnable (void)
+LinuxEnable(void)
{
if (enabled)
- return;
- if (kdSwitchPending)
- {
- kdSwitchPending = FALSE;
- ioctl (LinuxConsoleFd, VT_RELDISP, VT_ACKACQ);
+ return;
+ if (kdSwitchPending) {
+ kdSwitchPending = FALSE;
+ ioctl(LinuxConsoleFd, VT_RELDISP, VT_ACKACQ);
}
/*
* Open the APM driver
*/
- LinuxApmFd = open ("/dev/apm_bios", 2);
+ LinuxApmFd = open("/dev/apm_bios", 2);
if (LinuxApmFd < 0 && errno == ENOENT)
- LinuxApmFd = open ("/dev/misc/apm_bios", 2);
- if (LinuxApmFd >= 0)
- {
- LinuxApmRunning = TRUE;
- fcntl (LinuxApmFd, F_SETFL, fcntl (LinuxApmFd, F_GETFL) | NOBLOCK);
- RegisterBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0);
- AddEnabledDevice (LinuxApmFd);
+ LinuxApmFd = open("/dev/misc/apm_bios", 2);
+ if (LinuxApmFd >= 0) {
+ LinuxApmRunning = TRUE;
+ fcntl(LinuxApmFd, F_SETFL, fcntl(LinuxApmFd, F_GETFL) | NOBLOCK);
+ RegisterBlockAndWakeupHandlers(LinuxApmBlock, LinuxApmWakeup, 0);
+ AddEnabledDevice(LinuxApmFd);
}
/*
* now get the VT
*/
- LinuxSetSwitchMode (VT_AUTO);
- if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0)
- {
- FatalError("LinuxInit: VT_ACTIVATE failed\n");
+ LinuxSetSwitchMode(VT_AUTO);
+ if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0) {
+ FatalError("LinuxInit: VT_ACTIVATE failed\n");
}
- if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0)
- {
- FatalError("LinuxInit: VT_WAITACTIVE failed\n");
+ if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0) {
+ FatalError("LinuxInit: VT_WAITACTIVE failed\n");
}
- LinuxSetSwitchMode (VT_PROCESS);
- if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- {
- FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
+ LinuxSetSwitchMode(VT_PROCESS);
+ if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
}
enabled = TRUE;
}
static void
-LinuxDisable (void)
+LinuxDisable(void)
{
ioctl(LinuxConsoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
- if (kdSwitchPending)
- {
- kdSwitchPending = FALSE;
- ioctl (LinuxConsoleFd, VT_RELDISP, 1);
+ if (kdSwitchPending) {
+ kdSwitchPending = FALSE;
+ ioctl(LinuxConsoleFd, VT_RELDISP, 1);
}
enabled = FALSE;
- if (LinuxApmFd >= 0)
- {
- RemoveBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0);
- RemoveEnabledDevice (LinuxApmFd);
- close (LinuxApmFd);
- LinuxApmFd = -1;
+ if (LinuxApmFd >= 0) {
+ RemoveBlockAndWakeupHandlers(LinuxApmBlock, LinuxApmWakeup, 0);
+ RemoveEnabledDevice(LinuxApmFd);
+ close(LinuxApmFd);
+ LinuxApmFd = -1;
}
}
static void
-LinuxFini (void)
+LinuxFini(void)
{
- struct vt_mode VT;
- struct vt_stat vts;
- int fd;
+ struct vt_mode VT;
+ struct vt_stat vts;
+ int fd;
if (LinuxConsoleFd < 0)
- return;
+ return;
- if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO;
- ioctl(LinuxConsoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO;
+ ioctl(LinuxConsoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
}
- memset (&vts, '\0', sizeof (vts)); /* valgrind */
- ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
- if (vtno == vts.v_active)
- {
- /*
- * Find a legal VT to switch to, either the one we started from
- * or the lowest active one that isn't ours
- */
- if (activeVT < 0 ||
- activeVT == vts.v_active ||
- !(vts.v_state & (1 << activeVT)))
- {
- for (activeVT = 1; activeVT < 16; activeVT++)
- if (activeVT != vtno && (vts.v_state & (1 << activeVT)))
- break;
- if (activeVT == 16)
- activeVT = -1;
- }
- /*
- * Perform a switch back to the active VT when we were started
- */
- if (activeVT >= -1)
- {
- ioctl (LinuxConsoleFd, VT_ACTIVATE, activeVT);
- ioctl (LinuxConsoleFd, VT_WAITACTIVE, activeVT);
- activeVT = -1;
- }
+ memset(&vts, '\0', sizeof(vts)); /* valgrind */
+ ioctl(LinuxConsoleFd, VT_GETSTATE, &vts);
+ if (vtno == vts.v_active) {
+ /*
+ * Find a legal VT to switch to, either the one we started from
+ * or the lowest active one that isn't ours
+ */
+ if (activeVT < 0 ||
+ activeVT == vts.v_active || !(vts.v_state & (1 << activeVT))) {
+ for (activeVT = 1; activeVT < 16; activeVT++)
+ if (activeVT != vtno && (vts.v_state & (1 << activeVT)))
+ break;
+ if (activeVT == 16)
+ activeVT = -1;
+ }
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= -1) {
+ ioctl(LinuxConsoleFd, VT_ACTIVATE, activeVT);
+ ioctl(LinuxConsoleFd, VT_WAITACTIVE, activeVT);
+ activeVT = -1;
+ }
}
- close(LinuxConsoleFd); /* make the vt-manager happy */
+ close(LinuxConsoleFd); /* make the vt-manager happy */
LinuxConsoleFd = -1;
- fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0);
- if (fd >= 0)
- {
- memset (&vts, '\0', sizeof (vts)); /* valgrind */
- ioctl (fd, VT_GETSTATE, &vts);
- if (ioctl (fd, VT_DISALLOCATE, vtno) < 0)
- fprintf (stderr, "Can't deallocate console %d %s\n", vtno, strerror(errno));
- close (fd);
+ fd = open("/dev/tty0", O_RDWR | O_NDELAY, 0);
+ if (fd >= 0) {
+ memset(&vts, '\0', sizeof(vts)); /* valgrind */
+ ioctl(fd, VT_GETSTATE, &vts);
+ if (ioctl(fd, VT_DISALLOCATE, vtno) < 0)
+ fprintf(stderr, "Can't deallocate console %d %s\n", vtno,
+ strerror(errno));
+ close(fd);
}
return;
}
void
-KdOsAddInputDrivers (void)
+KdOsAddInputDrivers(void)
{
#ifdef KDRIVE_MOUSE
KdAddPointerDriver(&LinuxMouseDriver);
@@ -383,10 +354,10 @@ LinuxBell(int volume, int pitch, int duration)
{
if (volume && pitch)
ioctl(LinuxConsoleFd, KDMKTONE, ((1193190 / pitch) & 0xffff) |
- (((unsigned long)duration * volume / 50) << 16));
+ (((unsigned long) duration * volume / 50) << 16));
}
-KdOsFuncs LinuxFuncs = {
+KdOsFuncs LinuxFuncs = {
.Init = LinuxInit,
.Enable = LinuxEnable,
.Disable = LinuxDisable,
@@ -395,7 +366,7 @@ KdOsFuncs LinuxFuncs = {
};
void
-OsVendorInit (void)
+OsVendorInit(void)
{
- KdOsInit (&LinuxFuncs);
+ KdOsInit(&LinuxFuncs);
}
diff --git a/xorg-server/hw/kdrive/linux/mouse.c b/xorg-server/hw/kdrive/linux/mouse.c
index 93c207817..c87507790 100644
--- a/xorg-server/hw/kdrive/linux/mouse.c
+++ b/xorg-server/hw/kdrive/linux/mouse.c
@@ -38,185 +38,176 @@
#define MOUSE_TIMEOUT 100
typedef struct _kbufio {
- int fd;
- unsigned char buf[KBUFIO_SIZE];
- int avail;
- int used;
+ int fd;
+ unsigned char buf[KBUFIO_SIZE];
+ int avail;
+ int used;
} Kbufio;
static Bool
-MouseWaitForReadable (int fd, int timeout)
+MouseWaitForReadable(int fd, int timeout)
{
- fd_set set;
- struct timeval tv, *tp;
- int n;
- CARD32 done;
-
- done = GetTimeInMillis () + timeout;
- for (;;)
- {
- FD_ZERO (&set);
- FD_SET (fd, &set);
- if (timeout == -1)
- tp = 0;
- else
- {
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- tp = &tv;
- }
- n = select (fd + 1, &set, 0, 0, tp);
- if (n > 0)
- return TRUE;
- if (n < 0 && (errno == EAGAIN || errno == EINTR))
- {
- timeout = (int) (done - GetTimeInMillis ());
- if (timeout > 0)
- continue;
- }
- break;
+ fd_set set;
+ struct timeval tv, *tp;
+ int n;
+ CARD32 done;
+
+ done = GetTimeInMillis() + timeout;
+ for (;;) {
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ if (timeout == -1)
+ tp = 0;
+ else {
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ tp = &tv;
+ }
+ n = select(fd + 1, &set, 0, 0, tp);
+ if (n > 0)
+ return TRUE;
+ if (n < 0 && (errno == EAGAIN || errno == EINTR)) {
+ timeout = (int) (done - GetTimeInMillis());
+ if (timeout > 0)
+ continue;
+ }
+ break;
}
return FALSE;
}
static int
-MouseReadByte (Kbufio *b, int timeout)
+MouseReadByte(Kbufio * b, int timeout)
{
- int n;
- if (b->avail <= b->used)
- {
- if (timeout && !MouseWaitForReadable (b->fd, timeout))
- {
+ int n;
+
+ if (b->avail <= b->used) {
+ if (timeout && !MouseWaitForReadable(b->fd, timeout)) {
#ifdef DEBUG_BYTES
- ErrorF ("\tTimeout %d\n", timeout);
+ ErrorF("\tTimeout %d\n", timeout);
#endif
- return -1;
- }
- n = read (b->fd, b->buf, KBUFIO_SIZE);
- if (n <= 0)
- return -1;
+ return -1;
+ }
+ n = read(b->fd, b->buf, KBUFIO_SIZE);
+ if (n <= 0)
+ return -1;
b->avail = n;
b->used = 0;
}
#ifdef DEBUG_BYTES
- ErrorF ("\tget %02x\n", b->buf[b->used]);
+ ErrorF("\tget %02x\n", b->buf[b->used]);
#endif
return b->buf[b->used++];
}
#if NOTUSED
static int
-MouseFlush (Kbufio *b, char *buf, int size)
+MouseFlush(Kbufio * b, char *buf, int size)
{
- CARD32 now = GetTimeInMillis ();
- CARD32 done = now + 100;
- int c;
- int n = 0;
-
- while ((c = MouseReadByte (b, done - now)) != -1)
- {
- if (buf)
- {
- if (n == size)
- {
- memmove (buf, buf + 1, size - 1);
- n--;
- }
- buf[n++] = c;
- }
- now = GetTimeInMillis ();
- if ((INT32) (now - done) >= 0)
- break;
+ CARD32 now = GetTimeInMillis();
+ CARD32 done = now + 100;
+ int c;
+ int n = 0;
+
+ while ((c = MouseReadByte(b, done - now)) != -1) {
+ if (buf) {
+ if (n == size) {
+ memmove(buf, buf + 1, size - 1);
+ n--;
+ }
+ buf[n++] = c;
+ }
+ now = GetTimeInMillis();
+ if ((INT32) (now - done) >= 0)
+ break;
}
return n;
}
static int
-MousePeekByte (Kbufio *b, int timeout)
+MousePeekByte(Kbufio * b, int timeout)
{
- int c;
+ int c;
- c = MouseReadByte (b, timeout);
+ c = MouseReadByte(b, timeout);
if (c != -1)
- --b->used;
+ --b->used;
return c;
}
-#endif /* NOTUSED */
+#endif /* NOTUSED */
static Bool
-MouseWaitForWritable (int fd, int timeout)
+MouseWaitForWritable(int fd, int timeout)
{
- fd_set set;
- struct timeval tv, *tp;
- int n;
+ fd_set set;
+ struct timeval tv, *tp;
+ int n;
- FD_ZERO (&set);
- FD_SET (fd, &set);
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
if (timeout == -1)
- tp = 0;
- else
- {
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- tp = &tv;
+ tp = 0;
+ else {
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ tp = &tv;
}
- n = select (fd + 1, 0, &set, 0, tp);
+ n = select(fd + 1, 0, &set, 0, tp);
if (n > 0)
- return TRUE;
+ return TRUE;
return FALSE;
}
static Bool
-MouseWriteByte (int fd, unsigned char c, int timeout)
+MouseWriteByte(int fd, unsigned char c, int timeout)
{
- int ret;
+ int ret;
#ifdef DEBUG_BYTES
- ErrorF ("\tput %02x\n", c);
+ ErrorF("\tput %02x\n", c);
#endif
- for (;;)
- {
- ret = write (fd, &c, 1);
- if (ret == 1)
- return TRUE;
- if (ret == 0)
- return FALSE;
- if (errno != EWOULDBLOCK)
- return FALSE;
- if (!MouseWaitForWritable (fd, timeout))
- return FALSE;
+ for (;;) {
+ ret = write(fd, &c, 1);
+ if (ret == 1)
+ return TRUE;
+ if (ret == 0)
+ return FALSE;
+ if (errno != EWOULDBLOCK)
+ return FALSE;
+ if (!MouseWaitForWritable(fd, timeout))
+ return FALSE;
}
}
static Bool
-MouseWriteBytes (int fd, unsigned char *c, int n, int timeout)
+MouseWriteBytes(int fd, unsigned char *c, int n, int timeout)
{
while (n--)
- if (!MouseWriteByte (fd, *c++, timeout))
- return FALSE;
+ if (!MouseWriteByte(fd, *c++, timeout))
+ return FALSE;
return TRUE;
}
-#define MAX_MOUSE 10 /* maximum length of mouse protocol */
-#define MAX_SKIP 16 /* number of error bytes before switching */
-#define MAX_VALID 4 /* number of valid packets before accepting */
+#define MAX_MOUSE 10 /* maximum length of mouse protocol */
+#define MAX_SKIP 16 /* number of error bytes before switching */
+#define MAX_VALID 4 /* number of valid packets before accepting */
typedef struct _kmouseProt {
- char *name;
- Bool (*Complete) (KdPointerInfo *pi, unsigned char *ev, int ne);
- int (*Valid) (KdPointerInfo *pi, unsigned char *ev, int ne);
- Bool (*Parse) (KdPointerInfo *pi, unsigned char *ev, int ne);
- Bool (*Init) (KdPointerInfo *pi);
- unsigned char headerMask, headerValid;
- unsigned char dataMask, dataValid;
- Bool tty;
- unsigned int c_iflag;
- unsigned int c_oflag;
- unsigned int c_lflag;
- unsigned int c_cflag;
- unsigned int speed;
- unsigned char *init;
- unsigned long state;
+ char *name;
+ Bool (*Complete) (KdPointerInfo * pi, unsigned char *ev, int ne);
+ int (*Valid) (KdPointerInfo * pi, unsigned char *ev, int ne);
+ Bool (*Parse) (KdPointerInfo * pi, unsigned char *ev, int ne);
+ Bool (*Init) (KdPointerInfo * pi);
+ unsigned char headerMask, headerValid;
+ unsigned char dataMask, dataValid;
+ Bool tty;
+ unsigned int c_iflag;
+ unsigned int c_oflag;
+ unsigned int c_lflag;
+ unsigned int c_cflag;
+ unsigned int speed;
+ unsigned char *init;
+ unsigned long state;
} KmouseProt;
typedef enum _kmouseStage {
@@ -224,68 +215,71 @@ typedef enum _kmouseStage {
} KmouseStage;
typedef struct _kmouse {
- Kbufio iob;
- const KmouseProt *prot;
- int i_prot;
- KmouseStage stage; /* protocol verification stage */
- Bool tty; /* mouse device is a tty */
- int valid; /* sequential valid events */
- int tested; /* bytes scanned during Testing phase */
- int invalid;/* total invalid bytes for this protocol */
- unsigned long state; /* private per protocol, init to prot->state */
+ Kbufio iob;
+ const KmouseProt *prot;
+ int i_prot;
+ KmouseStage stage; /* protocol verification stage */
+ Bool tty; /* mouse device is a tty */
+ int valid; /* sequential valid events */
+ int tested; /* bytes scanned during Testing phase */
+ int invalid; /* total invalid bytes for this protocol */
+ unsigned long state; /* private per protocol, init to prot->state */
} Kmouse;
-static int mouseValid (KdPointerInfo *pi, unsigned char *ev, int ne)
+static int
+mouseValid(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- const KmouseProt *prot = km->prot;
- int i;
+ Kmouse *km = pi->driverPrivate;
+ const KmouseProt *prot = km->prot;
+ int i;
for (i = 0; i < ne; i++)
- if ((ev[i] & prot->headerMask) == prot->headerValid)
- break;
+ if ((ev[i] & prot->headerMask) == prot->headerValid)
+ break;
if (i != 0)
- return i;
+ return i;
for (i = 1; i < ne; i++)
- if ((ev[i] & prot->dataMask) != prot->dataValid)
- return -1;
+ if ((ev[i] & prot->dataMask) != prot->dataValid)
+ return -1;
return 0;
}
-static Bool threeComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+threeComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
{
return ne == 3;
}
-static Bool fourComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+fourComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
{
return ne == 4;
}
-static Bool fiveComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+fiveComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
{
return ne == 5;
}
-static Bool MouseReasonable (KdPointerInfo *pi, unsigned long flags, int dx, int dy)
+static Bool
+MouseReasonable(KdPointerInfo * pi, unsigned long flags, int dx, int dy)
{
- Kmouse *km = pi->driverPrivate;
+ Kmouse *km = pi->driverPrivate;
if (km->stage == MouseWorking)
- return TRUE;
- if (dx < -50 || dx > 50)
- {
+ return TRUE;
+ if (dx < -50 || dx > 50) {
#ifdef DEBUG
- ErrorF ("Large X %d\n", dx);
+ ErrorF("Large X %d\n", dx);
#endif
- return FALSE;
+ return FALSE;
}
- if (dy < -50 || dy > 50)
- {
+ if (dy < -50 || dy > 50) {
#ifdef DEBUG
- ErrorF ("Large Y %d\n", dy);
+ ErrorF("Large Y %d\n", dy);
#endif
- return FALSE;
+ return FALSE;
}
return TRUE;
}
@@ -293,58 +287,54 @@ static Bool MouseReasonable (KdPointerInfo *pi, unsigned long flags, int dx, int
/*
* Standard PS/2 mouse protocol
*/
-static Bool ps2Parse (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+ps2Parse(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- int dx, dy, dz;
- unsigned long flags;
- unsigned long flagsrelease = 0;
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy, dz;
+ unsigned long flags;
+ unsigned long flagsrelease = 0;
flags = KD_MOUSE_DELTA;
if (ev[0] & 4)
- flags |= KD_BUTTON_2;
+ flags |= KD_BUTTON_2;
if (ev[0] & 2)
- flags |= KD_BUTTON_3;
+ flags |= KD_BUTTON_3;
if (ev[0] & 1)
- flags |= KD_BUTTON_1;
-
- if (ne > 3)
- {
- dz = (int) (signed char) ev[3];
- if (dz < 0)
- {
- flags |= KD_BUTTON_4;
- flagsrelease = KD_BUTTON_4;
- }
- else if (dz > 0)
- {
- flags |= KD_BUTTON_5;
- flagsrelease = KD_BUTTON_5;
- }
+ flags |= KD_BUTTON_1;
+
+ if (ne > 3) {
+ dz = (int) (signed char) ev[3];
+ if (dz < 0) {
+ flags |= KD_BUTTON_4;
+ flagsrelease = KD_BUTTON_4;
+ }
+ else if (dz > 0) {
+ flags |= KD_BUTTON_5;
+ flagsrelease = KD_BUTTON_5;
+ }
}
dx = ev[1];
if (ev[0] & 0x10)
- dx -= 256;
+ dx -= 256;
dy = ev[2];
if (ev[0] & 0x20)
- dy -= 256;
+ dy -= 256;
dy = -dy;
- if (!MouseReasonable (pi, flags, dx, dy))
- return FALSE;
- if (km->stage == MouseWorking)
- {
- KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
- if (flagsrelease)
- {
- flags &= ~flagsrelease;
- KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
- }
+ if (!MouseReasonable(pi, flags, dx, dy))
+ return FALSE;
+ if (km->stage == MouseWorking) {
+ KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
+ if (flagsrelease) {
+ flags &= ~flagsrelease;
+ KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
+ }
}
return TRUE;
}
-static Bool ps2Init (KdPointerInfo *pi);
+static Bool ps2Init(KdPointerInfo * pi);
static const KmouseProt ps2Prot = {
"ps/2",
@@ -407,143 +397,143 @@ static const KmouseProt exps2Prot = {
#define PSM_4DMOUSE_ID 6
#define PSM_4DPLUS_ID 8
-static unsigned char ps2_init[] = {
+static unsigned char ps2_init[] = {
PSMC_ENABLE_DEV,
0,
};
#define NINIT_PS2 1
-static unsigned char wheel_3button_init[] = {
+static unsigned char wheel_3button_init[] = {
PSMC_SET_SAMPLING_RATE, 200,
PSMC_SET_SAMPLING_RATE, 100,
- PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SET_SAMPLING_RATE, 80,
PSMC_SEND_DEV_ID,
0,
};
#define NINIT_IMPS2 4
-static unsigned char wheel_5button_init[] = {
+static unsigned char wheel_5button_init[] = {
PSMC_SET_SAMPLING_RATE, 200,
PSMC_SET_SAMPLING_RATE, 100,
- PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SET_SAMPLING_RATE, 80,
PSMC_SET_SAMPLING_RATE, 200,
PSMC_SET_SAMPLING_RATE, 200,
- PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SET_SAMPLING_RATE, 80,
PSMC_SEND_DEV_ID,
0
};
#define NINIT_EXPS2 7
-static unsigned char intelli_init[] = {
+static unsigned char intelli_init[] = {
PSMC_SET_SAMPLING_RATE, 200,
PSMC_SET_SAMPLING_RATE, 100,
- PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SET_SAMPLING_RATE, 80,
0
};
#define NINIT_INTELLI 3
static int
-ps2SkipInit (KdPointerInfo *pi, int ninit, Bool ret_next)
+ps2SkipInit(KdPointerInfo * pi, int ninit, Bool ret_next)
{
- Kmouse *km = pi->driverPrivate;
- int c = -1;
- int skipping;
- Bool waiting;
+ Kmouse *km = pi->driverPrivate;
+ int c = -1;
+ int skipping;
+ Bool waiting;
skipping = 0;
waiting = FALSE;
- while (ninit || ret_next)
- {
- c = MouseReadByte (&km->iob, MOUSE_TIMEOUT);
- if (c == -1)
- break;
- /* look for ACK */
- if (c == 0xfa)
- {
- ninit--;
- if (ret_next)
- waiting = TRUE;
- }
- /* look for packet start -- not the response */
- else if ((c & 0x08) == 0x08)
- waiting = FALSE;
- else if (waiting)
- break;
+ while (ninit || ret_next) {
+ c = MouseReadByte(&km->iob, MOUSE_TIMEOUT);
+ if (c == -1)
+ break;
+ /* look for ACK */
+ if (c == 0xfa) {
+ ninit--;
+ if (ret_next)
+ waiting = TRUE;
+ }
+ /* look for packet start -- not the response */
+ else if ((c & 0x08) == 0x08)
+ waiting = FALSE;
+ else if (waiting)
+ break;
}
return c;
}
static Bool
-ps2Init (KdPointerInfo *pi)
+ps2Init(KdPointerInfo * pi)
{
- Kmouse *km = pi->driverPrivate;
- int skipping;
- Bool waiting;
- int id;
- unsigned char *init;
- int ninit;
+ Kmouse *km = pi->driverPrivate;
+ int skipping;
+ Bool waiting;
+ int id;
+ unsigned char *init;
+ int ninit;
/* Send Intellimouse initialization sequence */
- MouseWriteBytes (km->iob.fd, intelli_init, strlen ((char *) intelli_init), 100);
+ MouseWriteBytes(km->iob.fd, intelli_init, strlen((char *) intelli_init),
+ 100);
/*
* Send ID command
*/
- if (!MouseWriteByte (km->iob.fd, PSMC_SEND_DEV_ID, 100))
- return FALSE;
+ if (!MouseWriteByte(km->iob.fd, PSMC_SEND_DEV_ID, 100))
+ return FALSE;
skipping = 0;
waiting = FALSE;
- id = ps2SkipInit (pi, 0, TRUE);
+ id = ps2SkipInit(pi, 0, TRUE);
switch (id) {
case 3:
- init = wheel_3button_init;
- ninit = NINIT_IMPS2;
- km->prot = &imps2Prot;
- break;
+ init = wheel_3button_init;
+ ninit = NINIT_IMPS2;
+ km->prot = &imps2Prot;
+ break;
case 4:
- init = wheel_5button_init;
- ninit = NINIT_EXPS2;
- km->prot = &exps2Prot;
- break;
+ init = wheel_5button_init;
+ ninit = NINIT_EXPS2;
+ km->prot = &exps2Prot;
+ break;
default:
- init = ps2_init;
- ninit = NINIT_PS2;
- km->prot = &ps2Prot;
- break;
+ init = ps2_init;
+ ninit = NINIT_PS2;
+ km->prot = &ps2Prot;
+ break;
}
if (init)
- MouseWriteBytes (km->iob.fd, init, strlen ((char *) init), 100);
+ MouseWriteBytes(km->iob.fd, init, strlen((char *) init), 100);
/*
* Flush out the available data to eliminate responses to the
* initialization string. Make sure any partial event is
* skipped
*/
- (void) ps2SkipInit (pi, ninit, FALSE);
+ (void) ps2SkipInit(pi, ninit, FALSE);
return TRUE;
}
-static Bool busParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+busParse(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- int dx, dy;
- unsigned long flags;
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
flags = KD_MOUSE_DELTA;
dx = (signed char) ev[1];
dy = -(signed char) ev[2];
if ((ev[0] & 4) == 0)
- flags |= KD_BUTTON_1;
+ flags |= KD_BUTTON_1;
if ((ev[0] & 2) == 0)
- flags |= KD_BUTTON_2;
+ flags |= KD_BUTTON_2;
if ((ev[0] & 1) == 0)
- flags |= KD_BUTTON_3;
- if (!MouseReasonable (pi, flags, dx, dy))
- return FALSE;
+ flags |= KD_BUTTON_3;
+ if (!MouseReasonable(pi, flags, dx, dy))
+ return FALSE;
if (km->stage == MouseWorking)
- KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
return TRUE;
}
@@ -558,25 +548,26 @@ static const KmouseProt busProt = {
* Standard MS serial protocol, three bytes
*/
-static Bool msParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+msParse(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- int dx, dy;
- unsigned long flags;
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
flags = KD_MOUSE_DELTA;
if (ev[0] & 0x20)
- flags |= KD_BUTTON_1;
+ flags |= KD_BUTTON_1;
if (ev[0] & 0x10)
- flags |= KD_BUTTON_3;
+ flags |= KD_BUTTON_3;
- dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
- dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
- if (!MouseReasonable (pi, flags, dx, dy))
- return FALSE;
+ dx = (signed char) (((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
+ dy = (signed char) (((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
+ if (!MouseReasonable(pi, flags, dx, dy))
+ return FALSE;
if (km->stage == MouseWorking)
- KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
return TRUE;
}
@@ -597,70 +588,70 @@ static const KmouseProt msProt = {
* first byte of a synchronized protocol stream and see if it's got
* any bits turned on that can't occur in that fourth byte
*/
-static Bool logiComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+logiComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
+ Kmouse *km = pi->driverPrivate;
if ((ev[0] & 0x40) == 0x40)
- return ne == 3;
+ return ne == 3;
if (km->stage != MouseBroken && (ev[0] & ~0x23) == 0)
- return ne == 1;
+ return ne == 1;
return FALSE;
}
-static int logiValid (KdPointerInfo *pi, unsigned char *ev, int ne)
+static int
+logiValid(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- const KmouseProt *prot = km->prot;
- int i;
-
- for (i = 0; i < ne; i++)
- {
- if ((ev[i] & 0x40) == 0x40)
- break;
- if (km->stage != MouseBroken && (ev[i] & ~0x23) == 0)
- break;
+ Kmouse *km = pi->driverPrivate;
+ const KmouseProt *prot = km->prot;
+ int i;
+
+ for (i = 0; i < ne; i++) {
+ if ((ev[i] & 0x40) == 0x40)
+ break;
+ if (km->stage != MouseBroken && (ev[i] & ~0x23) == 0)
+ break;
}
if (i != 0)
- return i;
+ return i;
for (i = 1; i < ne; i++)
- if ((ev[i] & prot->dataMask) != prot->dataValid)
- return -1;
+ if ((ev[i] & prot->dataMask) != prot->dataValid)
+ return -1;
return 0;
}
-static Bool logiParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+logiParse(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- int dx, dy;
- unsigned long flags;
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
flags = KD_MOUSE_DELTA;
- if (ne == 3)
- {
- if (ev[0] & 0x20)
- flags |= KD_BUTTON_1;
- if (ev[0] & 0x10)
- flags |= KD_BUTTON_3;
+ if (ne == 3) {
+ if (ev[0] & 0x20)
+ flags |= KD_BUTTON_1;
+ if (ev[0] & 0x10)
+ flags |= KD_BUTTON_3;
- dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
- dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
- flags |= km->state & KD_BUTTON_2;
+ dx = (signed char) (((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
+ dy = (signed char) (((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
+ flags |= km->state & KD_BUTTON_2;
}
- else
- {
- if (ev[0] & 0x20)
- flags |= KD_BUTTON_2;
- dx = 0;
- dy = 0;
- flags |= km->state & (KD_BUTTON_1|KD_BUTTON_3);
+ else {
+ if (ev[0] & 0x20)
+ flags |= KD_BUTTON_2;
+ dx = 0;
+ dy = 0;
+ flags |= km->state & (KD_BUTTON_1 | KD_BUTTON_3);
}
- if (!MouseReasonable (pi, flags, dx, dy))
- return FALSE;
+ if (!MouseReasonable(pi, flags, dx, dy))
+ return FALSE;
if (km->stage == MouseWorking)
- KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
return TRUE;
}
@@ -679,27 +670,28 @@ static const KmouseProt logiProt = {
/*
* Mouse systems protocol, 5 bytes
*/
-static Bool mscParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+static Bool
+mscParse(KdPointerInfo * pi, unsigned char *ev, int ne)
{
- Kmouse *km = pi->driverPrivate;
- int dx, dy;
- unsigned long flags;
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
flags = KD_MOUSE_DELTA;
if (!(ev[0] & 0x4))
- flags |= KD_BUTTON_1;
+ flags |= KD_BUTTON_1;
if (!(ev[0] & 0x2))
- flags |= KD_BUTTON_2;
+ flags |= KD_BUTTON_2;
if (!(ev[0] & 0x1))
- flags |= KD_BUTTON_3;
- dx = (signed char)(ev[1]) + (signed char)(ev[3]);
- dy = - ((signed char)(ev[2]) + (signed char)(ev[4]));
+ flags |= KD_BUTTON_3;
+ dx = (signed char) (ev[1]) + (signed char) (ev[3]);
+ dy = -((signed char) (ev[2]) + (signed char) (ev[4]));
- if (!MouseReasonable (pi, flags, dx, dy))
- return FALSE;
+ if (!MouseReasonable(pi, flags, dx, dy))
+ return FALSE;
if (km->stage == MouseWorking)
- KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
return TRUE;
}
@@ -726,25 +718,23 @@ static const KmouseProt *kmouseProts[] = {
#define NUM_PROT (sizeof (kmouseProts) / sizeof (kmouseProts[0]))
static void
-MouseInitProtocol (Kmouse *km)
+MouseInitProtocol(Kmouse * km)
{
- int ret;
- struct termios t;
-
- if (km->prot->tty)
- {
- ret = tcgetattr (km->iob.fd, &t);
-
- if (ret >= 0)
- {
- t.c_iflag = km->prot->c_iflag;
- t.c_oflag = km->prot->c_oflag;
- t.c_lflag = km->prot->c_lflag;
- t.c_cflag = km->prot->c_cflag;
- cfsetispeed (&t, km->prot->speed);
- cfsetospeed (&t, km->prot->speed);
- ret = tcsetattr (km->iob.fd, TCSANOW, &t);
- }
+ int ret;
+ struct termios t;
+
+ if (km->prot->tty) {
+ ret = tcgetattr(km->iob.fd, &t);
+
+ if (ret >= 0) {
+ t.c_iflag = km->prot->c_iflag;
+ t.c_oflag = km->prot->c_oflag;
+ t.c_lflag = km->prot->c_lflag;
+ t.c_cflag = km->prot->c_cflag;
+ cfsetispeed(&t, km->prot->speed);
+ cfsetospeed(&t, km->prot->speed);
+ ret = tcsetattr(km->iob.fd, TCSANOW, &t);
+ }
}
km->stage = MouseBroken;
km->valid = 0;
@@ -754,172 +744,156 @@ MouseInitProtocol (Kmouse *km)
}
static void
-MouseFirstProtocol (Kmouse *km, char *prot)
+MouseFirstProtocol(Kmouse * km, char *prot)
{
- if (prot)
- {
- for (km->i_prot = 0; km->i_prot < NUM_PROT; km->i_prot++)
- if (!strcmp (prot, kmouseProts[km->i_prot]->name))
- break;
- if (km->i_prot == NUM_PROT)
- {
- int i;
- ErrorF ("Unknown mouse protocol \"%s\". Pick one of:", prot);
- for (i = 0; i < NUM_PROT; i++)
- ErrorF (" %s", kmouseProts[i]->name);
- ErrorF ("\n");
- }
- else
- {
- km->prot = kmouseProts[km->i_prot];
- if (km->tty && !km->prot->tty)
- ErrorF ("Mouse device is serial port, protocol %s is not serial protocol\n",
- prot);
- else if (!km->tty && km->prot->tty)
- ErrorF ("Mouse device is not serial port, protocol %s is serial protocol\n",
- prot);
- }
+ if (prot) {
+ for (km->i_prot = 0; km->i_prot < NUM_PROT; km->i_prot++)
+ if (!strcmp(prot, kmouseProts[km->i_prot]->name))
+ break;
+ if (km->i_prot == NUM_PROT) {
+ int i;
+
+ ErrorF("Unknown mouse protocol \"%s\". Pick one of:", prot);
+ for (i = 0; i < NUM_PROT; i++)
+ ErrorF(" %s", kmouseProts[i]->name);
+ ErrorF("\n");
+ }
+ else {
+ km->prot = kmouseProts[km->i_prot];
+ if (km->tty && !km->prot->tty)
+ ErrorF
+ ("Mouse device is serial port, protocol %s is not serial protocol\n",
+ prot);
+ else if (!km->tty && km->prot->tty)
+ ErrorF
+ ("Mouse device is not serial port, protocol %s is serial protocol\n",
+ prot);
+ }
}
- if (!km->prot)
- {
- for (km->i_prot = 0; kmouseProts[km->i_prot]->tty != km->tty; km->i_prot++)
- ;
- km->prot = kmouseProts[km->i_prot];
+ if (!km->prot) {
+ for (km->i_prot = 0; kmouseProts[km->i_prot]->tty != km->tty;
+ km->i_prot++);
+ km->prot = kmouseProts[km->i_prot];
}
- MouseInitProtocol (km);
+ MouseInitProtocol(km);
}
static void
-MouseNextProtocol (Kmouse *km)
+MouseNextProtocol(Kmouse * km)
{
- do
- {
- if (!km->prot)
- km->i_prot = 0;
- else
- if (++km->i_prot == NUM_PROT) km->i_prot = 0;
- km->prot = kmouseProts[km->i_prot];
+ do {
+ if (!km->prot)
+ km->i_prot = 0;
+ else if (++km->i_prot == NUM_PROT)
+ km->i_prot = 0;
+ km->prot = kmouseProts[km->i_prot];
} while (km->prot->tty != km->tty);
- MouseInitProtocol (km);
- ErrorF ("Switching to mouse protocol \"%s\"\n", km->prot->name);
+ MouseInitProtocol(km);
+ ErrorF("Switching to mouse protocol \"%s\"\n", km->prot->name);
}
static void
-MouseRead (int mousePort, void *closure)
+MouseRead(int mousePort, void *closure)
{
- KdPointerInfo *pi = closure;
- Kmouse *km = pi->driverPrivate;
- unsigned char event[MAX_MOUSE];
- int ne;
- int c;
- int i;
- int timeout;
+ KdPointerInfo *pi = closure;
+ Kmouse *km = pi->driverPrivate;
+ unsigned char event[MAX_MOUSE];
+ int ne;
+ int c;
+ int i;
+ int timeout;
timeout = 0;
ne = 0;
- for(;;)
- {
- c = MouseReadByte (&km->iob, timeout);
- if (c == -1)
- {
- if (ne)
- {
- km->invalid += ne + km->tested;
- km->valid = 0;
- km->tested = 0;
- km->stage = MouseBroken;
- }
- break;
- }
- event[ne++] = c;
- i = (*km->prot->Valid) (pi, event, ne);
- if (i != 0)
- {
+ for (;;) {
+ c = MouseReadByte(&km->iob, timeout);
+ if (c == -1) {
+ if (ne) {
+ km->invalid += ne + km->tested;
+ km->valid = 0;
+ km->tested = 0;
+ km->stage = MouseBroken;
+ }
+ break;
+ }
+ event[ne++] = c;
+ i = (*km->prot->Valid) (pi, event, ne);
+ if (i != 0) {
#ifdef DEBUG
- ErrorF ("Mouse protocol %s broken %d of %d bytes bad\n",
- km->prot->name, i > 0 ? i : ne, ne);
+ ErrorF("Mouse protocol %s broken %d of %d bytes bad\n",
+ km->prot->name, i > 0 ? i : ne, ne);
#endif
- if (i > 0 && i < ne)
- {
- ne -= i;
- memmove (event, event + i, ne);
- }
- else
- {
- i = ne;
- ne = 0;
- }
- km->invalid += i + km->tested;
- km->valid = 0;
- km->tested = 0;
- if (km->stage == MouseWorking)
- km->i_prot--;
- km->stage = MouseBroken;
- if (km->invalid > MAX_SKIP)
- {
- MouseNextProtocol (km);
- ne = 0;
- }
- timeout = 0;
- }
- else
- {
- if ((*km->prot->Complete) (pi, event, ne))
- {
- if ((*km->prot->Parse) (pi, event, ne))
- {
- switch (km->stage)
- {
- case MouseBroken:
+ if (i > 0 && i < ne) {
+ ne -= i;
+ memmove(event, event + i, ne);
+ }
+ else {
+ i = ne;
+ ne = 0;
+ }
+ km->invalid += i + km->tested;
+ km->valid = 0;
+ km->tested = 0;
+ if (km->stage == MouseWorking)
+ km->i_prot--;
+ km->stage = MouseBroken;
+ if (km->invalid > MAX_SKIP) {
+ MouseNextProtocol(km);
+ ne = 0;
+ }
+ timeout = 0;
+ }
+ else {
+ if ((*km->prot->Complete) (pi, event, ne)) {
+ if ((*km->prot->Parse) (pi, event, ne)) {
+ switch (km->stage) {
+ case MouseBroken:
#ifdef DEBUG
- ErrorF ("Mouse protocol %s seems OK\n",
- km->prot->name);
+ ErrorF("Mouse protocol %s seems OK\n", km->prot->name);
#endif
- /* do not zero invalid to accumulate invalid bytes */
- km->valid = 0;
- km->tested = 0;
- km->stage = MouseTesting;
- /* fall through ... */
- case MouseTesting:
- km->valid++;
- km->tested += ne;
- if (km->valid > MAX_VALID)
- {
+ /* do not zero invalid to accumulate invalid bytes */
+ km->valid = 0;
+ km->tested = 0;
+ km->stage = MouseTesting;
+ /* fall through ... */
+ case MouseTesting:
+ km->valid++;
+ km->tested += ne;
+ if (km->valid > MAX_VALID) {
#ifdef DEBUG
- ErrorF ("Mouse protocol %s working\n",
- km->prot->name);
+ ErrorF("Mouse protocol %s working\n",
+ km->prot->name);
#endif
- km->stage = MouseWorking;
- km->invalid = 0;
- km->tested = 0;
- km->valid = 0;
- if (km->prot->Init && !(*km->prot->Init) (pi))
- km->stage = MouseBroken;
- }
- break;
- case MouseWorking:
- break;
- }
- }
- else
- {
- km->invalid += ne + km->tested;
- km->valid = 0;
- km->tested = 0;
- km->stage = MouseBroken;
- }
- ne = 0;
- timeout = 0;
- }
- else
- timeout = MOUSE_TIMEOUT;
- }
+ km->stage = MouseWorking;
+ km->invalid = 0;
+ km->tested = 0;
+ km->valid = 0;
+ if (km->prot->Init && !(*km->prot->Init) (pi))
+ km->stage = MouseBroken;
+ }
+ break;
+ case MouseWorking:
+ break;
+ }
+ }
+ else {
+ km->invalid += ne + km->tested;
+ km->valid = 0;
+ km->tested = 0;
+ km->stage = MouseBroken;
+ }
+ ne = 0;
+ timeout = 0;
+ }
+ else
+ timeout = MOUSE_TIMEOUT;
+ }
}
}
int MouseInputType;
-char *kdefaultMouse[] = {
+char *kdefaultMouse[] = {
"/dev/input/mice",
"/dev/mouse",
"/dev/psaux",
@@ -931,26 +905,26 @@ char *kdefaultMouse[] = {
#define NUM_DEFAULT_MOUSE (sizeof (kdefaultMouse) / sizeof (kdefaultMouse[0]))
static Status
-MouseInit (KdPointerInfo *pi)
+MouseInit(KdPointerInfo * pi)
{
- int i;
- int fd;
- Kmouse *km;
+ int i;
+ int fd;
+ Kmouse *km;
if (!pi)
return BadImplementation;
if (!pi->path || strcmp(pi->path, "auto") == 0) {
for (i = 0; i < NUM_DEFAULT_MOUSE; i++) {
- fd = open (kdefaultMouse[i], 2);
+ fd = open(kdefaultMouse[i], 2);
if (fd >= 0) {
- pi->path = strdup (kdefaultMouse[i]);
+ pi->path = strdup(kdefaultMouse[i]);
break;
}
}
}
else {
- fd = open (pi->path, 2);
+ fd = open(pi->path, 2);
}
if (fd < 0)
@@ -958,21 +932,21 @@ MouseInit (KdPointerInfo *pi)
close(fd);
- km = (Kmouse *) malloc(sizeof (Kmouse));
+ km = (Kmouse *) malloc(sizeof(Kmouse));
if (km) {
km->iob.avail = km->iob.used = 0;
MouseFirstProtocol(km, pi->protocol ? pi->protocol : "exps/2");
/* MouseFirstProtocol sets state to MouseBroken for later protocol
* checks. Skip these checks if a protocol was supplied */
if (pi->protocol)
- km->state = MouseWorking;
+ km->state = MouseWorking;
km->i_prot = 0;
- km->tty = isatty (fd);
+ km->tty = isatty(fd);
km->iob.fd = -1;
pi->driverPrivate = km;
}
else {
- close (fd);
+ close(fd);
return BadAlloc;
}
@@ -980,7 +954,7 @@ MouseInit (KdPointerInfo *pi)
}
static Status
-MouseEnable (KdPointerInfo *pi)
+MouseEnable(KdPointerInfo * pi)
{
Kmouse *km;
@@ -993,8 +967,7 @@ MouseEnable (KdPointerInfo *pi)
if (km->iob.fd < 0)
return BadMatch;
- if (!KdRegisterFd (km->iob.fd, MouseRead, pi))
- {
+ if (!KdRegisterFd(km->iob.fd, MouseRead, pi)) {
close(km->iob.fd);
return BadAlloc;
}
@@ -1003,18 +976,19 @@ MouseEnable (KdPointerInfo *pi)
}
static void
-MouseDisable (KdPointerInfo *pi)
+MouseDisable(KdPointerInfo * pi)
{
Kmouse *km;
+
if (!pi || !pi->driverPrivate)
return;
km = pi->driverPrivate;
- KdUnregisterFd (pi, km->iob.fd, TRUE);
+ KdUnregisterFd(pi, km->iob.fd, TRUE);
}
static void
-MouseFini (KdPointerInfo *pi)
+MouseFini(KdPointerInfo * pi)
{
free(pi->driverPrivate);
pi->driverPrivate = NULL;
diff --git a/xorg-server/hw/kdrive/linux/ms.c b/xorg-server/hw/kdrive/linux/ms.c
index 176e12550..e82350ac5 100644
--- a/xorg-server/hw/kdrive/linux/ms.c
+++ b/xorg-server/hw/kdrive/linux/ms.c
@@ -34,67 +34,63 @@ THE SOFTWARE.
#include "kdrive.h"
static int
-MsReadBytes (int fd, char *buf, int len, int min)
+MsReadBytes(int fd, char *buf, int len, int min)
{
- int n, tot;
- fd_set set;
- struct timeval tv;
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
tot = 0;
- while (len)
- {
- n = read (fd, buf, len);
- if (n > 0)
- {
- tot += n;
- buf += n;
- len -= n;
- }
- if (tot % min == 0)
- break;
- FD_ZERO (&set);
- FD_SET (fd, &set);
- tv.tv_sec = 0;
- tv.tv_usec = 100 * 1000;
- n = select (fd + 1, &set, 0, 0, &tv);
- if (n <= 0)
- break;
+ while (len) {
+ n = read(fd, buf, len);
+ if (n > 0) {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0)
+ break;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select(fd + 1, &set, 0, 0, &tv);
+ if (n <= 0)
+ break;
}
return tot;
}
static void
-MsRead (int port, void *closure)
+MsRead(int port, void *closure)
{
- unsigned char buf[3 * 200];
- unsigned char *b;
- int n;
- int dx, dy;
- unsigned long flags;
-
- while ((n = MsReadBytes (port, (char *) buf, sizeof (buf), 3)) > 0)
- {
- b = buf;
- while (n >= 3)
- {
- flags = KD_MOUSE_DELTA;
-
- if (b[0] & 0x20)
- flags |= KD_BUTTON_1;
- if (b[0] & 0x10)
- flags |= KD_BUTTON_3;
-
- dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3F));
- dy = (char)(((b[0] & 0x0C) << 4) | (b[2] & 0x3F));
+ unsigned char buf[3 * 200];
+ unsigned char *b;
+ int n;
+ int dx, dy;
+ unsigned long flags;
+
+ while ((n = MsReadBytes(port, (char *) buf, sizeof(buf), 3)) > 0) {
+ b = buf;
+ while (n >= 3) {
+ flags = KD_MOUSE_DELTA;
+
+ if (b[0] & 0x20)
+ flags |= KD_BUTTON_1;
+ if (b[0] & 0x10)
+ flags |= KD_BUTTON_3;
+
+ dx = (char) (((b[0] & 0x03) << 6) | (b[1] & 0x3F));
+ dy = (char) (((b[0] & 0x0C) << 4) | (b[2] & 0x3F));
n -= 3;
b += 3;
- KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
- }
+ KdEnqueuePointerEvent(closure, flags, dx, dy, 0);
+ }
}
}
static Status
-MsInit (KdPointerInfo *pi)
+MsInit(KdPointerInfo * pi)
{
if (!pi)
return BadImplementation;
@@ -108,51 +104,51 @@ MsInit (KdPointerInfo *pi)
}
static Status
-MsEnable (KdPointerInfo *pi)
+MsEnable(KdPointerInfo * pi)
{
int port;
struct termios t;
int ret;
- port = open (pi->path, O_RDWR | O_NONBLOCK);
- if(port < 0) {
- ErrorF("Couldn't open %s (%d)\n", pi->path, (int)errno);
+ port = open(pi->path, O_RDWR | O_NONBLOCK);
+ if (port < 0) {
+ ErrorF("Couldn't open %s (%d)\n", pi->path, (int) errno);
return 0;
- } else if (port == 0) {
- ErrorF("Opening %s returned 0! Please complain to Keith.\n",
- pi->path);
- goto bail;
+ }
+ else if (port == 0) {
+ ErrorF("Opening %s returned 0! Please complain to Keith.\n", pi->path);
+ goto bail;
}
- if(!isatty(port)) {
+ if (!isatty(port)) {
ErrorF("%s is not a tty\n", pi->path);
goto bail;
}
ret = tcgetattr(port, &t);
- if(ret < 0) {
+ if (ret < 0) {
ErrorF("Couldn't tcgetattr(%s): %d\n", pi->path, errno);
goto bail;
}
- t.c_iflag &= ~ (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |
+ t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |
IGNCR | ICRNL | IXON | IXOFF);
- t.c_oflag &= ~ OPOST;
- t.c_lflag &= ~ (ECHO | ECHONL | ICANON | ISIG | IEXTEN);
- t.c_cflag &= ~ (CSIZE | PARENB);
+ t.c_oflag &= ~OPOST;
+ t.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ t.c_cflag &= ~(CSIZE | PARENB);
t.c_cflag |= CS8 | CLOCAL | CSTOPB;
- cfsetispeed (&t, B1200);
- cfsetospeed (&t, B1200);
+ cfsetispeed(&t, B1200);
+ cfsetospeed(&t, B1200);
t.c_cc[VMIN] = 1;
t.c_cc[VTIME] = 0;
ret = tcsetattr(port, TCSANOW, &t);
- if(ret < 0) {
+ if (ret < 0) {
ErrorF("Couldn't tcsetattr(%s): %d\n", pi->path, errno);
goto bail;
}
- if (KdRegisterFd (port, MsRead, pi))
- return TRUE;
- pi->driverPrivate = (void *)(intptr_t)port;
+ if (KdRegisterFd(port, MsRead, pi))
+ return TRUE;
+ pi->driverPrivate = (void *) (intptr_t) port;
return Success;
@@ -162,13 +158,13 @@ MsEnable (KdPointerInfo *pi)
}
static void
-MsDisable (KdPointerInfo *pi)
+MsDisable(KdPointerInfo * pi)
{
- KdUnregisterFd (pi, (int)(intptr_t)pi->driverPrivate, TRUE);
+ KdUnregisterFd(pi, (int) (intptr_t) pi->driverPrivate, TRUE);
}
static void
-MsFini (KdPointerInfo *pi)
+MsFini(KdPointerInfo * pi)
{
}
diff --git a/xorg-server/hw/kdrive/linux/ps2.c b/xorg-server/hw/kdrive/linux/ps2.c
index b62d769f2..d1522a2d0 100644
--- a/xorg-server/hw/kdrive/linux/ps2.c
+++ b/xorg-server/hw/kdrive/linux/ps2.c
@@ -31,36 +31,34 @@
#include "kdrive.h"
static int
-Ps2ReadBytes (int fd, char *buf, int len, int min)
+Ps2ReadBytes(int fd, char *buf, int len, int min)
{
- int n, tot;
- fd_set set;
- struct timeval tv;
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
tot = 0;
- while (len)
- {
- n = read (fd, buf, len);
- if (n > 0)
- {
- tot += n;
- buf += n;
- len -= n;
- }
- if (tot % min == 0)
- break;
- FD_ZERO (&set);
- FD_SET (fd, &set);
- tv.tv_sec = 0;
- tv.tv_usec = 100 * 1000;
- n = select (fd + 1, &set, 0, 0, &tv);
- if (n <= 0)
- break;
+ while (len) {
+ n = read(fd, buf, len);
+ if (n > 0) {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0)
+ break;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select(fd + 1, &set, 0, 0, &tv);
+ if (n <= 0)
+ break;
}
return tot;
}
-char *Ps2Names[] = {
+char *Ps2Names[] = {
"/dev/psaux",
/* "/dev/mouse", */
"/dev/input/mice",
@@ -69,67 +67,64 @@ char *Ps2Names[] = {
#define NUM_PS2_NAMES (sizeof (Ps2Names) / sizeof (Ps2Names[0]))
static void
-Ps2Read (int ps2Port, void *closure)
+Ps2Read(int ps2Port, void *closure)
{
- unsigned char buf[3 * 200];
- unsigned char *b;
- int n;
- int dx, dy;
- unsigned long flags;
- unsigned long left_button = KD_BUTTON_1;
- unsigned long right_button = KD_BUTTON_3;
+ unsigned char buf[3 * 200];
+ unsigned char *b;
+ int n;
+ int dx, dy;
+ unsigned long flags;
+ unsigned long left_button = KD_BUTTON_1;
+ unsigned long right_button = KD_BUTTON_3;
#undef SWAP_USB
#ifdef SWAP_USB
- if (id == 2)
- {
- left_button = KD_BUTTON_3;
- right_button = KD_BUTTON_1;
+ if (id == 2) {
+ left_button = KD_BUTTON_3;
+ right_button = KD_BUTTON_1;
}
#endif
- while ((n = Ps2ReadBytes (ps2Port, (char *) buf, sizeof (buf), 3)) > 0)
- {
- b = buf;
- while (n >= 3)
- {
- flags = KD_MOUSE_DELTA;
- if (b[0] & 4)
- flags |= KD_BUTTON_2;
- if (b[0] & 2)
- flags |= right_button;
- if (b[0] & 1)
- flags |= left_button;
-
- dx = b[1];
- if (b[0] & 0x10)
- dx -= 256;
- dy = b[2];
- if (b[0] & 0x20)
- dy -= 256;
- dy = -dy;
- n -= 3;
- b += 3;
- KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
- }
+ while ((n = Ps2ReadBytes(ps2Port, (char *) buf, sizeof(buf), 3)) > 0) {
+ b = buf;
+ while (n >= 3) {
+ flags = KD_MOUSE_DELTA;
+ if (b[0] & 4)
+ flags |= KD_BUTTON_2;
+ if (b[0] & 2)
+ flags |= right_button;
+ if (b[0] & 1)
+ flags |= left_button;
+
+ dx = b[1];
+ if (b[0] & 0x10)
+ dx -= 256;
+ dy = b[2];
+ if (b[0] & 0x20)
+ dy -= 256;
+ dy = -dy;
+ n -= 3;
+ b += 3;
+ KdEnqueuePointerEvent(closure, flags, dx, dy, 0);
+ }
}
}
static Status
-Ps2Init (KdPointerInfo *pi)
+Ps2Init(KdPointerInfo * pi)
{
- int ps2Port, i;
+ int ps2Port, i;
if (!pi->path) {
for (i = 0; i < NUM_PS2_NAMES; i++) {
- ps2Port = open (Ps2Names[i], 0);
+ ps2Port = open(Ps2Names[i], 0);
if (ps2Port >= 0) {
- pi->path = strdup (Ps2Names[i]);
+ pi->path = strdup(Ps2Names[i]);
break;
}
- }
+ }
}
else {
- ps2Port = open (pi->path, 0);
+ ps2Port = open(pi->path, 0);
}
if (ps2Port < 0)
@@ -137,42 +132,41 @@ Ps2Init (KdPointerInfo *pi)
close(ps2Port);
if (!pi->name)
- pi->name = strdup ("PS/2 Mouse");
+ pi->name = strdup("PS/2 Mouse");
return Success;
}
static Status
-Ps2Enable (KdPointerInfo *pi)
+Ps2Enable(KdPointerInfo * pi)
{
int fd;
if (!pi)
return BadImplementation;
- fd = open (pi->path, 0);
+ fd = open(pi->path, 0);
if (fd < 0)
return BadMatch;
- if (!KdRegisterFd (fd, Ps2Read, pi)) {
+ if (!KdRegisterFd(fd, Ps2Read, pi)) {
close(fd);
return BadAlloc;
}
- pi->driverPrivate = (void *)(intptr_t)fd;
+ pi->driverPrivate = (void *) (intptr_t) fd;
return Success;
}
-
static void
-Ps2Disable (KdPointerInfo *pi)
+Ps2Disable(KdPointerInfo * pi)
{
- KdUnregisterFd (pi, (int)(intptr_t)pi->driverPrivate, TRUE);
+ KdUnregisterFd(pi, (int) (intptr_t) pi->driverPrivate, TRUE);
}
static void
-Ps2Fini (KdPointerInfo *pi)
+Ps2Fini(KdPointerInfo * pi)
{
}
diff --git a/xorg-server/hw/kdrive/linux/tslib.c b/xorg-server/hw/kdrive/linux/tslib.c
index 1f30ccae7..1403c7968 100644
--- a/xorg-server/hw/kdrive/linux/tslib.c
+++ b/xorg-server/hw/kdrive/linux/tslib.c
@@ -30,7 +30,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-
#ifdef HAVE_KDRIVE_CONFIG_H
#include <kdrive-config.h>
#endif
@@ -50,25 +49,24 @@ struct TslibPrivate {
int fd;
int lastx, lasty;
struct tsdev *tsDev;
- void (*raw_event_hook)(int x, int y, int pressure, void *closure);
+ void (*raw_event_hook) (int x, int y, int pressure, void *closure);
void *raw_event_closure;
int phys_screen;
};
-
static void
-TsRead (int fd, void *closure)
+TsRead(int fd, void *closure)
{
- KdPointerInfo *pi = closure;
+ KdPointerInfo *pi = closure;
struct TslibPrivate *private = pi->driverPrivate;
- struct ts_sample event;
- long x = 0, y = 0;
- unsigned long flags;
+ struct ts_sample event;
+ long x = 0, y = 0;
+ unsigned long flags;
if (private->raw_event_hook) {
while (ts_read_raw(private->tsDev, &event, 1) == 1)
- private->raw_event_hook (event.x, event.y, event.pressure,
- private->raw_event_closure);
+ private->raw_event_hook(event.x, event.y, event.pressure,
+ private->raw_event_closure);
return;
}
@@ -84,30 +82,33 @@ TsRead (int fd, void *closure)
if (KdCurScreen == private->phys_screen) {
x = event.x;
y = event.y;
- } else {
+ }
+ else {
flags |= KD_MOUSE_DELTA;
if ((private->lastx == 0) || (private->lasty == 0)) {
x = event.x;
y = event.y;
- } else {
+ }
+ else {
x = event.x - private->lastx;
y = event.y - private->lasty;
- }
+ }
}
private->lastx = event.x;
private->lasty = event.y;
- } else {
+ }
+ else {
flags = 0;
x = private->lastx;
y = private->lasty;
}
- KdEnqueuePointerEvent (pi, flags, x, y, event.pressure);
+ KdEnqueuePointerEvent(pi, flags, x, y, event.pressure);
}
}
static Status
-TslibEnable (KdPointerInfo *pi)
+TslibEnable(KdPointerInfo * pi)
{
struct TslibPrivate *private = pi->driverPrivate;
@@ -115,7 +116,8 @@ TslibEnable (KdPointerInfo *pi)
private->raw_event_closure = NULL;
if (!pi->path) {
pi->path = strdup("/dev/input/touchscreen0");
- ErrorF("[tslib/TslibEnable] no device path given, trying %s\n", pi->path);
+ ErrorF("[tslib/TslibEnable] no device path given, trying %s\n",
+ pi->path);
}
private->tsDev = ts_open(pi->path, 0);
@@ -138,9 +140,8 @@ TslibEnable (KdPointerInfo *pi)
return Success;
}
-
static void
-TslibDisable (KdPointerInfo *pi)
+TslibDisable(KdPointerInfo * pi)
{
struct TslibPrivate *private = pi->driverPrivate;
@@ -154,9 +155,8 @@ TslibDisable (KdPointerInfo *pi)
private->tsDev = NULL;
}
-
static Status
-TslibInit (KdPointerInfo *pi)
+TslibInit(KdPointerInfo * pi)
{
struct TslibPrivate *private = NULL;
@@ -164,7 +164,7 @@ TslibInit (KdPointerInfo *pi)
return !Success;
pi->driverPrivate = (struct TslibPrivate *)
- calloc(sizeof(struct TslibPrivate), 1);
+ calloc(sizeof(struct TslibPrivate), 1);
if (!pi->driverPrivate)
return !Success;
@@ -178,15 +178,13 @@ TslibInit (KdPointerInfo *pi)
return Success;
}
-
static void
-TslibFini (KdPointerInfo *pi)
+TslibFini(KdPointerInfo * pi)
{
free(pi->driverPrivate);
pi->driverPrivate = NULL;
}
-
KdPointerDriver TsDriver = {
"tslib",
TslibInit,
diff --git a/xorg-server/hw/kdrive/src/kcmap.c b/xorg-server/hw/kdrive/src/kcmap.c
index 6e0fc1417..c93c2f4d3 100644
--- a/xorg-server/hw/kdrive/src/kcmap.c
+++ b/xorg-server/hw/kdrive/src/kcmap.c
@@ -30,25 +30,25 @@
*/
void
-KdSetColormap (ScreenPtr pScreen)
+KdSetColormap(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- ColormapPtr pCmap = pScreenPriv->pInstalledmap;
- Pixel pixels[KD_MAX_PSEUDO_SIZE];
- xrgb colors[KD_MAX_PSEUDO_SIZE];
- xColorItem defs[KD_MAX_PSEUDO_SIZE];
- int i;
+ ColormapPtr pCmap = pScreenPriv->pInstalledmap;
+ Pixel pixels[KD_MAX_PSEUDO_SIZE];
+ xrgb colors[KD_MAX_PSEUDO_SIZE];
+ xColorItem defs[KD_MAX_PSEUDO_SIZE];
+ int i;
if (!pScreenPriv->card->cfuncs->putColors)
- return;
+ return;
if (pScreenPriv->screen->fb.depth > KD_MAX_PSEUDO_DEPTH)
- return;
+ return;
if (!pScreenPriv->enabled)
- return;
+ return;
if (!pCmap)
- return;
+ return;
/*
* Make DIX convert pixels into RGB values -- this handles
@@ -56,26 +56,26 @@ KdSetColormap (ScreenPtr pScreen)
*/
for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++)
- pixels[i] = i;
+ pixels[i] = i;
- QueryColors (pCmap, (1 << pScreenPriv->screen->fb.depth), pixels, colors, serverClient);
+ QueryColors(pCmap, (1 << pScreenPriv->screen->fb.depth), pixels, colors,
+ serverClient);
- for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++)
- {
- defs[i].pixel = i;
- defs[i].red = colors[i].red;
- defs[i].green = colors[i].green;
- defs[i].blue = colors[i].blue;
- defs[i].flags = DoRed|DoGreen|DoBlue;
+ for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++) {
+ defs[i].pixel = i;
+ defs[i].red = colors[i].red;
+ defs[i].green = colors[i].green;
+ defs[i].blue = colors[i].blue;
+ defs[i].flags = DoRed | DoGreen | DoBlue;
}
(*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen,
- (1 << pScreenPriv->screen->fb.depth),
- defs);
+ (1 << pScreenPriv->screen->fb.
+ depth), defs);
/* recolor hardware cursor */
if (pScreenPriv->card->cfuncs->recolorCursor)
- (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, 0, 0);
+ (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, 0, 0);
}
/*
@@ -83,38 +83,38 @@ KdSetColormap (ScreenPtr pScreen)
* the current colormap
*/
void
-KdEnableColormap (ScreenPtr pScreen)
+KdEnableColormap(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- int i;
+ int i;
if (!pScreenPriv->card->cfuncs->putColors)
- return;
-
- if (pScreenPriv->screen->fb.depth <= KD_MAX_PSEUDO_DEPTH)
- {
- for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++)
- pScreenPriv->systemPalette[i].pixel = i;
- (*pScreenPriv->card->cfuncs->getColors) (pScreen,
- (1 << pScreenPriv->screen->fb.depth),
- pScreenPriv->systemPalette);
+ return;
+
+ if (pScreenPriv->screen->fb.depth <= KD_MAX_PSEUDO_DEPTH) {
+ for (i = 0; i < (1 << pScreenPriv->screen->fb.depth); i++)
+ pScreenPriv->systemPalette[i].pixel = i;
+ (*pScreenPriv->card->cfuncs->getColors) (pScreen,
+ (1 << pScreenPriv->screen->fb.
+ depth),
+ pScreenPriv->systemPalette);
}
- KdSetColormap (pScreen);
+ KdSetColormap(pScreen);
}
void
-KdDisableColormap (ScreenPtr pScreen)
+KdDisableColormap(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
if (!pScreenPriv->card->cfuncs->putColors)
- return;
+ return;
- if (pScreenPriv->screen->fb.depth <= KD_MAX_PSEUDO_DEPTH)
- {
- (*pScreenPriv->card->cfuncs->putColors) (pScreen,
- (1 << pScreenPriv->screen->fb.depth),
- pScreenPriv->systemPalette);
+ if (pScreenPriv->screen->fb.depth <= KD_MAX_PSEUDO_DEPTH) {
+ (*pScreenPriv->card->cfuncs->putColors) (pScreen,
+ (1 << pScreenPriv->screen->fb.
+ depth),
+ pScreenPriv->systemPalette);
}
}
@@ -128,22 +128,22 @@ KdDisableColormap (ScreenPtr pScreen)
* colormap and realize it into the Windows system palette.
*/
void
-KdInstallColormap (ColormapPtr pCmap)
+KdInstallColormap(ColormapPtr pCmap)
{
KdScreenPriv(pCmap->pScreen);
if (pCmap == pScreenPriv->pInstalledmap)
- return;
+ return;
/* Tell X clients that the installed colormap is going away. */
if (pScreenPriv->pInstalledmap)
- WalkTree(pScreenPriv->pInstalledmap->pScreen, TellLostMap,
- (pointer) &(pScreenPriv->pInstalledmap->mid));
+ WalkTree(pScreenPriv->pInstalledmap->pScreen, TellLostMap,
+ (pointer) &(pScreenPriv->pInstalledmap->mid));
/* Take note of the new installed colorscreen-> */
pScreenPriv->pInstalledmap = pCmap;
- KdSetColormap (pCmap->pScreen);
+ KdSetColormap(pCmap->pScreen);
/* Tell X clients of the new colormap */
WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &(pCmap->mid));
@@ -157,45 +157,42 @@ KdInstallColormap (ColormapPtr pCmap)
* The default X colormap itself cannot be uninstalled.
*/
void
-KdUninstallColormap (ColormapPtr pCmap)
+KdUninstallColormap(ColormapPtr pCmap)
{
KdScreenPriv(pCmap->pScreen);
- Colormap defMapID;
+ Colormap defMapID;
ColormapPtr defMap;
/* ignore if not installed */
if (pCmap != pScreenPriv->pInstalledmap)
- return;
+ return;
/* ignore attempts to uninstall default colormap */
defMapID = pCmap->pScreen->defColormap;
if ((Colormap) pCmap->mid == defMapID)
- return;
+ return;
/* install default */
- dixLookupResourceByType((pointer *)&defMap, defMapID, RT_COLORMAP,
- serverClient, DixInstallAccess);
+ dixLookupResourceByType((pointer *) &defMap, defMapID, RT_COLORMAP,
+ serverClient, DixInstallAccess);
if (defMap)
- (*pCmap->pScreen->InstallColormap)(defMap);
- else
- {
- /* uninstall and clear colormap pointer */
- WalkTree(pCmap->pScreen, TellLostMap,
- (pointer) &(pCmap->mid));
- pScreenPriv->pInstalledmap = 0;
+ (*pCmap->pScreen->InstallColormap) (defMap);
+ else {
+ /* uninstall and clear colormap pointer */
+ WalkTree(pCmap->pScreen, TellLostMap, (pointer) &(pCmap->mid));
+ pScreenPriv->pInstalledmap = 0;
}
}
int
-KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps)
+KdListInstalledColormaps(ScreenPtr pScreen, Colormap * pCmaps)
{
KdScreenPriv(pScreen);
- int n = 0;
+ int n = 0;
- if (pScreenPriv->pInstalledmap)
- {
- *pCmaps++ = pScreenPriv->pInstalledmap->mid;
- n++;
+ if (pScreenPriv->pInstalledmap) {
+ *pCmaps++ = pScreenPriv->pInstalledmap->mid;
+ n++;
}
return n;
}
@@ -208,39 +205,39 @@ KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps)
* colormap; it can be either the default colormap or a private colorscreen->
*/
void
-KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs)
+KdStoreColors(ColormapPtr pCmap, int ndef, xColorItem * pdefs)
{
KdScreenPriv(pCmap->pScreen);
- VisualPtr pVisual;
- xColorItem expanddefs[KD_MAX_PSEUDO_SIZE];
+ VisualPtr pVisual;
+ xColorItem expanddefs[KD_MAX_PSEUDO_SIZE];
if (pCmap != pScreenPriv->pInstalledmap)
- return;
+ return;
if (!pScreenPriv->card->cfuncs->putColors)
- return;
+ return;
if (pScreenPriv->screen->fb.depth > KD_MAX_PSEUDO_DEPTH)
- return;
+ return;
if (!pScreenPriv->enabled)
- return;
+ return;
/* Check for DirectColor or TrueColor being simulated on a PseudoColor device. */
pVisual = pCmap->pVisual;
- if ((pVisual->class | DynamicClass) == DirectColor)
- {
- /*
- * Expand DirectColor or TrueColor color values into a PseudoColor
- * format. Defer to the Color Framebuffer (CFB) code to do that.
- */
- ndef = fbExpandDirectColors(pCmap, ndef, pdefs, expanddefs);
- pdefs = expanddefs;
+ if ((pVisual->class | DynamicClass) == DirectColor) {
+ /*
+ * Expand DirectColor or TrueColor color values into a PseudoColor
+ * format. Defer to the Color Framebuffer (CFB) code to do that.
+ */
+ ndef = fbExpandDirectColors(pCmap, ndef, pdefs, expanddefs);
+ pdefs = expanddefs;
}
(*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, ndef, pdefs);
/* recolor hardware cursor */
if (pScreenPriv->card->cfuncs->recolorCursor)
- (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, ndef, pdefs);
+ (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, ndef,
+ pdefs);
}
diff --git a/xorg-server/hw/kdrive/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c
index f6cc351cd..f65ab96bc 100644
--- a/xorg-server/hw/kdrive/src/kdrive.c
+++ b/xorg-server/hw/kdrive/src/kdrive.c
@@ -46,197 +46,191 @@
#include <signal.h>
typedef struct _kdDepths {
- CARD8 depth;
- CARD8 bpp;
+ CARD8 depth;
+ CARD8 bpp;
} KdDepths;
-KdDepths kdDepths[] = {
- { 1, 1 },
- { 4, 4 },
- { 8, 8 },
- { 15, 16 },
- { 16, 16 },
- { 24, 32 },
- { 32, 32 }
+KdDepths kdDepths[] = {
+ {1, 1},
+ {4, 4},
+ {8, 8},
+ {15, 16},
+ {16, 16},
+ {24, 32},
+ {32, 32}
};
#define NUM_KD_DEPTHS (sizeof (kdDepths) / sizeof (kdDepths[0]))
#define KD_DEFAULT_BUTTONS 5
-DevPrivateKeyRec kdScreenPrivateKeyRec;
-unsigned long kdGeneration;
-
-Bool kdVideoTest;
-unsigned long kdVideoTestTime;
-Bool kdEmulateMiddleButton;
-Bool kdRawPointerCoordinates;
-Bool kdDisableZaphod;
-Bool kdAllowZap;
-Bool kdEnabled;
-int kdSubpixelOrder;
-int kdVirtualTerminal = -1;
-Bool kdSwitchPending;
-char *kdSwitchCmd;
-DDXPointRec kdOrigin;
-Bool kdHasPointer = FALSE;
-Bool kdHasKbd = FALSE;
-
-static Bool kdCaughtSignal = FALSE;
+DevPrivateKeyRec kdScreenPrivateKeyRec;
+unsigned long kdGeneration;
+
+Bool kdVideoTest;
+unsigned long kdVideoTestTime;
+Bool kdEmulateMiddleButton;
+Bool kdRawPointerCoordinates;
+Bool kdDisableZaphod;
+Bool kdAllowZap;
+Bool kdEnabled;
+int kdSubpixelOrder;
+int kdVirtualTerminal = -1;
+Bool kdSwitchPending;
+char *kdSwitchCmd;
+DDXPointRec kdOrigin;
+Bool kdHasPointer = FALSE;
+Bool kdHasKbd = FALSE;
+
+static Bool kdCaughtSignal = FALSE;
/*
* Carry arguments from InitOutput through driver initialization
* to KdScreenInit
*/
-KdOsFuncs *kdOsFuncs;
+KdOsFuncs *kdOsFuncs;
void
-KdDisableScreen (ScreenPtr pScreen)
+KdDisableScreen(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
if (!pScreenPriv->enabled)
- return;
+ return;
if (!pScreenPriv->closed)
- SetRootClip (pScreen, FALSE);
- KdDisableColormap (pScreen);
+ SetRootClip(pScreen, FALSE);
+ KdDisableColormap(pScreen);
if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->disableAccel)
- (*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
- if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->disableCursor)
- (*pScreenPriv->card->cfuncs->disableCursor) (pScreen);
+ (*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
+ if (!pScreenPriv->screen->softCursor &&
+ pScreenPriv->card->cfuncs->disableCursor)
+ (*pScreenPriv->card->cfuncs->disableCursor) (pScreen);
if (pScreenPriv->card->cfuncs->dpms)
- (*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
pScreenPriv->enabled = FALSE;
- if(pScreenPriv->card->cfuncs->disable)
+ if (pScreenPriv->card->cfuncs->disable)
(*pScreenPriv->card->cfuncs->disable) (pScreen);
}
static void
-KdDoSwitchCmd (const char *reason)
+KdDoSwitchCmd(const char *reason)
{
- if (kdSwitchCmd)
- {
- char *command;
-
- if (asprintf(&command, "%s %s", kdSwitchCmd, reason) == -1)
- return;
- system (command);
- free(command);
+ if (kdSwitchCmd) {
+ char *command;
+
+ if (asprintf(&command, "%s %s", kdSwitchCmd, reason) == -1)
+ return;
+ system(command);
+ free(command);
}
}
void
-KdSuspend (void)
+KdSuspend(void)
{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (kdEnabled)
- {
- for (card = kdCardInfo; card; card = card->next)
- {
- for (screen = card->screenList; screen; screen = screen->next)
- if (screen->mynum == card->selected && screen->pScreen)
- KdDisableScreen (screen->pScreen);
- if (card->driver && card->cfuncs->restore)
- (*card->cfuncs->restore) (card);
- }
- KdDisableInput ();
- KdDoSwitchCmd ("suspend");
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (kdEnabled) {
+ for (card = kdCardInfo; card; card = card->next) {
+ for (screen = card->screenList; screen; screen = screen->next)
+ if (screen->mynum == card->selected && screen->pScreen)
+ KdDisableScreen(screen->pScreen);
+ if (card->driver && card->cfuncs->restore)
+ (*card->cfuncs->restore) (card);
+ }
+ KdDisableInput();
+ KdDoSwitchCmd("suspend");
}
}
void
-KdDisableScreens (void)
+KdDisableScreens(void)
{
- KdSuspend ();
- if (kdEnabled)
- {
+ KdSuspend();
+ if (kdEnabled) {
if (kdOsFuncs->Disable)
(*kdOsFuncs->Disable) ();
- kdEnabled = FALSE;
+ kdEnabled = FALSE;
}
}
Bool
-KdEnableScreen (ScreenPtr pScreen)
+KdEnableScreen(ScreenPtr pScreen)
{
- KdScreenPriv (pScreen);
+ KdScreenPriv(pScreen);
if (pScreenPriv->enabled)
- return TRUE;
- if(pScreenPriv->card->cfuncs->enable)
- if (!(*pScreenPriv->card->cfuncs->enable) (pScreen))
- return FALSE;
+ return TRUE;
+ if (pScreenPriv->card->cfuncs->enable)
+ if (!(*pScreenPriv->card->cfuncs->enable) (pScreen))
+ return FALSE;
pScreenPriv->enabled = TRUE;
pScreenPriv->dpmsState = KD_DPMS_NORMAL;
pScreenPriv->card->selected = pScreenPriv->screen->mynum;
- if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->enableCursor)
- (*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
+ if (!pScreenPriv->screen->softCursor &&
+ pScreenPriv->card->cfuncs->enableCursor)
+ (*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->enableAccel)
- (*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
- KdEnableColormap (pScreen);
- SetRootClip (pScreen, TRUE);
+ (*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
+ KdEnableColormap(pScreen);
+ SetRootClip(pScreen, TRUE);
if (pScreenPriv->card->cfuncs->dpms)
- (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState);
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState);
return TRUE;
}
void
-KdResume (void)
+KdResume(void)
{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (kdEnabled)
- {
- KdDoSwitchCmd ("resume");
- for (card = kdCardInfo; card; card = card->next)
- {
- if(card->cfuncs->preserve)
- (*card->cfuncs->preserve) (card);
- for (screen = card->screenList; screen; screen = screen->next)
- if (screen->mynum == card->selected && screen->pScreen)
- KdEnableScreen (screen->pScreen);
- }
- KdEnableInput ();
- KdReleaseAllKeys ();
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (kdEnabled) {
+ KdDoSwitchCmd("resume");
+ for (card = kdCardInfo; card; card = card->next) {
+ if (card->cfuncs->preserve)
+ (*card->cfuncs->preserve) (card);
+ for (screen = card->screenList; screen; screen = screen->next)
+ if (screen->mynum == card->selected && screen->pScreen)
+ KdEnableScreen(screen->pScreen);
+ }
+ KdEnableInput();
+ KdReleaseAllKeys();
}
}
void
-KdEnableScreens (void)
+KdEnableScreens(void)
{
- if (!kdEnabled)
- {
- kdEnabled = TRUE;
+ if (!kdEnabled) {
+ kdEnabled = TRUE;
if (kdOsFuncs->Enable)
(*kdOsFuncs->Enable) ();
}
- KdResume ();
+ KdResume();
}
void
-KdProcessSwitch (void)
+KdProcessSwitch(void)
{
if (kdEnabled)
- KdDisableScreens ();
+ KdDisableScreens();
else
- KdEnableScreens ();
+ KdEnableScreens();
}
void
AbortDDX(enum ExitCode error)
{
- KdDisableScreens ();
- if (kdOsFuncs)
- {
- if (kdEnabled && kdOsFuncs->Disable)
- (*kdOsFuncs->Disable) ();
+ KdDisableScreens();
+ if (kdOsFuncs) {
+ if (kdEnabled && kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
if (kdOsFuncs->Fini)
(*kdOsFuncs->Fini) ();
- KdDoSwitchCmd ("stop");
+ KdDoSwitchCmd("stop");
}
if (kdCaughtSignal)
@@ -244,58 +238,56 @@ AbortDDX(enum ExitCode error)
}
void
-ddxGiveUp (enum ExitCode error)
+ddxGiveUp(enum ExitCode error)
{
- AbortDDX (error);
+ AbortDDX(error);
}
-Bool kdDumbDriver;
-Bool kdSoftCursor;
+Bool kdDumbDriver;
+Bool kdSoftCursor;
char *
-KdParseFindNext (char *cur, const char *delim, char *save, char *last)
+KdParseFindNext(char *cur, const char *delim, char *save, char *last)
{
- while (*cur && !strchr (delim, *cur))
- {
- *save++ = *cur++;
+ while (*cur && !strchr(delim, *cur)) {
+ *save++ = *cur++;
}
*save = 0;
*last = *cur;
if (*cur)
- cur++;
+ cur++;
return cur;
}
Rotation
-KdAddRotation (Rotation a, Rotation b)
+KdAddRotation(Rotation a, Rotation b)
{
- Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All);
- Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+ Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
if (rotate > RR_Rotate_270)
- rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
return reflect | rotate;
}
Rotation
-KdSubRotation (Rotation a, Rotation b)
+KdSubRotation(Rotation a, Rotation b)
{
- Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All);
- Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+ Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
if (rotate > RR_Rotate_270)
- rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
return reflect | rotate;
}
void
-KdParseScreen (KdScreenInfo *screen,
- char *arg)
+KdParseScreen(KdScreenInfo * screen, char *arg)
{
- char delim;
- char save[1024];
- int i;
- int pixels, mm;
+ char delim;
+ char save[1024];
+ int i;
+ int pixels, mm;
screen->dumb = kdDumbDriver;
screen->softCursor = kdSoftCursor;
@@ -309,39 +301,35 @@ KdParseScreen (KdScreenInfo *screen,
screen->rate = 0;
screen->fb.depth = 0;
if (!arg)
- return;
- if (strlen (arg) >= sizeof (save))
- return;
-
- for (i = 0; i < 2; i++)
- {
- arg = KdParseFindNext (arg, "x/@XY", save, &delim);
- if (!save[0])
- return;
-
- pixels = atoi(save);
- mm = 0;
-
- if (delim == '/')
- {
- arg = KdParseFindNext (arg, "x@XY", save, &delim);
- if (!save[0])
- return;
- mm = atoi(save);
- }
-
- if (i == 0)
- {
- screen->width = pixels;
- screen->width_mm = mm;
- }
- else
- {
- screen->height = pixels;
- screen->height_mm = mm;
- }
- if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y')
- return;
+ return;
+ if (strlen(arg) >= sizeof(save))
+ return;
+
+ for (i = 0; i < 2; i++) {
+ arg = KdParseFindNext(arg, "x/@XY", save, &delim);
+ if (!save[0])
+ return;
+
+ pixels = atoi(save);
+ mm = 0;
+
+ if (delim == '/') {
+ arg = KdParseFindNext(arg, "x@XY", save, &delim);
+ if (!save[0])
+ return;
+ mm = atoi(save);
+ }
+
+ if (i == 0) {
+ screen->width = pixels;
+ screen->width_mm = mm;
+ }
+ else {
+ screen->height = pixels;
+ screen->height_mm = mm;
+ }
+ if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y')
+ return;
}
kdOrigin.x += screen->width;
@@ -350,55 +338,49 @@ KdParseScreen (KdScreenInfo *screen,
kdSoftCursor = FALSE;
kdSubpixelOrder = SubPixelUnknown;
- if (delim == '@')
- {
- arg = KdParseFindNext (arg, "xXY", save, &delim);
- if (save[0])
- {
- int rotate = atoi (save);
- if (rotate < 45)
- screen->randr = RR_Rotate_0;
- else if (rotate < 135)
- screen->randr = RR_Rotate_90;
- else if (rotate < 225)
- screen->randr = RR_Rotate_180;
- else if (rotate < 315)
- screen->randr = RR_Rotate_270;
- else
- screen->randr = RR_Rotate_0;
- }
+ if (delim == '@') {
+ arg = KdParseFindNext(arg, "xXY", save, &delim);
+ if (save[0]) {
+ int rotate = atoi(save);
+
+ if (rotate < 45)
+ screen->randr = RR_Rotate_0;
+ else if (rotate < 135)
+ screen->randr = RR_Rotate_90;
+ else if (rotate < 225)
+ screen->randr = RR_Rotate_180;
+ else if (rotate < 315)
+ screen->randr = RR_Rotate_270;
+ else
+ screen->randr = RR_Rotate_0;
+ }
}
- if (delim == 'X')
- {
- arg = KdParseFindNext (arg, "xY", save, &delim);
- screen->randr |= RR_Reflect_X;
+ if (delim == 'X') {
+ arg = KdParseFindNext(arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_X;
}
- if (delim == 'Y')
- {
- arg = KdParseFindNext (arg, "xY", save, &delim);
- screen->randr |= RR_Reflect_Y;
+ if (delim == 'Y') {
+ arg = KdParseFindNext(arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_Y;
}
- arg = KdParseFindNext (arg, "x/,", save, &delim);
- if (save[0])
- {
- screen->fb.depth = atoi(save);
- if (delim == '/')
- {
- arg = KdParseFindNext (arg, "x,", save, &delim);
- if (save[0])
- screen->fb.bitsPerPixel = atoi (save);
- }
- else
- screen->fb.bitsPerPixel = 0;
+ arg = KdParseFindNext(arg, "x/,", save, &delim);
+ if (save[0]) {
+ screen->fb.depth = atoi(save);
+ if (delim == '/') {
+ arg = KdParseFindNext(arg, "x,", save, &delim);
+ if (save[0])
+ screen->fb.bitsPerPixel = atoi(save);
+ }
+ else
+ screen->fb.bitsPerPixel = 0;
}
- if (delim == 'x')
- {
- arg = KdParseFindNext (arg, "x", save, &delim);
- if (save[0])
- screen->rate = atoi(save);
+ if (delim == 'x') {
+ arg = KdParseFindNext(arg, "x", save, &delim);
+ if (save[0])
+ screen->rate = atoi(save);
}
}
@@ -414,162 +396,154 @@ KdParseScreen (KdScreenInfo *screen,
*/
void
-KdParseRgba (char *rgba)
+KdParseRgba(char *rgba)
{
- if (!strcmp (rgba, "rgb"))
- kdSubpixelOrder = SubPixelHorizontalRGB;
- else if (!strcmp (rgba, "bgr"))
- kdSubpixelOrder = SubPixelHorizontalBGR;
- else if (!strcmp (rgba, "vrgb"))
- kdSubpixelOrder = SubPixelVerticalRGB;
- else if (!strcmp (rgba, "vbgr"))
- kdSubpixelOrder = SubPixelVerticalBGR;
- else if (!strcmp (rgba, "none"))
- kdSubpixelOrder = SubPixelNone;
+ if (!strcmp(rgba, "rgb"))
+ kdSubpixelOrder = SubPixelHorizontalRGB;
+ else if (!strcmp(rgba, "bgr"))
+ kdSubpixelOrder = SubPixelHorizontalBGR;
+ else if (!strcmp(rgba, "vrgb"))
+ kdSubpixelOrder = SubPixelVerticalRGB;
+ else if (!strcmp(rgba, "vbgr"))
+ kdSubpixelOrder = SubPixelVerticalBGR;
+ else if (!strcmp(rgba, "none"))
+ kdSubpixelOrder = SubPixelNone;
else
- kdSubpixelOrder = SubPixelUnknown;
+ kdSubpixelOrder = SubPixelUnknown;
}
void
-KdUseMsg (void)
+KdUseMsg(void)
{
ErrorF("\nTinyX Device Dependent Usage:\n");
- ErrorF("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n");
- ErrorF("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
- ErrorF("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n");
- ErrorF("-keybd driver [,,options] Specify the keyboard driver and its options\n");
+ ErrorF
+ ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n");
+ ErrorF
+ ("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
+ ErrorF
+ ("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n");
+ ErrorF
+ ("-keybd driver [,,options] Specify the keyboard driver and its options\n");
ErrorF("-zaphod Disable cursor screen switching\n");
ErrorF("-2button Emulate 3 button mouse\n");
ErrorF("-3button Disable 3 button mouse emulation\n");
- ErrorF("-rawcoord Don't transform pointer coordinates on rotation\n");
+ ErrorF
+ ("-rawcoord Don't transform pointer coordinates on rotation\n");
ErrorF("-dumb Disable hardware acceleration\n");
ErrorF("-softCursor Force software cursor\n");
ErrorF("-videoTest Start the server, pause momentarily and exit\n");
- ErrorF("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n");
+ ErrorF
+ ("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n");
ErrorF("-switchCmd Command to execute on vt switch\n");
ErrorF("-zap Terminate server on Ctrl+Alt+Backspace\n");
- ErrorF("vtxx Use virtual terminal xx instead of the next available\n");
+ ErrorF
+ ("vtxx Use virtual terminal xx instead of the next available\n");
}
int
-KdProcessArgument (int argc, char **argv, int i)
+KdProcessArgument(int argc, char **argv, int i)
{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (!strcmp (argv[i], "-screen"))
- {
- if ((i+1) < argc)
- {
- card = KdCardInfoLast ();
- if (!card)
- {
- InitCard (0);
- card = KdCardInfoLast ();
- }
- if (card) {
- screen = KdScreenInfoAdd (card);
- KdParseScreen (screen, argv[i+1]);
- } else
- ErrorF("No matching card found!\n");
- }
- else
- UseMsg ();
- return 2;
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (!strcmp(argv[i], "-screen")) {
+ if ((i + 1) < argc) {
+ card = KdCardInfoLast();
+ if (!card) {
+ InitCard(0);
+ card = KdCardInfoLast();
+ }
+ if (card) {
+ screen = KdScreenInfoAdd(card);
+ KdParseScreen(screen, argv[i + 1]);
+ }
+ else
+ ErrorF("No matching card found!\n");
+ }
+ else
+ UseMsg();
+ return 2;
}
- if (!strcmp (argv[i], "-zaphod"))
- {
- kdDisableZaphod = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-zaphod")) {
+ kdDisableZaphod = TRUE;
+ return 1;
}
- if (!strcmp (argv[i], "-zap"))
- {
- kdAllowZap = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-zap")) {
+ kdAllowZap = TRUE;
+ return 1;
}
- if (!strcmp (argv[i], "-3button"))
- {
- kdEmulateMiddleButton = FALSE;
- return 1;
+ if (!strcmp(argv[i], "-3button")) {
+ kdEmulateMiddleButton = FALSE;
+ return 1;
}
- if (!strcmp (argv[i], "-2button"))
- {
- kdEmulateMiddleButton = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-2button")) {
+ kdEmulateMiddleButton = TRUE;
+ return 1;
}
- if (!strcmp (argv[i], "-rawcoord"))
- {
- kdRawPointerCoordinates = 1;
- return 1;
+ if (!strcmp(argv[i], "-rawcoord")) {
+ kdRawPointerCoordinates = 1;
+ return 1;
}
- if (!strcmp (argv[i], "-dumb"))
- {
- kdDumbDriver = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-dumb")) {
+ kdDumbDriver = TRUE;
+ return 1;
}
- if (!strcmp (argv[i], "-softCursor"))
- {
- kdSoftCursor = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-softCursor")) {
+ kdSoftCursor = TRUE;
+ return 1;
}
- if (!strcmp (argv[i], "-videoTest"))
- {
- kdVideoTest = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-videoTest")) {
+ kdVideoTest = TRUE;
+ return 1;
}
- if (!strcmp (argv[i], "-origin"))
- {
- if ((i+1) < argc)
- {
- char *x = argv[i+1];
- char *y = strchr (x, ',');
- if (x)
- kdOrigin.x = atoi (x);
- else
- kdOrigin.x = 0;
- if (y)
- kdOrigin.y = atoi(y+1);
- else
- kdOrigin.y = 0;
- }
- else
- UseMsg ();
- return 2;
+ if (!strcmp(argv[i], "-origin")) {
+ if ((i + 1) < argc) {
+ char *x = argv[i + 1];
+ char *y = strchr(x, ',');
+
+ if (x)
+ kdOrigin.x = atoi(x);
+ else
+ kdOrigin.x = 0;
+ if (y)
+ kdOrigin.y = atoi(y + 1);
+ else
+ kdOrigin.y = 0;
+ }
+ else
+ UseMsg();
+ return 2;
}
- if (!strcmp (argv[i], "-rgba"))
- {
- if ((i+1) < argc)
- KdParseRgba (argv[i+1]);
- else
- UseMsg ();
- return 2;
+ if (!strcmp(argv[i], "-rgba")) {
+ if ((i + 1) < argc)
+ KdParseRgba(argv[i + 1]);
+ else
+ UseMsg();
+ return 2;
}
- if (!strcmp (argv[i], "-switchCmd"))
- {
- if ((i+1) < argc)
- kdSwitchCmd = argv[i+1];
- else
- UseMsg ();
- return 2;
+ if (!strcmp(argv[i], "-switchCmd")) {
+ if ((i + 1) < argc)
+ kdSwitchCmd = argv[i + 1];
+ else
+ UseMsg();
+ return 2;
}
- if (!strncmp (argv[i], "vt", 2) &&
- sscanf (argv[i], "vt%2d", &kdVirtualTerminal) == 1)
- {
- return 1;
+ if (!strncmp(argv[i], "vt", 2) &&
+ sscanf(argv[i], "vt%2d", &kdVirtualTerminal) == 1) {
+ return 1;
}
- if (!strcmp (argv[i], "-mouse") ||
- !strcmp (argv[i], "-pointer")) {
+ if (!strcmp(argv[i], "-mouse") || !strcmp(argv[i], "-pointer")) {
if (i + 1 >= argc)
UseMsg();
KdAddConfigPointer(argv[i + 1]);
- kdHasPointer = TRUE;
+ kdHasPointer = TRUE;
return 2;
}
- if (!strcmp (argv[i], "-keybd")) {
+ if (!strcmp(argv[i], "-keybd")) {
if (i + 1 >= argc)
UseMsg();
KdAddConfigKeyboard(argv[i + 1]);
- kdHasKbd = TRUE;
+ kdHasKbd = TRUE;
return 2;
}
@@ -582,116 +556,110 @@ KdProcessArgument (int argc, char **argv, int i)
*/
void
-KdOsInit (KdOsFuncs *pOsFuncs)
+KdOsInit(KdOsFuncs * pOsFuncs)
{
kdOsFuncs = pOsFuncs;
- if (pOsFuncs)
- {
- if (serverGeneration == 1)
- {
- KdDoSwitchCmd ("start");
+ if (pOsFuncs) {
+ if (serverGeneration == 1) {
+ KdDoSwitchCmd("start");
if (pOsFuncs->Init)
(*pOsFuncs->Init) ();
- }
+ }
}
}
Bool
-KdAllocatePrivates (ScreenPtr pScreen)
+KdAllocatePrivates(ScreenPtr pScreen)
{
- KdPrivScreenPtr pScreenPriv;
+ KdPrivScreenPtr pScreenPriv;
if (kdGeneration != serverGeneration)
- kdGeneration = serverGeneration;
+ kdGeneration = serverGeneration;
if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
- pScreenPriv = calloc(1, sizeof (*pScreenPriv));
+ pScreenPriv = calloc(1, sizeof(*pScreenPriv));
if (!pScreenPriv)
- return FALSE;
- KdSetScreenPriv (pScreen, pScreenPriv);
+ return FALSE;
+ KdSetScreenPriv(pScreen, pScreenPriv);
return TRUE;
}
Bool
-KdCreateScreenResources (ScreenPtr pScreen)
+KdCreateScreenResources(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- KdCardInfo *card = pScreenPriv->card;
+ KdCardInfo *card = pScreenPriv->card;
Bool ret;
pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources;
- if(pScreen->CreateScreenResources)
- ret = (*pScreen->CreateScreenResources) (pScreen);
+ if (pScreen->CreateScreenResources)
+ ret = (*pScreen->CreateScreenResources) (pScreen);
else
- ret= -1;
+ ret = -1;
pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
pScreen->CreateScreenResources = KdCreateScreenResources;
if (ret && card->cfuncs->createRes)
- ret = (*card->cfuncs->createRes) (pScreen);
+ ret = (*card->cfuncs->createRes) (pScreen);
return ret;
}
Bool
-KdCloseScreen (int index, ScreenPtr pScreen)
+KdCloseScreen(int index, ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- KdCardInfo *card = pScreenPriv->card;
- Bool ret;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = pScreenPriv->card;
+ Bool ret;
pScreenPriv->closed = TRUE;
pScreen->CloseScreen = pScreenPriv->CloseScreen;
- if(pScreen->CloseScreen)
+ if (pScreen->CloseScreen)
ret = (*pScreen->CloseScreen) (index, pScreen);
else
- ret = TRUE;
+ ret = TRUE;
if (pScreenPriv->dpmsState != KD_DPMS_NORMAL)
- (*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
+ (*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
if (screen->mynum == card->selected)
- KdDisableScreen (pScreen);
+ KdDisableScreen(pScreen);
/*
* Restore video hardware when last screen is closed
*/
- if (screen == card->screenList)
- {
- if (kdEnabled && card->cfuncs->restore)
- (*card->cfuncs->restore) (card);
+ if (screen == card->screenList) {
+ if (kdEnabled && card->cfuncs->restore)
+ (*card->cfuncs->restore) (card);
}
if (!pScreenPriv->screen->dumb && card->cfuncs->finiAccel)
- (*card->cfuncs->finiAccel) (pScreen);
+ (*card->cfuncs->finiAccel) (pScreen);
if (!pScreenPriv->screen->softCursor && card->cfuncs->finiCursor)
- (*card->cfuncs->finiCursor) (pScreen);
+ (*card->cfuncs->finiCursor) (pScreen);
- if(card->cfuncs->scrfini)
+ if (card->cfuncs->scrfini)
(*card->cfuncs->scrfini) (screen);
/*
* Clean up card when last screen is closed, DIX closes them in
* reverse order, thus we check for when the first in the list is closed
*/
- if (screen == card->screenList)
- {
- if(card->cfuncs->cardfini)
- (*card->cfuncs->cardfini) (card);
- /*
- * Clean up OS when last card is closed
- */
- if (card == kdCardInfo)
- {
- if (kdEnabled)
- {
- kdEnabled = FALSE;
- if(kdOsFuncs->Disable)
- (*kdOsFuncs->Disable) ();
- }
- }
+ if (screen == card->screenList) {
+ if (card->cfuncs->cardfini)
+ (*card->cfuncs->cardfini) (card);
+ /*
+ * Clean up OS when last card is closed
+ */
+ if (card == kdCardInfo) {
+ if (kdEnabled) {
+ kdEnabled = FALSE;
+ if (kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ }
+ }
}
pScreenPriv->screen->pScreen = 0;
@@ -701,112 +669,107 @@ KdCloseScreen (int index, ScreenPtr pScreen)
}
Bool
-KdSaveScreen (ScreenPtr pScreen, int on)
+KdSaveScreen(ScreenPtr pScreen, int on)
{
KdScreenPriv(pScreen);
- int dpmsState;
+ int dpmsState;
if (!pScreenPriv->card->cfuncs->dpms)
- return FALSE;
+ return FALSE;
dpmsState = pScreenPriv->dpmsState;
switch (on) {
case SCREEN_SAVER_OFF:
- dpmsState = KD_DPMS_NORMAL;
- break;
+ dpmsState = KD_DPMS_NORMAL;
+ break;
case SCREEN_SAVER_ON:
- if (dpmsState == KD_DPMS_NORMAL)
- dpmsState = KD_DPMS_NORMAL+1;
- break;
+ if (dpmsState == KD_DPMS_NORMAL)
+ dpmsState = KD_DPMS_NORMAL + 1;
+ break;
case SCREEN_SAVER_CYCLE:
- if (dpmsState < KD_DPMS_MAX)
- dpmsState++;
- break;
+ if (dpmsState < KD_DPMS_MAX)
+ dpmsState++;
+ break;
case SCREEN_SAVER_FORCER:
- break;
+ break;
}
- if (dpmsState != pScreenPriv->dpmsState)
- {
- if (pScreenPriv->enabled)
- (*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState);
- pScreenPriv->dpmsState = dpmsState;
+ if (dpmsState != pScreenPriv->dpmsState) {
+ if (pScreenPriv->enabled)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState);
+ pScreenPriv->dpmsState = dpmsState;
}
return TRUE;
}
static Bool
-KdCreateWindow (WindowPtr pWin)
+KdCreateWindow(WindowPtr pWin)
{
#ifndef PHOENIX
- if (!pWin->parent)
- {
- KdScreenPriv(pWin->drawable.pScreen);
-
- if (!pScreenPriv->enabled)
- {
- RegionEmpty(&pWin->borderClip);
- RegionBreak(&pWin->clipList);
- }
+ if (!pWin->parent) {
+ KdScreenPriv(pWin->drawable.pScreen);
+
+ if (!pScreenPriv->enabled) {
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
+ }
}
#endif
- return fbCreateWindow (pWin);
+ return fbCreateWindow(pWin);
}
void
-KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr)
+KdSetSubpixelOrder(ScreenPtr pScreen, Rotation randr)
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- int subpixel_order = screen->subpixel_order;
- Rotation subpixel_dir;
- int i;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int subpixel_order = screen->subpixel_order;
+ Rotation subpixel_dir;
+ int i;
static struct {
- int subpixel_order;
- Rotation direction;
+ int subpixel_order;
+ Rotation direction;
} orders[] = {
- { SubPixelHorizontalRGB, RR_Rotate_0 },
- { SubPixelHorizontalBGR, RR_Rotate_180 },
- { SubPixelVerticalRGB, RR_Rotate_270 },
- { SubPixelVerticalBGR, RR_Rotate_90 },
- };
+ {
+ SubPixelHorizontalRGB, RR_Rotate_0}, {
+ SubPixelHorizontalBGR, RR_Rotate_180}, {
+ SubPixelVerticalRGB, RR_Rotate_270}, {
+ SubPixelVerticalBGR, RR_Rotate_90},};
static struct {
- int bit;
- int normal;
- int reflect;
+ int bit;
+ int normal;
+ int reflect;
} reflects[] = {
- { RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR },
- { RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB },
- { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR },
- { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB },
- };
+ {
+ RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR}, {
+ RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB}, {
+ RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR}, {
+ RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB},};
/* map subpixel to direction */
for (i = 0; i < 4; i++)
- if (orders[i].subpixel_order == subpixel_order)
- break;
- if (i < 4)
- {
- subpixel_dir = KdAddRotation (randr & RR_Rotate_All, orders[i].direction);
-
- /* map back to subpixel order */
- for (i = 0; i < 4; i++)
- if (orders[i].direction & subpixel_dir)
- {
- subpixel_order = orders[i].subpixel_order;
- break;
- }
- /* reflect */
- for (i = 0; i < 4; i++)
- if ((randr & reflects[i].bit) &&
- reflects[i].normal == subpixel_order)
- {
- subpixel_order = reflects[i].reflect;
- break;
- }
+ if (orders[i].subpixel_order == subpixel_order)
+ break;
+ if (i < 4) {
+ subpixel_dir =
+ KdAddRotation(randr & RR_Rotate_All, orders[i].direction);
+
+ /* map back to subpixel order */
+ for (i = 0; i < 4; i++)
+ if (orders[i].direction & subpixel_dir) {
+ subpixel_order = orders[i].subpixel_order;
+ break;
+ }
+ /* reflect */
+ for (i = 0; i < 4; i++)
+ if ((randr & reflects[i].bit) &&
+ reflects[i].normal == subpixel_order) {
+ subpixel_order = reflects[i].reflect;
+ break;
+ }
}
- PictureSetSubpixelOrder (pScreen, subpixel_order);
+ PictureSetSubpixelOrder(pScreen, subpixel_order);
}
/* Pass through AddScreen, which doesn't take any closure */
@@ -815,34 +778,33 @@ static KdScreenInfo *kdCurrentScreen;
Bool
KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
{
- KdScreenInfo *screen = kdCurrentScreen;
- KdCardInfo *card = screen->card;
- KdPrivScreenPtr pScreenPriv;
+ KdScreenInfo *screen = kdCurrentScreen;
+ KdCardInfo *card = screen->card;
+ KdPrivScreenPtr pScreenPriv;
+
/*
* note that screen->fb is set up for the nominal orientation
* of the screen; that means if randr is rotated, the values
* there should reflect a rotated frame buffer (or shadow).
*/
- Bool rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0;
- int width, height, *width_mmp, *height_mmp;
+ Bool rotated = (screen->randr & (RR_Rotate_90 | RR_Rotate_270)) != 0;
+ int width, height, *width_mmp, *height_mmp;
- KdAllocatePrivates (pScreen);
+ KdAllocatePrivates(pScreen);
pScreenPriv = KdGetScreenPriv(pScreen);
- if (!rotated)
- {
- width = screen->width;
- height = screen->height;
- width_mmp = &screen->width_mm;
- height_mmp = &screen->height_mm;
+ if (!rotated) {
+ width = screen->width;
+ height = screen->height;
+ width_mmp = &screen->width_mm;
+ height_mmp = &screen->height_mm;
}
- else
- {
- width = screen->height;
- height = screen->width;
- width_mmp = &screen->height_mm;
- height_mmp = &screen->width_mm;
+ else {
+ width = screen->height;
+ height = screen->width;
+ width_mmp = &screen->height_mm;
+ height_mmp = &screen->width_mm;
}
screen->pScreen = pScreen;
pScreenPriv->screen = screen;
@@ -853,41 +815,37 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->y = screen->origin.y;
if (!monitorResolution)
- monitorResolution = 75;
+ monitorResolution = 75;
/*
* This is done in this order so that backing store wraps
* our GC functions; fbFinishScreenInit initializes MI
* backing store
*/
- if (!fbSetupScreen (pScreen,
- screen->fb.frameBuffer,
- width, height,
- monitorResolution, monitorResolution,
- screen->fb.pixelStride,
- screen->fb.bitsPerPixel))
- {
- return FALSE;
+ if (!fbSetupScreen(pScreen,
+ screen->fb.frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb.pixelStride, screen->fb.bitsPerPixel)) {
+ return FALSE;
}
/*
* Set colormap functions
*/
- pScreen->InstallColormap = KdInstallColormap;
- pScreen->UninstallColormap = KdUninstallColormap;
+ pScreen->InstallColormap = KdInstallColormap;
+ pScreen->UninstallColormap = KdUninstallColormap;
pScreen->ListInstalledColormaps = KdListInstalledColormaps;
- pScreen->StoreColors = KdStoreColors;
-
- pScreen->SaveScreen = KdSaveScreen;
- pScreen->CreateWindow = KdCreateWindow;
-
- if (!fbFinishScreenInit (pScreen,
- screen->fb.frameBuffer,
- width, height,
- monitorResolution, monitorResolution,
- screen->fb.pixelStride,
- screen->fb.bitsPerPixel))
- {
- return FALSE;
+ pScreen->StoreColors = KdStoreColors;
+
+ pScreen->SaveScreen = KdSaveScreen;
+ pScreen->CreateWindow = KdCreateWindow;
+
+ if (!fbFinishScreenInit(pScreen,
+ screen->fb.frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb.pixelStride, screen->fb.bitsPerPixel)) {
+ return FALSE;
}
/*
@@ -895,44 +853,44 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
* Rounding errors are annoying
*/
if (*width_mmp)
- pScreen->mmWidth = *width_mmp;
+ pScreen->mmWidth = *width_mmp;
else
- *width_mmp = pScreen->mmWidth;
+ *width_mmp = pScreen->mmWidth;
if (*height_mmp)
- pScreen->mmHeight = *height_mmp;
+ pScreen->mmHeight = *height_mmp;
else
- *height_mmp = pScreen->mmHeight;
+ *height_mmp = pScreen->mmHeight;
/*
* Plug in our own block/wakeup handlers.
* miScreenInit installs NoopDDA in both places
*/
- pScreen->BlockHandler = KdBlockHandler;
- pScreen->WakeupHandler = KdWakeupHandler;
+ pScreen->BlockHandler = KdBlockHandler;
+ pScreen->WakeupHandler = KdWakeupHandler;
- if (!fbPictureInit (pScreen, 0, 0))
- return FALSE;
+ if (!fbPictureInit(pScreen, 0, 0))
+ return FALSE;
if (card->cfuncs->initScreen)
- if (!(*card->cfuncs->initScreen) (pScreen))
- return FALSE;
+ if (!(*card->cfuncs->initScreen) (pScreen))
+ return FALSE;
if (!screen->dumb && card->cfuncs->initAccel)
- if (!(*card->cfuncs->initAccel) (pScreen))
- screen->dumb = TRUE;
+ if (!(*card->cfuncs->initAccel) (pScreen))
+ screen->dumb = TRUE;
if (card->cfuncs->finishInitScreen)
- if (!(*card->cfuncs->finishInitScreen) (pScreen))
- return FALSE;
+ if (!(*card->cfuncs->finishInitScreen) (pScreen))
+ return FALSE;
#if 0
- fbInitValidateTree (pScreen);
+ fbInitValidateTree(pScreen);
#endif
/*
* Wrap CloseScreen, the order now is:
- * KdCloseScreen
- * miBSCloseScreen
- * fbCloseScreen
+ * KdCloseScreen
+ * miBSCloseScreen
+ * fbCloseScreen
*/
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = KdCloseScreen;
@@ -941,78 +899,70 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->CreateScreenResources = KdCreateScreenResources;
if (screen->softCursor ||
- !card->cfuncs->initCursor ||
- !(*card->cfuncs->initCursor) (pScreen))
- {
- /* Use MI for cursor display and event queueing. */
- screen->softCursor = TRUE;
- miDCInitialize(pScreen, &kdPointerScreenFuncs);
+ !card->cfuncs->initCursor || !(*card->cfuncs->initCursor) (pScreen)) {
+ /* Use MI for cursor display and event queueing. */
+ screen->softCursor = TRUE;
+ miDCInitialize(pScreen, &kdPointerScreenFuncs);
}
-
- if (!fbCreateDefColormap (pScreen))
- {
- return FALSE;
+ if (!fbCreateDefColormap(pScreen)) {
+ return FALSE;
}
- KdSetSubpixelOrder (pScreen, screen->randr);
+ KdSetSubpixelOrder(pScreen, screen->randr);
/*
* Enable the hardware
*/
- if (!kdEnabled)
- {
- kdEnabled = TRUE;
- if(kdOsFuncs->Enable)
- (*kdOsFuncs->Enable) ();
+ if (!kdEnabled) {
+ kdEnabled = TRUE;
+ if (kdOsFuncs->Enable)
+ (*kdOsFuncs->Enable) ();
}
- if (screen->mynum == card->selected)
- {
- if(card->cfuncs->preserve)
- (*card->cfuncs->preserve) (card);
- if(card->cfuncs->enable)
- if (!(*card->cfuncs->enable) (pScreen))
- return FALSE;
- pScreenPriv->enabled = TRUE;
- if (!screen->softCursor && card->cfuncs->enableCursor)
- (*card->cfuncs->enableCursor) (pScreen);
- KdEnableColormap (pScreen);
- if (!screen->dumb && card->cfuncs->enableAccel)
- (*card->cfuncs->enableAccel) (pScreen);
+ if (screen->mynum == card->selected) {
+ if (card->cfuncs->preserve)
+ (*card->cfuncs->preserve) (card);
+ if (card->cfuncs->enable)
+ if (!(*card->cfuncs->enable) (pScreen))
+ return FALSE;
+ pScreenPriv->enabled = TRUE;
+ if (!screen->softCursor && card->cfuncs->enableCursor)
+ (*card->cfuncs->enableCursor) (pScreen);
+ KdEnableColormap(pScreen);
+ if (!screen->dumb && card->cfuncs->enableAccel)
+ (*card->cfuncs->enableAccel) (pScreen);
}
return TRUE;
}
void
-KdInitScreen (ScreenInfo *pScreenInfo,
- KdScreenInfo *screen,
- int argc,
- char **argv)
+KdInitScreen(ScreenInfo * pScreenInfo,
+ KdScreenInfo * screen, int argc, char **argv)
{
- KdCardInfo *card = screen->card;
+ KdCardInfo *card = screen->card;
(*card->cfuncs->scrinit) (screen);
if (!card->cfuncs->initAccel)
- screen->dumb = TRUE;
+ screen->dumb = TRUE;
if (!card->cfuncs->initCursor)
- screen->softCursor = TRUE;
+ screen->softCursor = TRUE;
}
static Bool
-KdSetPixmapFormats (ScreenInfo *pScreenInfo)
+KdSetPixmapFormats(ScreenInfo * pScreenInfo)
{
- CARD8 depthToBpp[33]; /* depth -> bpp map */
- KdCardInfo *card;
- KdScreenInfo *screen;
- int i;
- int bpp;
+ CARD8 depthToBpp[33]; /* depth -> bpp map */
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+ int i;
+ int bpp;
PixmapFormatRec *format;
for (i = 1; i <= 32; i++)
- depthToBpp[i] = 0;
+ depthToBpp[i] = 0;
/*
* Generate mappings between bitsPerPixel and depth,
@@ -1020,148 +970,135 @@ KdSetPixmapFormats (ScreenInfo *pScreenInfo)
* restrictions on equivalent formats for the same
* depth on different screens
*/
- for (card = kdCardInfo; card; card = card->next)
- {
- for (screen = card->screenList; screen; screen = screen->next)
- {
- bpp = screen->fb.bitsPerPixel;
- if (bpp == 24)
- bpp = 32;
- if (!depthToBpp[screen->fb.depth])
- depthToBpp[screen->fb.depth] = bpp;
- else if (depthToBpp[screen->fb.depth] != bpp)
- return FALSE;
- }
+ for (card = kdCardInfo; card; card = card->next) {
+ for (screen = card->screenList; screen; screen = screen->next) {
+ bpp = screen->fb.bitsPerPixel;
+ if (bpp == 24)
+ bpp = 32;
+ if (!depthToBpp[screen->fb.depth])
+ depthToBpp[screen->fb.depth] = bpp;
+ else if (depthToBpp[screen->fb.depth] != bpp)
+ return FALSE;
+ }
}
/*
* Fill in additional formats
*/
for (i = 0; i < NUM_KD_DEPTHS; i++)
- if (!depthToBpp[kdDepths[i].depth])
- depthToBpp[kdDepths[i].depth] = kdDepths[i].bpp;
+ if (!depthToBpp[kdDepths[i].depth])
+ depthToBpp[kdDepths[i].depth] = kdDepths[i].bpp;
- pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
pScreenInfo->numPixmapFormats = 0;
- for (i = 1; i <= 32; i++)
- {
- if (depthToBpp[i])
- {
- format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
- format->depth = i;
- format->bitsPerPixel = depthToBpp[i];
- format->scanlinePad = BITMAP_SCANLINE_PAD;
- }
+ for (i = 1; i <= 32; i++) {
+ if (depthToBpp[i]) {
+ format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
+ format->depth = i;
+ format->bitsPerPixel = depthToBpp[i];
+ format->scanlinePad = BITMAP_SCANLINE_PAD;
+ }
}
return TRUE;
}
static void
-KdAddScreen (ScreenInfo *pScreenInfo,
- KdScreenInfo *screen,
- int argc,
- char **argv)
+KdAddScreen(ScreenInfo * pScreenInfo,
+ KdScreenInfo * screen, int argc, char **argv)
{
- int i;
+ int i;
+
/*
* Fill in fb visual type masks for this screen
*/
- for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
- {
- unsigned long visuals;
- Pixel rm, gm, bm;
-
- visuals = 0;
- rm = gm = bm = 0;
- if (pScreenInfo->formats[i].depth == screen->fb.depth)
- {
- visuals = screen->fb.visuals;
- rm = screen->fb.redMask;
- gm = screen->fb.greenMask;
- bm = screen->fb.blueMask;
- }
- fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
- visuals,
- 8,
- rm, gm, bm);
+ for (i = 0; i < pScreenInfo->numPixmapFormats; i++) {
+ unsigned long visuals;
+ Pixel rm, gm, bm;
+
+ visuals = 0;
+ rm = gm = bm = 0;
+ if (pScreenInfo->formats[i].depth == screen->fb.depth) {
+ visuals = screen->fb.visuals;
+ rm = screen->fb.redMask;
+ gm = screen->fb.greenMask;
+ bm = screen->fb.blueMask;
+ }
+ fbSetVisualTypesAndMasks(pScreenInfo->formats[i].depth,
+ visuals, 8, rm, gm, bm);
}
kdCurrentScreen = screen;
- AddScreen (KdScreenInit, argc, argv);
+ AddScreen(KdScreenInit, argc, argv);
}
-#if 0 /* This function is not used currently */
+#if 0 /* This function is not used currently */
int
-KdDepthToFb (ScreenPtr pScreen, int depth)
+KdDepthToFb(ScreenPtr pScreen, int depth)
{
KdScreenPriv(pScreen);
for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb.frameBuffer; fb++)
- if (pScreenPriv->screen->fb.depth == depth)
- return fb;
+ if (pScreenPriv->screen->fb.depth == depth)
+ return fb;
}
#endif
static int
-KdSignalWrapper (int signum)
+KdSignalWrapper(int signum)
{
kdCaughtSignal = TRUE;
- return 1; /* use generic OS layer cleanup & abort */
+ return 1; /* use generic OS layer cleanup & abort */
}
void
-KdInitOutput (ScreenInfo *pScreenInfo,
- int argc,
- char **argv)
+KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (!kdCardInfo)
- {
- InitCard (0);
- if (!(card = KdCardInfoLast ()))
- FatalError("No matching cards found!\n");
- screen = KdScreenInfoAdd (card);
- KdParseScreen (screen, 0);
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (!kdCardInfo) {
+ InitCard(0);
+ if (!(card = KdCardInfoLast()))
+ FatalError("No matching cards found!\n");
+ screen = KdScreenInfoAdd(card);
+ KdParseScreen(screen, 0);
}
/*
* Initialize all of the screens for all of the cards
*/
- for (card = kdCardInfo; card; card = card->next)
- {
- int ret=1;
- if(card->cfuncs->cardinit)
- ret=(*card->cfuncs->cardinit) (card);
- if (ret)
- {
- for (screen = card->screenList; screen; screen = screen->next)
- KdInitScreen (pScreenInfo, screen, argc, argv);
- }
+ for (card = kdCardInfo; card; card = card->next) {
+ int ret = 1;
+
+ if (card->cfuncs->cardinit)
+ ret = (*card->cfuncs->cardinit) (card);
+ if (ret) {
+ for (screen = card->screenList; screen; screen = screen->next)
+ KdInitScreen(pScreenInfo, screen, argc, argv);
+ }
}
/*
* Merge the various pixmap formats together, this can fail
* when two screens share depth but not bitsPerPixel
*/
- if (!KdSetPixmapFormats (pScreenInfo))
- return;
+ if (!KdSetPixmapFormats(pScreenInfo))
+ return;
/*
* Add all of the screens
*/
for (card = kdCardInfo; card; card = card->next)
- for (screen = card->screenList; screen; screen = screen->next)
- KdAddScreen (pScreenInfo, screen, argc, argv);
+ for (screen = card->screenList; screen; screen = screen->next)
+ KdAddScreen(pScreenInfo, screen, argc, argv);
OsRegisterSigWrapper(KdSignalWrapper);
}
@@ -1178,7 +1115,7 @@ DPMSSet(ClientPtr client, int level)
}
Bool
-DPMSSupported (void)
+DPMSSupported(void)
{
return FALSE;
}
diff --git a/xorg-server/hw/kdrive/src/kdrive.h b/xorg-server/hw/kdrive/src/kdrive.h
index cda965d84..6c2f29309 100644
--- a/xorg-server/hw/kdrive/src/kdrive.h
+++ b/xorg-server/hw/kdrive/src/kdrive.h
@@ -56,80 +56,80 @@
#define Status int
typedef struct _KdCardInfo {
- struct _KdCardFuncs *cfuncs;
- void *closure;
- void *driver;
- struct _KdScreenInfo *screenList;
- int selected;
- struct _KdCardInfo *next;
+ struct _KdCardFuncs *cfuncs;
+ void *closure;
+ void *driver;
+ struct _KdScreenInfo *screenList;
+ int selected;
+ struct _KdCardInfo *next;
} KdCardInfo;
-extern KdCardInfo *kdCardInfo;
+extern KdCardInfo *kdCardInfo;
/*
* Configuration information per X screen
*/
typedef struct _KdFrameBuffer {
- CARD8 *frameBuffer;
- int depth;
- int bitsPerPixel;
- int pixelStride;
- int byteStride;
- Bool shadow;
- unsigned long visuals;
- Pixel redMask, greenMask, blueMask;
- void *closure;
+ CARD8 *frameBuffer;
+ int depth;
+ int bitsPerPixel;
+ int pixelStride;
+ int byteStride;
+ Bool shadow;
+ unsigned long visuals;
+ Pixel redMask, greenMask, blueMask;
+ void *closure;
} KdFrameBuffer;
#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y)
typedef struct _KdScreenInfo {
- struct _KdScreenInfo *next;
- KdCardInfo *card;
- ScreenPtr pScreen;
- void *driver;
- Rotation randr; /* rotation and reflection */
- int width;
- int height;
- int rate;
- int width_mm;
- int height_mm;
- int subpixel_order;
- Bool dumb;
- Bool softCursor;
- int mynum;
- DDXPointRec origin;
- KdFrameBuffer fb;
+ struct _KdScreenInfo *next;
+ KdCardInfo *card;
+ ScreenPtr pScreen;
+ void *driver;
+ Rotation randr; /* rotation and reflection */
+ int width;
+ int height;
+ int rate;
+ int width_mm;
+ int height_mm;
+ int subpixel_order;
+ Bool dumb;
+ Bool softCursor;
+ int mynum;
+ DDXPointRec origin;
+ KdFrameBuffer fb;
} KdScreenInfo;
typedef struct _KdCardFuncs {
- Bool (*cardinit) (KdCardInfo *); /* detect and map device */
- Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
- Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
- Bool (*finishInitScreen) (ScreenPtr pScreen);
- Bool (*createRes) (ScreenPtr); /* create screen resources */
- void (*preserve) (KdCardInfo *); /* save graphics card state */
- Bool (*enable) (ScreenPtr); /* set up for rendering */
- Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
- void (*disable) (ScreenPtr); /* turn off rendering */
- void (*restore) (KdCardInfo *); /* restore graphics card state */
- void (*scrfini) (KdScreenInfo *);/* close down screen */
- void (*cardfini) (KdCardInfo *); /* close down */
-
- Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
- void (*enableCursor) (ScreenPtr); /* enable cursor */
- void (*disableCursor) (ScreenPtr); /* disable cursor */
- void (*finiCursor) (ScreenPtr); /* close down */
- void (*recolorCursor) (ScreenPtr, int, xColorItem *);
-
- Bool (*initAccel) (ScreenPtr);
- void (*enableAccel) (ScreenPtr);
- void (*disableAccel) (ScreenPtr);
- void (*finiAccel) (ScreenPtr);
-
- void (*getColors) (ScreenPtr, int, xColorItem *);
- void (*putColors) (ScreenPtr, int, xColorItem *);
+ Bool (*cardinit) (KdCardInfo *); /* detect and map device */
+ Bool (*scrinit) (KdScreenInfo *); /* initialize screen information */
+ Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
+ Bool (*finishInitScreen) (ScreenPtr pScreen);
+ Bool (*createRes) (ScreenPtr); /* create screen resources */
+ void (*preserve) (KdCardInfo *); /* save graphics card state */
+ Bool (*enable) (ScreenPtr); /* set up for rendering */
+ Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
+ void (*disable) (ScreenPtr); /* turn off rendering */
+ void (*restore) (KdCardInfo *); /* restore graphics card state */
+ void (*scrfini) (KdScreenInfo *); /* close down screen */
+ void (*cardfini) (KdCardInfo *); /* close down */
+
+ Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
+ void (*enableCursor) (ScreenPtr); /* enable cursor */
+ void (*disableCursor) (ScreenPtr); /* disable cursor */
+ void (*finiCursor) (ScreenPtr); /* close down */
+ void (*recolorCursor) (ScreenPtr, int, xColorItem *);
+
+ Bool (*initAccel) (ScreenPtr);
+ void (*enableAccel) (ScreenPtr);
+ void (*disableAccel) (ScreenPtr);
+ void (*finiAccel) (ScreenPtr);
+
+ void (*getColors) (ScreenPtr, int, xColorItem *);
+ void (*putColors) (ScreenPtr, int, xColorItem *);
} KdCardFuncs;
@@ -137,20 +137,20 @@ typedef struct _KdCardFuncs {
#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH)
typedef struct {
- KdScreenInfo *screen;
- KdCardInfo *card;
+ KdScreenInfo *screen;
+ KdCardInfo *card;
- Bool enabled;
- Bool closed;
- int bytesPerPixel;
+ Bool enabled;
+ Bool closed;
+ int bytesPerPixel;
- int dpmsState;
+ int dpmsState;
- ColormapPtr pInstalledmap; /* current colormap */
- xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
+ ColormapPtr pInstalledmap; /* current colormap */
+ xColorItem systemPalette[KD_MAX_PSEUDO_SIZE]; /* saved windows colors */
- CreateScreenResourcesProcPtr CreateScreenResources;
- CloseScreenProcPtr CloseScreen;
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
} KdPrivScreenRec, *KdPrivScreenPtr;
typedef enum _kdPointerState {
@@ -175,33 +175,33 @@ typedef enum _kdPointerState {
typedef struct _KdPointerInfo KdPointerInfo;
typedef struct _KdPointerDriver {
- char *name;
- Status (*Init) (KdPointerInfo *);
- Status (*Enable) (KdPointerInfo *);
- void (*Disable) (KdPointerInfo *);
- void (*Fini) (KdPointerInfo *);
+ char *name;
+ Status(*Init) (KdPointerInfo *);
+ Status(*Enable) (KdPointerInfo *);
+ void (*Disable) (KdPointerInfo *);
+ void (*Fini) (KdPointerInfo *);
struct _KdPointerDriver *next;
} KdPointerDriver;
struct _KdPointerInfo {
- DeviceIntPtr dixdev;
- char *name;
- char *path;
- char *protocol;
- InputOption *options;
- int inputClass;
-
- CARD8 map[KD_MAX_BUTTON + 1];
- int nButtons;
- int nAxes;
-
- Bool emulateMiddleButton;
- unsigned long emulationTimeout;
- int emulationDx, emulationDy;
-
- Bool timeoutPending;
- KdPointerState mouseState;
- Bool eventHeld;
+ DeviceIntPtr dixdev;
+ char *name;
+ char *path;
+ char *protocol;
+ InputOption *options;
+ int inputClass;
+
+ CARD8 map[KD_MAX_BUTTON + 1];
+ int nButtons;
+ int nAxes;
+
+ Bool emulateMiddleButton;
+ unsigned long emulationTimeout;
+ int emulationDx, emulationDy;
+
+ Bool timeoutPending;
+ KdPointerState mouseState;
+ Bool eventHeld;
struct {
int type;
int x;
@@ -210,26 +210,25 @@ struct _KdPointerInfo {
int flags;
int absrel;
} heldEvent;
- unsigned char buttonState;
- Bool transformCoordinates;
- int pressureThreshold;
+ unsigned char buttonState;
+ Bool transformCoordinates;
+ int pressureThreshold;
- KdPointerDriver *driver;
- void *driverPrivate;
+ KdPointerDriver *driver;
+ void *driverPrivate;
struct _KdPointerInfo *next;
};
extern int KdCurScreen;
-void KdAddPointerDriver (KdPointerDriver *driver);
-void KdRemovePointerDriver (KdPointerDriver *driver);
-KdPointerInfo *KdNewPointer (void);
-void KdFreePointer (KdPointerInfo *);
-int KdAddPointer (KdPointerInfo *ki);
-int KdAddConfigPointer (char *pointer);
-void KdRemovePointer (KdPointerInfo *ki);
-
+void KdAddPointerDriver(KdPointerDriver * driver);
+void KdRemovePointerDriver(KdPointerDriver * driver);
+KdPointerInfo *KdNewPointer(void);
+void KdFreePointer(KdPointerInfo *);
+int KdAddPointer(KdPointerInfo * ki);
+int KdAddConfigPointer(char *pointer);
+void KdRemovePointer(KdPointerInfo * ki);
#define KD_KEY_COUNT 248
#define KD_MIN_KEYCODE 8
@@ -239,64 +238,64 @@ void KdRemovePointer (KdPointerInfo *ki);
typedef struct {
KeySym modsym;
- int modbit;
+ int modbit;
} KdKeySymModsRec;
typedef struct _KdKeyboardInfo KdKeyboardInfo;
typedef struct _KdKeyboardDriver {
- char *name;
- Bool (*Init) (KdKeyboardInfo *);
- Bool (*Enable) (KdKeyboardInfo *);
- void (*Leds) (KdKeyboardInfo *, int);
- void (*Bell) (KdKeyboardInfo *, int, int, int);
- void (*Disable) (KdKeyboardInfo *);
- void (*Fini) (KdKeyboardInfo *);
+ char *name;
+ Bool (*Init) (KdKeyboardInfo *);
+ Bool (*Enable) (KdKeyboardInfo *);
+ void (*Leds) (KdKeyboardInfo *, int);
+ void (*Bell) (KdKeyboardInfo *, int, int, int);
+ void (*Disable) (KdKeyboardInfo *);
+ void (*Fini) (KdKeyboardInfo *);
struct _KdKeyboardDriver *next;
} KdKeyboardDriver;
struct _KdKeyboardInfo {
struct _KdKeyboardInfo *next;
- DeviceIntPtr dixdev;
- void *closure;
- char *name;
- char *path;
- int inputClass;
- char *xkbRules;
- char *xkbModel;
- char *xkbLayout;
- char *xkbVariant;
- char *xkbOptions;
- int LockLed;
-
- int minScanCode;
- int maxScanCode;
-
- int leds;
- int bellPitch;
- int bellDuration;
- InputOption *options;
-
- KdKeyboardDriver *driver;
- void *driverPrivate;
+ DeviceIntPtr dixdev;
+ void *closure;
+ char *name;
+ char *path;
+ int inputClass;
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
+ int LockLed;
+
+ int minScanCode;
+ int maxScanCode;
+
+ int leds;
+ int bellPitch;
+ int bellDuration;
+ InputOption *options;
+
+ KdKeyboardDriver *driver;
+ void *driverPrivate;
};
-void KdAddKeyboardDriver (KdKeyboardDriver *driver);
-void KdRemoveKeyboardDriver (KdKeyboardDriver *driver);
-KdKeyboardInfo *KdNewKeyboard (void);
-void KdFreeKeyboard (KdKeyboardInfo *ki);
-int KdAddConfigKeyboard (char *pointer);
-int KdAddKeyboard (KdKeyboardInfo *ki);
-void KdRemoveKeyboard (KdKeyboardInfo *ki);
+void KdAddKeyboardDriver(KdKeyboardDriver * driver);
+void KdRemoveKeyboardDriver(KdKeyboardDriver * driver);
+KdKeyboardInfo *KdNewKeyboard(void);
+void KdFreeKeyboard(KdKeyboardInfo * ki);
+int KdAddConfigKeyboard(char *pointer);
+int KdAddKeyboard(KdKeyboardInfo * ki);
+void KdRemoveKeyboard(KdKeyboardInfo * ki);
typedef struct _KdOsFuncs {
- int (*Init) (void);
- void (*Enable) (void);
- Bool (*SpecialKey) (KeySym);
- void (*Disable) (void);
- void (*Fini) (void);
- void (*pollEvents) (void);
- void (*Bell) (int, int, int);
+ int (*Init) (void);
+ void (*Enable) (void);
+ Bool (*SpecialKey) (KeySym);
+ void (*Disable) (void);
+ void (*Fini) (void);
+ void (*pollEvents) (void);
+ void (*Bell) (int, int, int);
} KdOsFuncs;
typedef enum _KdSyncPolarity {
@@ -305,28 +304,28 @@ typedef enum _KdSyncPolarity {
typedef struct _KdMonitorTiming {
/* label */
- int horizontal;
- int vertical;
- int rate;
+ int horizontal;
+ int vertical;
+ int rate;
/* pixel clock */
- int clock; /* in KHz */
+ int clock; /* in KHz */
/* horizontal timing */
- int hfp; /* front porch */
- int hbp; /* back porch */
- int hblank; /* blanking */
- KdSyncPolarity hpol; /* polarity */
+ int hfp; /* front porch */
+ int hbp; /* back porch */
+ int hblank; /* blanking */
+ KdSyncPolarity hpol; /* polarity */
/* vertical timing */
- int vfp; /* front porch */
- int vbp; /* back porch */
- int vblank; /* blanking */
- KdSyncPolarity vpol; /* polarity */
+ int vfp; /* front porch */
+ int vbp; /* back porch */
+ int vblank; /* blanking */
+ KdSyncPolarity vpol; /* polarity */
} KdMonitorTiming;
-extern const KdMonitorTiming kdMonitorTimings[];
-extern const int kdNumMonitorTimings;
+extern const KdMonitorTiming kdMonitorTimings[];
+extern const int kdNumMonitorTimings;
typedef struct _KdPointerMatrix {
- int matrix[2][3];
+ int matrix[2][3];
} KdPointerMatrix;
/*
@@ -342,18 +341,19 @@ typedef struct _KdPointerMatrix {
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
-extern DevPrivateKeyRec kdScreenPrivateKeyRec;
+extern DevPrivateKeyRec kdScreenPrivateKeyRec;
+
#define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
-extern unsigned long kdGeneration;
-extern Bool kdEnabled;
-extern Bool kdSwitchPending;
-extern Bool kdEmulateMiddleButton;
-extern Bool kdDisableZaphod;
-extern Bool kdAllowZap;
-extern int kdVirtualTerminal;
-extern char *kdSwitchCmd;
-extern KdOsFuncs *kdOsFuncs;
+extern unsigned long kdGeneration;
+extern Bool kdEnabled;
+extern Bool kdSwitchPending;
+extern Bool kdEmulateMiddleButton;
+extern Bool kdDisableZaphod;
+extern Bool kdAllowZap;
+extern int kdVirtualTerminal;
+extern char *kdSwitchCmd;
+extern KdOsFuncs *kdOsFuncs;
#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
@@ -363,158 +363,142 @@ extern KdOsFuncs *kdOsFuncs;
/* kcmap.c */
void
-KdSetColormap (ScreenPtr pScreen);
+ KdSetColormap(ScreenPtr pScreen);
void
-KdEnableColormap (ScreenPtr pScreen);
+ KdEnableColormap(ScreenPtr pScreen);
void
-KdDisableColormap (ScreenPtr pScreen);
+ KdDisableColormap(ScreenPtr pScreen);
void
-KdInstallColormap (ColormapPtr pCmap);
+ KdInstallColormap(ColormapPtr pCmap);
void
-KdUninstallColormap (ColormapPtr pCmap);
+ KdUninstallColormap(ColormapPtr pCmap);
int
-KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
+ KdListInstalledColormaps(ScreenPtr pScreen, Colormap * pCmaps);
void
-KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
+ KdStoreColors(ColormapPtr pCmap, int ndef, xColorItem * pdefs);
/* kdrive.c */
extern miPointerScreenFuncRec kdPointerScreenFuncs;
void
-KdDisableScreen (ScreenPtr pScreen);
+ KdDisableScreen(ScreenPtr pScreen);
void
-KdDisableScreens (void);
+ KdDisableScreens(void);
Bool
-KdEnableScreen (ScreenPtr pScreen);
+ KdEnableScreen(ScreenPtr pScreen);
void
-KdEnableScreens (void);
+ KdEnableScreens(void);
void
-KdSuspend (void);
+ KdSuspend(void);
void
-KdResume (void);
+ KdResume(void);
void
-KdProcessSwitch (void);
+ KdProcessSwitch(void);
-Rotation
-KdAddRotation (Rotation a, Rotation b);
+Rotation KdAddRotation(Rotation a, Rotation b);
-Rotation
-KdSubRotation (Rotation a, Rotation b);
+Rotation KdSubRotation(Rotation a, Rotation b);
void
-KdParseScreen (KdScreenInfo *screen,
- char *arg);
+ KdParseScreen(KdScreenInfo * screen, char *arg);
-KdPointerInfo *
-KdParsePointer (char *arg);
+KdPointerInfo *KdParsePointer(char *arg);
-KdKeyboardInfo *
-KdParseKeyboard (char *arg);
+KdKeyboardInfo *KdParseKeyboard(char *arg);
-char *
-KdParseFindNext (char *cur, const char *delim, char *save, char *last);
+char *KdParseFindNext(char *cur, const char *delim, char *save, char *last);
void
-KdParseRgba (char *rgba);
+ KdParseRgba(char *rgba);
void
-KdUseMsg (void);
+ KdUseMsg(void);
int
-KdProcessArgument (int argc, char **argv, int i);
+ KdProcessArgument(int argc, char **argv, int i);
void
-KdOsInit (KdOsFuncs *pOsFuncs);
+ KdOsInit(KdOsFuncs * pOsFuncs);
void
-KdOsAddInputDrivers (void);
+ KdOsAddInputDrivers(void);
Bool
-KdAllocatePrivates (ScreenPtr pScreen);
+ KdAllocatePrivates(ScreenPtr pScreen);
Bool
-KdCreateScreenResources (ScreenPtr pScreen);
+ KdCreateScreenResources(ScreenPtr pScreen);
Bool
-KdCloseScreen (int index, ScreenPtr pScreen);
+ KdCloseScreen(int index, ScreenPtr pScreen);
Bool
-KdSaveScreen (ScreenPtr pScreen, int on);
+ KdSaveScreen(ScreenPtr pScreen, int on);
Bool
-KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
+ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
void
-KdInitScreen (ScreenInfo *pScreenInfo,
- KdScreenInfo *screen,
- int argc,
- char **argv);
+
+KdInitScreen(ScreenInfo * pScreenInfo,
+ KdScreenInfo * screen, int argc, char **argv);
void
-KdInitCard (ScreenInfo *pScreenInfo,
- KdCardInfo *card,
- int argc,
- char **argv);
+ KdInitCard(ScreenInfo * pScreenInfo, KdCardInfo * card, int argc, char **argv);
void
-KdInitOutput (ScreenInfo *pScreenInfo,
- int argc,
- char **argv);
+ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv);
void
-KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
+ KdSetSubpixelOrder(ScreenPtr pScreen, Rotation randr);
void
-KdBacktrace (int signum);
+ KdBacktrace(int signum);
/* kinfo.c */
-KdCardInfo *
-KdCardInfoAdd (KdCardFuncs *funcs,
- void *closure);
+KdCardInfo *KdCardInfoAdd(KdCardFuncs * funcs, void *closure);
-KdCardInfo *
-KdCardInfoLast (void);
+KdCardInfo *KdCardInfoLast(void);
void
-KdCardInfoDispose (KdCardInfo *ci);
+ KdCardInfoDispose(KdCardInfo * ci);
-KdScreenInfo *
-KdScreenInfoAdd (KdCardInfo *ci);
+KdScreenInfo *KdScreenInfoAdd(KdCardInfo * ci);
void
-KdScreenInfoDispose (KdScreenInfo *si);
-
+ KdScreenInfoDispose(KdScreenInfo * si);
/* kinput.c */
void
-KdInitInput(void);
+ KdInitInput(void);
void
-KdCloseInput(void);
+ KdCloseInput(void);
Bool
-KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure);
+ KdRegisterFd(int fd, void (*read) (int fd, void *closure), void *closure);
void
-KdUnregisterFds (void *closure, Bool do_close);
+ KdUnregisterFds(void *closure, Bool do_close);
void
-KdUnregisterFd (void *closure, int fd, Bool do_close);
+ KdUnregisterFd(void *closure, int fd, Bool do_close);
void
-KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
- unsigned char is_up);
+
+KdEnqueueKeyboardEvent(KdKeyboardInfo * ki, unsigned char scan_code,
+ unsigned char is_up);
#define KD_BUTTON_1 0x01
#define KD_BUTTON_2 0x02
@@ -525,97 +509,96 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
#define KD_MOUSE_DELTA 0x80000000
void
-KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+
+KdEnqueuePointerEvent(KdPointerInfo * pi, unsigned long flags, int rx, int ry,
int rz);
void
-_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z,
+
+_KdEnqueuePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z,
int b, int absrel, Bool force);
void
-KdReleaseAllKeys (void);
+ KdReleaseAllKeys(void);
void
-KdSetLed (KdKeyboardInfo *ki, int led, Bool on);
+ KdSetLed(KdKeyboardInfo * ki, int led, Bool on);
void
-KdSetPointerMatrix (KdPointerMatrix *pointer);
+ KdSetPointerMatrix(KdPointerMatrix * pointer);
void
-KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
+
+KdComputePointerMatrix(KdPointerMatrix * pointer, Rotation randr, int width,
+ int height);
void
-KdScreenToPointerCoords (int *x, int *y);
+ KdScreenToPointerCoords(int *x, int *y);
void
-KdBlockHandler (int screen,
- pointer blockData,
- pointer timeout,
- pointer readmask);
+
+KdBlockHandler(int screen,
+ pointer blockData, pointer timeout, pointer readmask);
void
-KdWakeupHandler (int screen,
- pointer data,
- unsigned long result,
- pointer readmask);
+
+KdWakeupHandler(int screen,
+ pointer data, unsigned long result, pointer readmask);
void
-KdDisableInput (void);
+ KdDisableInput(void);
void
-KdEnableInput (void);
+ KdEnableInput(void);
void
-ProcessInputEvents (void);
+ ProcessInputEvents(void);
void
-KdRingBell (KdKeyboardInfo *ki,
- int volume,
- int pitch,
- int duration);
+ KdRingBell(KdKeyboardInfo * ki, int volume, int pitch, int duration);
/* kmode.c */
-const KdMonitorTiming *
-KdFindMode (KdScreenInfo *screen,
- Bool (*supported) (KdScreenInfo *,
- const KdMonitorTiming *));
+const KdMonitorTiming *KdFindMode(KdScreenInfo * screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
Bool
-KdTuneMode (KdScreenInfo *screen,
- Bool (*usable) (KdScreenInfo *),
- Bool (*supported) (KdScreenInfo *,
- const KdMonitorTiming *));
+
+KdTuneMode(KdScreenInfo * screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *, const KdMonitorTiming *));
#ifdef RANDR
Bool
-KdRandRGetInfo (ScreenPtr pScreen,
- int randr,
- Bool (*supported) (ScreenPtr pScreen,
- const KdMonitorTiming *));
-
-const KdMonitorTiming *
-KdRandRGetTiming (ScreenPtr pScreen,
- Bool (*supported) (ScreenPtr pScreen,
- const KdMonitorTiming *),
- int rate,
- RRScreenSizePtr pSize);
+
+KdRandRGetInfo(ScreenPtr pScreen,
+ int randr,
+ Bool (*supported) (ScreenPtr pScreen, const KdMonitorTiming *));
+
+const KdMonitorTiming *KdRandRGetTiming(ScreenPtr pScreen,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming
+ *), int rate,
+ RRScreenSizePtr pSize);
#endif
/* kshadow.c */
Bool
-KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate);
+ KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate);
void
-KdShadowFbFree (KdScreenInfo *screen);
+ KdShadowFbFree(KdScreenInfo * screen);
Bool
-KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window);
+
+KdShadowSet(ScreenPtr pScreen, int randr, ShadowUpdateProc update,
+ ShadowWindowProc window);
void
-KdShadowUnset (ScreenPtr pScreen);
+ KdShadowUnset(ScreenPtr pScreen);
/* function prototypes to be implemented by the drivers */
void
-InitCard (char *name);
+ InitCard(char *name);
-#endif /* _KDRIVE_H_ */
+#endif /* _KDRIVE_H_ */
diff --git a/xorg-server/hw/kdrive/src/kinfo.c b/xorg-server/hw/kdrive/src/kinfo.c
index 0055b16db..01ae1e491 100644
--- a/xorg-server/hw/kdrive/src/kinfo.c
+++ b/xorg-server/hw/kdrive/src/kinfo.c
@@ -25,17 +25,16 @@
#endif
#include "kdrive.h"
-KdCardInfo *kdCardInfo;
+KdCardInfo *kdCardInfo;
KdCardInfo *
-KdCardInfoAdd (KdCardFuncs *funcs,
- void *closure)
+KdCardInfoAdd(KdCardFuncs * funcs, void *closure)
{
- KdCardInfo *ci, **prev;
+ KdCardInfo *ci, **prev;
- ci = calloc(1, sizeof (KdCardInfo));
+ ci = calloc(1, sizeof(KdCardInfo));
if (!ci)
- return 0;
+ return 0;
for (prev = &kdCardInfo; *prev; prev = &(*prev)->next);
*prev = ci;
ci->cfuncs = funcs;
@@ -47,39 +46,38 @@ KdCardInfoAdd (KdCardFuncs *funcs,
}
KdCardInfo *
-KdCardInfoLast (void)
+KdCardInfoLast(void)
{
- KdCardInfo *ci;
+ KdCardInfo *ci;
if (!kdCardInfo)
- return 0;
+ return 0;
for (ci = kdCardInfo; ci->next; ci = ci->next);
return ci;
}
void
-KdCardInfoDispose (KdCardInfo *ci)
+KdCardInfoDispose(KdCardInfo * ci)
{
- KdCardInfo **prev;
+ KdCardInfo **prev;
for (prev = &kdCardInfo; *prev; prev = &(*prev)->next)
- if (*prev == ci)
- {
- *prev = ci->next;
- free(ci);
- break;
- }
+ if (*prev == ci) {
+ *prev = ci->next;
+ free(ci);
+ break;
+ }
}
KdScreenInfo *
-KdScreenInfoAdd (KdCardInfo *ci)
+KdScreenInfoAdd(KdCardInfo * ci)
{
- KdScreenInfo *si, **prev;
- int n;
+ KdScreenInfo *si, **prev;
+ int n;
- si = calloc(1, sizeof (KdScreenInfo));
+ si = calloc(1, sizeof(KdScreenInfo));
if (!si)
- return 0;
+ return 0;
for (prev = &ci->screenList, n = 0; *prev; prev = &(*prev)->next, n++);
*prev = si;
si->next = 0;
@@ -89,30 +87,29 @@ KdScreenInfoAdd (KdCardInfo *ci)
}
void
-KdScreenInfoDispose (KdScreenInfo *si)
+KdScreenInfoDispose(KdScreenInfo * si)
{
- KdCardInfo *ci = si->card;
- KdScreenInfo **prev;
+ KdCardInfo *ci = si->card;
+ KdScreenInfo **prev;
for (prev = &ci->screenList; *prev; prev = &(*prev)->next) {
- if (*prev == si)
- {
- *prev = si->next;
- free(si);
- if (!ci->screenList)
- KdCardInfoDispose (ci);
- break;
- }
+ if (*prev == si) {
+ *prev = si->next;
+ free(si);
+ if (!ci->screenList)
+ KdCardInfoDispose(ci);
+ break;
+ }
}
}
KdPointerInfo *
-KdNewPointer (void)
+KdNewPointer(void)
{
KdPointerInfo *pi;
int i;
- pi = (KdPointerInfo *)calloc(1, sizeof(KdPointerInfo));
+ pi = (KdPointerInfo *) calloc(1, sizeof(KdPointerInfo));
if (!pi)
return NULL;
@@ -132,7 +129,7 @@ KdNewPointer (void)
}
void
-KdFreePointer(KdPointerInfo *pi)
+KdFreePointer(KdPointerInfo * pi)
{
free(pi->name);
free(pi->path);
@@ -141,7 +138,7 @@ KdFreePointer(KdPointerInfo *pi)
}
void
-KdFreeKeyboard(KdKeyboardInfo *ki)
+KdFreeKeyboard(KdKeyboardInfo * ki)
{
free(ki->name);
free(ki->path);
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 968ebb159..e16fe78f2 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -35,14 +35,14 @@
#include <signal.h>
#include <stdio.h>
#ifdef sun
-#include <sys/file.h> /* needed for FNONBLOCK & FASYNC */
+#include <sys/file.h> /* needed for FNONBLOCK & FASYNC */
#endif
#include "xkbsrv.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "XIstubs.h" /* even though we don't use stubs. cute, no? */
+#include "XIstubs.h" /* even though we don't use stubs. cute, no? */
#include "exevents.h"
#include "extinit.h"
#include "exglobals.h"
@@ -59,79 +59,80 @@ struct KdConfigDevice {
};
/* kdKeyboards and kdPointers hold all the real devices. */
-static KdKeyboardInfo *kdKeyboards = NULL;
-static KdPointerInfo *kdPointers = NULL;
-static struct KdConfigDevice *kdConfigKeyboards = NULL;
-static struct KdConfigDevice *kdConfigPointers = NULL;
+static KdKeyboardInfo *kdKeyboards = NULL;
+static KdPointerInfo *kdPointers = NULL;
+static struct KdConfigDevice *kdConfigKeyboards = NULL;
+static struct KdConfigDevice *kdConfigPointers = NULL;
static KdKeyboardDriver *kdKeyboardDrivers = NULL;
-static KdPointerDriver *kdPointerDrivers = NULL;
-
-static Bool kdInputEnabled;
-static Bool kdOffScreen;
-static unsigned long kdOffScreenTime;
-static KdPointerMatrix kdPointerMatrix = {
- { { 1, 0, 0 },
- { 0, 1, 0 } }
+static KdPointerDriver *kdPointerDrivers = NULL;
+
+static Bool kdInputEnabled;
+static Bool kdOffScreen;
+static unsigned long kdOffScreenTime;
+
+static KdPointerMatrix kdPointerMatrix = {
+ {{1, 0, 0},
+ {0, 1, 0}}
};
-void KdResetInputMachine (void);
+void KdResetInputMachine(void);
#define KD_MAX_INPUT_FDS 8
typedef struct _kdInputFd {
- int fd;
- void (*read) (int fd, void *closure);
- int (*enable) (int fd, void *closure);
- void (*disable) (int fd, void *closure);
- void *closure;
+ int fd;
+ void (*read) (int fd, void *closure);
+ int (*enable) (int fd, void *closure);
+ void (*disable) (int fd, void *closure);
+ void *closure;
} KdInputFd;
static KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
-static int kdNumInputFds;
+static int kdNumInputFds;
-extern Bool kdRawPointerCoordinates;
+extern Bool kdRawPointerCoordinates;
static void
-KdSigio (int sig)
+KdSigio(int sig)
{
- int i;
+ int i;
for (i = 0; i < kdNumInputFds; i++)
- (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
}
static void
-KdBlockSigio (void)
+KdBlockSigio(void)
{
- sigset_t set;
+ sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, 0);
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_BLOCK, &set, 0);
}
static void
-KdUnblockSigio (void)
+KdUnblockSigio(void)
{
- sigset_t set;
+ sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, 0);
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_UNBLOCK, &set, 0);
}
#ifdef DEBUG_SIGIO
void
-KdAssertSigioBlocked (char *where)
+KdAssertSigioBlocked(char *where)
{
- sigset_t set, old;
+ sigset_t set, old;
- sigemptyset (&set);
- sigprocmask (SIG_BLOCK, &set, &old);
- if (!sigismember (&old, SIGIO)) {
- ErrorF ("SIGIO not blocked at %s\n", where);
+ sigemptyset(&set);
+ sigprocmask(SIG_BLOCK, &set, &old);
+ if (!sigismember(&old, SIGIO)) {
+ ErrorF("SIGIO not blocked at %s\n", where);
KdBacktrace(0);
}
}
@@ -142,7 +143,7 @@ KdAssertSigioBlocked (char *where)
#endif
-static int kdnFds;
+static int kdnFds;
#ifdef FNONBLOCK
#define NOBLOCK FNONBLOCK
@@ -151,7 +152,7 @@ static int kdnFds;
#endif
void
-KdResetInputMachine (void)
+KdResetInputMachine(void)
{
KdPointerInfo *pi;
@@ -162,60 +163,60 @@ KdResetInputMachine (void)
}
static void
-KdNonBlockFd (int fd)
+KdNonBlockFd(int fd)
{
- int flags;
- flags = fcntl (fd, F_GETFL);
- flags |= FASYNC|NOBLOCK;
- fcntl (fd, F_SETFL, flags);
+ int flags;
+
+ flags = fcntl(fd, F_GETFL);
+ flags |= FASYNC | NOBLOCK;
+ fcntl(fd, F_SETFL, flags);
}
static void
-KdAddFd (int fd)
+KdAddFd(int fd)
{
- struct sigaction act;
- sigset_t set;
+ struct sigaction act;
+ sigset_t set;
kdnFds++;
- fcntl (fd, F_SETOWN, getpid());
- KdNonBlockFd (fd);
- AddEnabledDevice (fd);
- memset (&act, '\0', sizeof act);
+ fcntl(fd, F_SETOWN, getpid());
+ KdNonBlockFd(fd);
+ AddEnabledDevice(fd);
+ memset(&act, '\0', sizeof act);
act.sa_handler = KdSigio;
- sigemptyset (&act.sa_mask);
- sigaddset (&act.sa_mask, SIGIO);
- sigaddset (&act.sa_mask, SIGALRM);
- sigaddset (&act.sa_mask, SIGVTALRM);
- sigaction (SIGIO, &act, 0);
- sigemptyset (&set);
- sigprocmask (SIG_SETMASK, &set, 0);
+ sigemptyset(&act.sa_mask);
+ sigaddset(&act.sa_mask, SIGIO);
+ sigaddset(&act.sa_mask, SIGALRM);
+ sigaddset(&act.sa_mask, SIGVTALRM);
+ sigaction(SIGIO, &act, 0);
+ sigemptyset(&set);
+ sigprocmask(SIG_SETMASK, &set, 0);
}
static void
-KdRemoveFd (int fd)
+KdRemoveFd(int fd)
{
- struct sigaction act;
- int flags;
+ struct sigaction act;
+ int flags;
kdnFds--;
- RemoveEnabledDevice (fd);
- flags = fcntl (fd, F_GETFL);
- flags &= ~(FASYNC|NOBLOCK);
- fcntl (fd, F_SETFL, flags);
- if (kdnFds == 0)
- {
- memset (&act, '\0', sizeof act);
- act.sa_handler = SIG_IGN;
- sigemptyset (&act.sa_mask);
- sigaction (SIGIO, &act, 0);
+ RemoveEnabledDevice(fd);
+ flags = fcntl(fd, F_GETFL);
+ flags &= ~(FASYNC | NOBLOCK);
+ fcntl(fd, F_SETFL, flags);
+ if (kdnFds == 0) {
+ memset(&act, '\0', sizeof act);
+ act.sa_handler = SIG_IGN;
+ sigemptyset(&act.sa_mask);
+ sigaction(SIGIO, &act, 0);
}
}
Bool
-KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
+KdRegisterFd(int fd, void (*read) (int fd, void *closure), void *closure)
{
if (kdNumInputFds == KD_MAX_INPUT_FDS)
- return FALSE;
+ return FALSE;
kdInputFds[kdNumInputFds].fd = fd;
kdInputFds[kdNumInputFds].read = read;
kdInputFds[kdNumInputFds].enable = 0;
@@ -223,38 +224,38 @@ KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
kdInputFds[kdNumInputFds].closure = closure;
kdNumInputFds++;
if (kdInputEnabled)
- KdAddFd (fd);
+ KdAddFd(fd);
return TRUE;
}
void
-KdUnregisterFd (void *closure, int fd, Bool do_close)
+KdUnregisterFd(void *closure, int fd, Bool do_close)
{
- int i, j;
+ int i, j;
for (i = 0; i < kdNumInputFds; i++) {
- if (kdInputFds[i].closure == closure &&
+ if (kdInputFds[i].closure == closure &&
(fd == -1 || kdInputFds[i].fd == fd)) {
- if (kdInputEnabled)
- KdRemoveFd (kdInputFds[i].fd);
- if (do_close)
- close (kdInputFds[i].fd);
- kdNumInputFds--;
- for (j = i; j < kdNumInputFds; j++)
- kdInputFds[j] = kdInputFds[j+1];
+ if (kdInputEnabled)
+ KdRemoveFd(kdInputFds[i].fd);
+ if (do_close)
+ close(kdInputFds[i].fd);
+ kdNumInputFds--;
+ for (j = i; j < kdNumInputFds; j++)
+ kdInputFds[j] = kdInputFds[j + 1];
break;
- }
+ }
}
}
void
-KdUnregisterFds (void *closure, Bool do_close)
+KdUnregisterFds(void *closure, Bool do_close)
{
KdUnregisterFd(closure, -1, do_close);
}
void
-KdDisableInput (void)
+KdDisableInput(void)
{
KdKeyboardInfo *ki;
KdPointerInfo *pi;
@@ -283,7 +284,7 @@ KdDisableInput (void)
ErrorF(" fd %d belongs to keybd driver %s\n",
kdInputFds[i].fd,
ki->driver && ki->driver->name ?
- ki->driver->name : "(unnamed!)");
+ ki->driver->name : "(unnamed!)");
found = 1;
break;
}
@@ -299,7 +300,7 @@ KdDisableInput (void)
ErrorF(" fd %d belongs to pointer driver %s\n",
kdInputFds[i].fd,
pi->driver && pi->driver->name ?
- pi->driver->name : "(unnamed!)");
+ pi->driver->name : "(unnamed!)");
break;
}
}
@@ -319,7 +320,7 @@ KdDisableInput (void)
}
void
-KdEnableInput (void)
+KdEnableInput(void)
{
InternalEvent ev;
KdKeyboardInfo *ki;
@@ -338,14 +339,15 @@ KdEnableInput (void)
}
/* reset screen saver */
- ev.any.time = GetTimeInMillis ();
- NoticeEventTime (&ev);
+ ev.any.time = GetTimeInMillis();
+ NoticeEventTime(&ev, pi->dixdev);
+ NoticeEventTime(&ev, ki->dixdev);
- KdUnblockSigio ();
+ KdUnblockSigio();
}
static KdKeyboardDriver *
-KdFindKeyboardDriver (const char *name)
+KdFindKeyboardDriver(const char *name)
{
KdKeyboardDriver *ret;
@@ -362,7 +364,7 @@ KdFindKeyboardDriver (const char *name)
}
static KdPointerDriver *
-KdFindPointerDriver (const char *name)
+KdFindPointerDriver(const char *name)
{
KdPointerDriver *ret;
@@ -381,14 +383,14 @@ KdFindPointerDriver (const char *name)
static int
KdPointerProc(DeviceIntPtr pDevice, int onoff)
{
- DevicePtr pDev = (DevicePtr)pDevice;
- KdPointerInfo *pi;
- Atom xiclass;
- Atom *btn_labels;
- Atom *axes_labels;
+ DevicePtr pDev = (DevicePtr) pDevice;
+ KdPointerInfo *pi;
+ Atom xiclass;
+ Atom *btn_labels;
+ Atom *axes_labels;
if (!pDev)
- return BadImplementation;
+ return BadImplementation;
for (pi = kdPointers; pi; pi = pi->next) {
if (pi->dixdev && pi->dixdev->id == pDevice->id)
@@ -401,8 +403,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation;
}
- switch (onoff)
- {
+ switch (onoff) {
case DEVICE_INIT:
#ifdef DEBUG
ErrorF("initialising pointer %s ...\n", pi->name);
@@ -433,44 +434,43 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return !Success;
}
- btn_labels = calloc(pi->nButtons, sizeof(Atom));
- if (!btn_labels)
- return BadAlloc;
- axes_labels = calloc(pi->nAxes, sizeof(Atom));
- if (!axes_labels) {
- free(btn_labels);
- return BadAlloc;
- }
-
- switch(pi->nAxes)
- {
- default:
- case 7:
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- case 6:
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- case 5:
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- case 4:
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- case 3:
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- case 2:
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- case 1:
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- case 0:
- break;
- }
-
- if (pi->nAxes >= 2) {
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
- }
-
- InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), pi->nAxes, axes_labels);
+ btn_labels = calloc(pi->nButtons, sizeof(Atom));
+ if (!btn_labels)
+ return BadAlloc;
+ axes_labels = calloc(pi->nAxes, sizeof(Atom));
+ if (!axes_labels) {
+ free(btn_labels);
+ return BadAlloc;
+ }
+
+ switch (pi->nAxes) {
+ default:
+ case 7:
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ case 6:
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ case 5:
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ case 4:
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ case 3:
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ case 2:
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ case 1:
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ case 0:
+ break;
+ }
+
+ if (pi->nAxes >= 2) {
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ }
+
+ InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
+ (PtrCtrlProcPtr) NoopDDA,
+ GetMotionHistorySize(), pi->nAxes, axes_labels);
free(btn_labels);
free(axes_labels);
@@ -485,7 +485,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
AssignTypeAndName(pi->dixdev, xiclass,
pi->name ? pi->name : "Generic KDrive Pointer");
- return Success;
+ return Success;
case DEVICE_ON:
if (pDev->on == TRUE)
@@ -504,7 +504,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation;
}
- return Success;
+ return Success;
case DEVICE_OFF:
if (pDev->on == FALSE) {
@@ -523,7 +523,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return Success;
case DEVICE_CLOSE:
- if (pDev->on) {
+ if (pDev->on) {
if (!pi->driver->Disable) {
return BadImplementation;
}
@@ -552,7 +552,7 @@ LegalModifier(unsigned int key, DeviceIntPtr pDev)
}
static void
-KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
+KdBell(int volume, DeviceIntPtr pDev, pointer arg, int something)
{
KeybdCtrl *ctrl = arg;
KdKeyboardInfo *ki = NULL;
@@ -574,7 +574,7 @@ DDXRingBell(int volume, int pitch, int duration)
KdKeyboardInfo *ki = NULL;
if (kdOsFuncs->Bell) {
- (*kdOsFuncs->Bell)(volume, pitch, duration);
+ (*kdOsFuncs->Bell) (volume, pitch, duration);
}
else {
for (ki = kdKeyboards; ki; ki = ki->next) {
@@ -585,7 +585,7 @@ DDXRingBell(int volume, int pitch, int duration)
}
void
-KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
+KdRingBell(KdKeyboardInfo * ki, int volume, int pitch, int duration)
{
if (!ki || !ki->driver || !ki->driver->Bell)
return;
@@ -594,9 +594,8 @@ KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
(*ki->driver->Bell) (ki, volume, pitch, duration);
}
-
static void
-KdSetLeds (KdKeyboardInfo *ki, int leds)
+KdSetLeds(KdKeyboardInfo * ki, int leds)
{
if (!ki || !ki->driver)
return;
@@ -608,75 +607,85 @@ KdSetLeds (KdKeyboardInfo *ki, int leds)
}
void
-KdSetLed (KdKeyboardInfo *ki, int led, Bool on)
+KdSetLed(KdKeyboardInfo * ki, int led, Bool on)
{
if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed)
return;
- NoteLedState (ki->dixdev, led, on);
- KdSetLeds (ki, ki->dixdev->kbdfeed->ctrl.leds);
+ NoteLedState(ki->dixdev, led, on);
+ KdSetLeds(ki, ki->dixdev->kbdfeed->ctrl.leds);
}
void
-KdSetPointerMatrix (KdPointerMatrix *matrix)
+KdSetPointerMatrix(KdPointerMatrix * matrix)
{
kdPointerMatrix = *matrix;
}
void
-KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
- int height)
+KdComputePointerMatrix(KdPointerMatrix * m, Rotation randr, int width,
+ int height)
{
- int x_dir = 1, y_dir = 1;
- int i, j;
- int size[2];
+ int x_dir = 1, y_dir = 1;
+ int i, j;
+ int size[2];
- size[0] = width; size[1] = height;
+ size[0] = width;
+ size[1] = height;
if (randr & RR_Reflect_X)
- x_dir = -1;
+ x_dir = -1;
if (randr & RR_Reflect_Y)
- y_dir = -1;
+ y_dir = -1;
switch (randr & (RR_Rotate_All)) {
case RR_Rotate_0:
- m->matrix[0][0] = x_dir; m->matrix[0][1] = 0;
- m->matrix[1][0] = 0; m->matrix[1][1] = y_dir;
- break;
+ m->matrix[0][0] = x_dir;
+ m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0;
+ m->matrix[1][1] = y_dir;
+ break;
case RR_Rotate_90:
- m->matrix[0][0] = 0; m->matrix[0][1] = -x_dir;
- m->matrix[1][0] = y_dir; m->matrix[1][1] = 0;
- break;
+ m->matrix[0][0] = 0;
+ m->matrix[0][1] = -x_dir;
+ m->matrix[1][0] = y_dir;
+ m->matrix[1][1] = 0;
+ break;
case RR_Rotate_180:
- m->matrix[0][0] = -x_dir; m->matrix[0][1] = 0;
- m->matrix[1][0] = 0; m->matrix[1][1] = -y_dir;
- break;
+ m->matrix[0][0] = -x_dir;
+ m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0;
+ m->matrix[1][1] = -y_dir;
+ break;
case RR_Rotate_270:
- m->matrix[0][0] = 0; m->matrix[0][1] = x_dir;
- m->matrix[1][0] = -y_dir; m->matrix[1][1] = 0;
- break;
+ m->matrix[0][0] = 0;
+ m->matrix[0][1] = x_dir;
+ m->matrix[1][0] = -y_dir;
+ m->matrix[1][1] = 0;
+ break;
}
- for (i = 0; i < 2; i++)
- {
- m->matrix[i][2] = 0;
- for (j = 0 ; j < 2; j++)
- if (m->matrix[i][j] < 0)
- m->matrix[i][2] = size[j] - 1;
+ for (i = 0; i < 2; i++) {
+ m->matrix[i][2] = 0;
+ for (j = 0; j < 2; j++)
+ if (m->matrix[i][j] < 0)
+ m->matrix[i][2] = size[j] - 1;
}
}
void
-KdScreenToPointerCoords (int *x, int *y)
+KdScreenToPointerCoords(int *x, int *y)
{
- int (*m)[3] = kdPointerMatrix.matrix;
+ int (*m)[3] = kdPointerMatrix.matrix;
int div = m[0][1] * m[1][0] - m[1][1] * m[0][0];
int sx = *x;
int sy = *y;
- *x = (m[0][1] * sy - m[0][1] * m[1][2] + m[1][1] * m[0][2] - m[1][1] * sx) / div;
- *y = (m[1][0] * sx + m[0][0] * m[1][2] - m[1][0] * m[0][2] - m[0][0] * sy) / div;
+ *x = (m[0][1] * sy - m[0][1] * m[1][2] + m[1][1] * m[0][2] -
+ m[1][1] * sx) / div;
+ *y = (m[1][0] * sx + m[0][0] * m[1][2] - m[1][0] * m[0][2] -
+ m[0][0] * sy) / div;
}
static void
-KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
+KdKbdCtrl(DeviceIntPtr pDevice, KeybdCtrl * ctrl)
{
KdKeyboardInfo *ki;
@@ -698,14 +707,14 @@ extern KeybdCtrl defaultKeyboardControl;
static int
KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
{
- Bool ret;
- DevicePtr pDev = (DevicePtr)pDevice;
+ Bool ret;
+ DevicePtr pDev = (DevicePtr) pDevice;
KdKeyboardInfo *ki;
Atom xiclass;
XkbRMLVOSet rmlvo;
if (!pDev)
- return BadImplementation;
+ return BadImplementation;
for (ki = kdKeyboards; ki; ki = ki->next) {
if (ki->dixdev && ki->dixdev->id == pDevice->id)
@@ -716,8 +725,7 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation;
}
- switch (onoff)
- {
+ switch (onoff) {
case DEVICE_INIT:
#ifdef DEBUG
ErrorF("initialising keyboard %s\n", ki->name);
@@ -754,10 +762,10 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
rmlvo.layout = ki->xkbLayout;
rmlvo.variant = ki->xkbVariant;
rmlvo.options = ki->xkbOptions;
- ret = InitKeyboardDeviceStruct (pDevice, &rmlvo, KdBell, KdKbdCtrl);
- if (!ret) {
+ ret = InitKeyboardDeviceStruct(pDevice, &rmlvo, KdBell, KdKbdCtrl);
+ if (!ret) {
ErrorF("Couldn't initialise keyboard %s\n", ki->name);
- return BadImplementation;
+ return BadImplementation;
}
xiclass = AtomFromName(XI_KEYBOARD);
@@ -797,13 +805,13 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
break;
case DEVICE_CLOSE:
- if (pDev->on) {
+ if (pDev->on) {
if (!ki->driver->Disable)
return BadImplementation;
(*ki->driver->Disable) (ki);
pDev->on = FALSE;
- }
+ }
if (!ki->driver->Fini)
return BadImplementation;
@@ -820,7 +828,7 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
}
void
-KdAddPointerDriver (KdPointerDriver *driver)
+KdAddPointerDriver(KdPointerDriver * driver)
{
KdPointerDriver **prev;
@@ -835,7 +843,7 @@ KdAddPointerDriver (KdPointerDriver *driver)
}
void
-KdRemovePointerDriver (KdPointerDriver *driver)
+KdRemovePointerDriver(KdPointerDriver * driver)
{
KdPointerDriver *tmp;
@@ -852,7 +860,7 @@ KdRemovePointerDriver (KdPointerDriver *driver)
}
void
-KdAddKeyboardDriver (KdKeyboardDriver *driver)
+KdAddKeyboardDriver(KdKeyboardDriver * driver)
{
KdKeyboardDriver **prev;
@@ -867,7 +875,7 @@ KdAddKeyboardDriver (KdKeyboardDriver *driver)
}
void
-KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
+KdRemoveKeyboardDriver(KdKeyboardDriver * driver)
{
KdKeyboardDriver *tmp;
@@ -884,9 +892,10 @@ KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
}
KdKeyboardInfo *
-KdNewKeyboard (void)
+KdNewKeyboard(void)
{
KdKeyboardInfo *ki = calloc(sizeof(KdKeyboardInfo), 1);
+
if (!ki)
return NULL;
@@ -907,7 +916,7 @@ KdNewKeyboard (void)
}
int
-KdAddConfigKeyboard (char *keyboard)
+KdAddConfigKeyboard(char *keyboard)
{
struct KdConfigDevice **prev, *new;
@@ -928,7 +937,7 @@ KdAddConfigKeyboard (char *keyboard)
}
int
-KdAddKeyboard (KdKeyboardInfo *ki)
+KdAddKeyboard(KdKeyboardInfo * ki)
{
KdKeyboardInfo **prev;
@@ -953,7 +962,7 @@ KdAddKeyboard (KdKeyboardInfo *ki)
}
void
-KdRemoveKeyboard (KdKeyboardInfo *ki)
+KdRemoveKeyboard(KdKeyboardInfo * ki)
{
KdKeyboardInfo **prev;
@@ -971,7 +980,7 @@ KdRemoveKeyboard (KdKeyboardInfo *ki)
}
int
-KdAddConfigPointer (char *pointer)
+KdAddConfigPointer(char *pointer)
{
struct KdConfigDevice **prev, *new;
@@ -992,7 +1001,7 @@ KdAddConfigPointer (char *pointer)
}
int
-KdAddPointer (KdPointerInfo *pi)
+KdAddPointer(KdPointerInfo * pi)
{
KdPointerInfo **prev;
@@ -1016,7 +1025,7 @@ KdAddPointer (KdPointerInfo *pi)
}
void
-KdRemovePointer (KdPointerInfo *pi)
+KdRemovePointer(KdPointerInfo * pi)
{
KdPointerInfo **prev;
@@ -1039,15 +1048,13 @@ KdRemovePointer (KdPointerInfo *pi)
* evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
*/
static Bool
-KdGetOptions (InputOption **options, char *string)
+KdGetOptions(InputOption **options, char *string)
{
- InputOption *newopt = NULL;
- char *key = NULL,
- *value = NULL;
- int tam_key = 0;
+ InputOption *newopt = NULL;
+ char *key = NULL, *value = NULL;
+ int tam_key = 0;
- if (strchr(string, '='))
- {
+ if (strchr(string, '=')) {
tam_key = (strchr(string, '=') - string);
key = strndup(string, tam_key);
if (!key)
@@ -1057,8 +1064,7 @@ KdGetOptions (InputOption **options, char *string)
if (!value)
goto out;
}
- else
- {
+ else {
key = strdup(string);
value = NULL;
}
@@ -1067,7 +1073,7 @@ KdGetOptions (InputOption **options, char *string)
if (newopt)
*options = newopt;
-out:
+ out:
free(key);
free(value);
@@ -1075,12 +1081,11 @@ out:
}
static void
-KdParseKbdOptions (KdKeyboardInfo *ki)
+KdParseKbdOptions(KdKeyboardInfo * ki)
{
InputOption *option = NULL;
- nt_list_for_each_entry(option, ki->options, list.next)
- {
+ nt_list_for_each_entry(option, ki->options, list.next) {
const char *key = input_option_get_key(option);
const char *value = input_option_get_value(option);
@@ -1094,21 +1099,21 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
ki->xkbVariant = strdup(value);
else if (strcasecmp(key, "XkbOptions") == 0)
ki->xkbOptions = strdup(value);
- else if (!strcasecmp (key, "device"))
+ else if (!strcasecmp(key, "device"))
ki->path = strdup(value);
else
- ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
- key, value);
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ key, value);
}
}
KdKeyboardInfo *
-KdParseKeyboard (char *arg)
+KdParseKeyboard(char *arg)
{
- char save[1024];
- char delim;
- InputOption *options = NULL;
- KdKeyboardInfo *ki = NULL;
+ char save[1024];
+ char delim;
+ InputOption *options = NULL;
+ KdKeyboardInfo *ki = NULL;
ki = KdNewKeyboard();
if (!ki)
@@ -1120,53 +1125,46 @@ KdParseKeyboard (char *arg)
ki->driverPrivate = NULL;
ki->next = NULL;
- if (!arg)
- {
+ if (!arg) {
ErrorF("keybd: no arg\n");
- KdFreeKeyboard (ki);
+ KdFreeKeyboard(ki);
return NULL;
}
- if (strlen (arg) >= sizeof (save))
- {
+ if (strlen(arg) >= sizeof(save)) {
ErrorF("keybd: arg too long\n");
- KdFreeKeyboard (ki);
+ KdFreeKeyboard(ki);
return NULL;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (!save[0])
- {
+ arg = KdParseFindNext(arg, ",", save, &delim);
+ if (!save[0]) {
ErrorF("keybd: failed on save[0]\n");
- KdFreeKeyboard (ki);
+ KdFreeKeyboard(ki);
return NULL;
}
- if (strcmp (save, "auto") == 0)
+ if (strcmp(save, "auto") == 0)
ki->driverPrivate = NULL;
else
ki->driverPrivate = strdup(save);
- if (delim != ',')
- {
+ if (delim != ',') {
return ki;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
+ arg = KdParseFindNext(arg, ",", save, &delim);
- while (delim == ',')
- {
- arg = KdParseFindNext (arg, ",", save, &delim);
+ while (delim == ',') {
+ arg = KdParseFindNext(arg, ",", save, &delim);
- if (!KdGetOptions(&options, save))
- {
- KdFreeKeyboard(ki);
- return NULL;
+ if (!KdGetOptions(&options, save)) {
+ KdFreeKeyboard(ki);
+ return NULL;
}
}
- if (options)
- {
+ if (options) {
ki->options = options;
KdParseKbdOptions(ki);
}
@@ -1175,41 +1173,40 @@ KdParseKeyboard (char *arg)
}
static void
-KdParsePointerOptions (KdPointerInfo *pi)
+KdParsePointerOptions(KdPointerInfo * pi)
{
InputOption *option = NULL;
- nt_list_for_each_entry(option, pi->options, list.next)
- {
+ nt_list_for_each_entry(option, pi->options, list.next) {
const char *key = input_option_get_key(option);
const char *value = input_option_get_value(option);
- if (!strcmp (key, "emulatemiddle"))
+ if (!strcmp(key, "emulatemiddle"))
pi->emulateMiddleButton = TRUE;
- else if (!strcmp (key, "noemulatemiddle"))
+ else if (!strcmp(key, "noemulatemiddle"))
pi->emulateMiddleButton = FALSE;
- else if (!strcmp (key, "transformcoord"))
+ else if (!strcmp(key, "transformcoord"))
pi->transformCoordinates = TRUE;
- else if (!strcmp (key, "rawcoord"))
+ else if (!strcmp(key, "rawcoord"))
pi->transformCoordinates = FALSE;
- else if (!strcasecmp (key, "device"))
+ else if (!strcasecmp(key, "device"))
pi->path = strdup(value);
- else if (!strcasecmp (key, "protocol"))
+ else if (!strcasecmp(key, "protocol"))
pi->protocol = strdup(value);
else
ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
- key, value);
+ key, value);
}
}
KdPointerInfo *
-KdParsePointer (char *arg)
+KdParsePointer(char *arg)
{
- char save[1024];
- char delim;
- KdPointerInfo *pi = NULL;
- InputOption *options = NULL;
- int i = 0;
+ char save[1024];
+ char delim;
+ KdPointerInfo *pi = NULL;
+ InputOption *options = NULL;
+ int i = 0;
pi = KdNewPointer();
if (!pi)
@@ -1217,27 +1214,24 @@ KdParsePointer (char *arg)
pi->emulateMiddleButton = kdEmulateMiddleButton;
pi->transformCoordinates = !kdRawPointerCoordinates;
pi->protocol = NULL;
- pi->nButtons = 5; /* XXX should not be hardcoded */
+ pi->nButtons = 5; /* XXX should not be hardcoded */
pi->inputClass = KD_MOUSE;
- if (!arg)
- {
+ if (!arg) {
ErrorF("mouse: no arg\n");
- KdFreePointer (pi);
+ KdFreePointer(pi);
return NULL;
}
- if (strlen (arg) >= sizeof (save))
- {
+ if (strlen(arg) >= sizeof(save)) {
ErrorF("mouse: arg too long\n");
- KdFreePointer (pi);
+ KdFreePointer(pi);
return NULL;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (!save[0])
- {
+ arg = KdParseFindNext(arg, ",", save, &delim);
+ if (!save[0]) {
ErrorF("failed on save[0]\n");
- KdFreePointer (pi);
+ KdFreePointer(pi);
return NULL;
}
@@ -1246,41 +1240,35 @@ KdParsePointer (char *arg)
else
pi->driverPrivate = strdup(save);
- if (delim != ',')
- {
+ if (delim != ',') {
return pi;
}
- arg = KdParseFindNext (arg, ",", save, &delim);
+ arg = KdParseFindNext(arg, ",", save, &delim);
- while (delim == ',')
- {
- arg = KdParseFindNext (arg, ",", save, &delim);
- if (save[0] == '{')
- {
+ while (delim == ',') {
+ arg = KdParseFindNext(arg, ",", save, &delim);
+ if (save[0] == '{') {
char *s = save + 1;
- i = 0;
- while (*s && *s != '}')
- {
+
+ i = 0;
+ while (*s && *s != '}') {
if ('1' <= *s && *s <= '0' + pi->nButtons)
pi->map[i] = *s - '0';
else
- UseMsg ();
+ UseMsg();
s++;
- }
+ }
}
- else
- {
- if (!KdGetOptions(&options, save))
- {
+ else {
+ if (!KdGetOptions(&options, save)) {
KdFreePointer(pi);
return NULL;
}
}
}
- if (options)
- {
+ if (options) {
pi->options = options;
KdParsePointerOptions(pi);
}
@@ -1288,9 +1276,8 @@ KdParsePointer (char *arg)
return pi;
}
-
void
-KdInitInput (void)
+KdInitInput(void)
{
KdPointerInfo *pi;
KdKeyboardInfo *ki;
@@ -1317,7 +1304,7 @@ KdInitInput (void)
}
void
-KdCloseInput (void)
+KdCloseInput(void)
{
mieqFini();
}
@@ -1480,195 +1467,203 @@ typedef enum _inputAction {
#define MAX_ACTIONS 2
typedef struct _inputTransition {
- KdInputAction actions[MAX_ACTIONS];
+ KdInputAction actions[MAX_ACTIONS];
KdPointerState nextState;
} KdInputTransition;
static const
-KdInputTransition kdInputMachine[num_input_states][num_input_class] = {
+KdInputTransition kdInputMachine[num_input_states][num_input_class] = {
/* start */
{
- { { hold, setto }, button_1_pend }, /* v1 */
- { { deliver, noop }, start }, /* ^1 */
- { { deliver, noop }, button_2_down }, /* v2 */
- { { deliver, noop }, start }, /* ^2 */
- { { hold, setto }, button_3_pend }, /* v3 */
- { { deliver, noop }, start }, /* ^3 */
- { { deliver, noop }, start }, /* vo */
- { { deliver, noop }, start }, /* ^o */
- { { deliver, noop }, start }, /* <> */
- { { deliver, noop }, start }, /* <-> */
- { { noop, noop }, start }, /* k */
- { { noop, noop }, start }, /* ... */
- },
+ {{hold, setto}, button_1_pend}, /* v1 */
+ {{deliver, noop}, start}, /* ^1 */
+ {{deliver, noop}, button_2_down}, /* v2 */
+ {{deliver, noop}, start}, /* ^2 */
+ {{hold, setto}, button_3_pend}, /* v3 */
+ {{deliver, noop}, start}, /* ^3 */
+ {{deliver, noop}, start}, /* vo */
+ {{deliver, noop}, start}, /* ^o */
+ {{deliver, noop}, start}, /* <> */
+ {{deliver, noop}, start}, /* <-> */
+ {{noop, noop}, start}, /* k */
+ {{noop, noop}, start}, /* ... */
+ },
/* button_1_pend */
{
- { { noop, noop }, button_1_pend }, /* v1 */
- { { release, deliver }, start }, /* ^1 */
- { { release, deliver }, button_1_down }, /* v2 */
- { { release, deliver }, button_1_down }, /* ^2 */
- { { clearto, gen_down_2 }, synth_2_down_13 }, /* v3 */
- { { release, deliver }, button_1_down }, /* ^3 */
- { { release, deliver }, button_1_down }, /* vo */
- { { release, deliver }, button_1_down }, /* ^o */
- { { deliver, noop }, button_1_pend }, /* <> */
- { { release, deliver }, button_1_down }, /* <-> */
- { { noop, noop }, button_1_down }, /* k */
- { { release, noop }, button_1_down }, /* ... */
- },
+ {{noop, noop}, button_1_pend}, /* v1 */
+ {{release, deliver}, start}, /* ^1 */
+ {{release, deliver}, button_1_down}, /* v2 */
+ {{release, deliver}, button_1_down}, /* ^2 */
+ {{clearto, gen_down_2}, synth_2_down_13}, /* v3 */
+ {{release, deliver}, button_1_down}, /* ^3 */
+ {{release, deliver}, button_1_down}, /* vo */
+ {{release, deliver}, button_1_down}, /* ^o */
+ {{deliver, noop}, button_1_pend}, /* <> */
+ {{release, deliver}, button_1_down}, /* <-> */
+ {{noop, noop}, button_1_down}, /* k */
+ {{release, noop}, button_1_down}, /* ... */
+ },
/* button_1_down */
{
- { { noop, noop }, button_1_down }, /* v1 */
- { { deliver, noop }, start }, /* ^1 */
- { { deliver, noop }, button_1_down }, /* v2 */
- { { deliver, noop }, button_1_down }, /* ^2 */
- { { deliver, noop }, button_1_down }, /* v3 */
- { { deliver, noop }, button_1_down }, /* ^3 */
- { { deliver, noop }, button_1_down }, /* vo */
- { { deliver, noop }, button_1_down }, /* ^o */
- { { deliver, noop }, button_1_down }, /* <> */
- { { deliver, noop }, button_1_down }, /* <-> */
- { { noop, noop }, button_1_down }, /* k */
- { { noop, noop }, button_1_down }, /* ... */
- },
+ {{noop, noop}, button_1_down}, /* v1 */
+ {{deliver, noop}, start}, /* ^1 */
+ {{deliver, noop}, button_1_down}, /* v2 */
+ {{deliver, noop}, button_1_down}, /* ^2 */
+ {{deliver, noop}, button_1_down}, /* v3 */
+ {{deliver, noop}, button_1_down}, /* ^3 */
+ {{deliver, noop}, button_1_down}, /* vo */
+ {{deliver, noop}, button_1_down}, /* ^o */
+ {{deliver, noop}, button_1_down}, /* <> */
+ {{deliver, noop}, button_1_down}, /* <-> */
+ {{noop, noop}, button_1_down}, /* k */
+ {{noop, noop}, button_1_down}, /* ... */
+ },
/* button_2_down */
{
- { { deliver, noop }, button_2_down }, /* v1 */
- { { deliver, noop }, button_2_down }, /* ^1 */
- { { noop, noop }, button_2_down }, /* v2 */
- { { deliver, noop }, start }, /* ^2 */
- { { deliver, noop }, button_2_down }, /* v3 */
- { { deliver, noop }, button_2_down }, /* ^3 */
- { { deliver, noop }, button_2_down }, /* vo */
- { { deliver, noop }, button_2_down }, /* ^o */
- { { deliver, noop }, button_2_down }, /* <> */
- { { deliver, noop }, button_2_down }, /* <-> */
- { { noop, noop }, button_2_down }, /* k */
- { { noop, noop }, button_2_down }, /* ... */
- },
+ {{deliver, noop}, button_2_down}, /* v1 */
+ {{deliver, noop}, button_2_down}, /* ^1 */
+ {{noop, noop}, button_2_down}, /* v2 */
+ {{deliver, noop}, start}, /* ^2 */
+ {{deliver, noop}, button_2_down}, /* v3 */
+ {{deliver, noop}, button_2_down}, /* ^3 */
+ {{deliver, noop}, button_2_down}, /* vo */
+ {{deliver, noop}, button_2_down}, /* ^o */
+ {{deliver, noop}, button_2_down}, /* <> */
+ {{deliver, noop}, button_2_down}, /* <-> */
+ {{noop, noop}, button_2_down}, /* k */
+ {{noop, noop}, button_2_down}, /* ... */
+ },
/* button_3_pend */
{
- { { clearto, gen_down_2 }, synth_2_down_13 }, /* v1 */
- { { release, deliver }, button_3_down }, /* ^1 */
- { { release, deliver }, button_3_down }, /* v2 */
- { { release, deliver }, button_3_down }, /* ^2 */
- { { release, deliver }, button_3_down }, /* v3 */
- { { release, deliver }, start }, /* ^3 */
- { { release, deliver }, button_3_down }, /* vo */
- { { release, deliver }, button_3_down }, /* ^o */
- { { deliver, noop }, button_3_pend }, /* <> */
- { { release, deliver }, button_3_down }, /* <-> */
- { { release, noop }, button_3_down }, /* k */
- { { release, noop }, button_3_down }, /* ... */
- },
+ {{clearto, gen_down_2}, synth_2_down_13}, /* v1 */
+ {{release, deliver}, button_3_down}, /* ^1 */
+ {{release, deliver}, button_3_down}, /* v2 */
+ {{release, deliver}, button_3_down}, /* ^2 */
+ {{release, deliver}, button_3_down}, /* v3 */
+ {{release, deliver}, start}, /* ^3 */
+ {{release, deliver}, button_3_down}, /* vo */
+ {{release, deliver}, button_3_down}, /* ^o */
+ {{deliver, noop}, button_3_pend}, /* <> */
+ {{release, deliver}, button_3_down}, /* <-> */
+ {{release, noop}, button_3_down}, /* k */
+ {{release, noop}, button_3_down}, /* ... */
+ },
/* button_3_down */
{
- { { deliver, noop }, button_3_down }, /* v1 */
- { { deliver, noop }, button_3_down }, /* ^1 */
- { { deliver, noop }, button_3_down }, /* v2 */
- { { deliver, noop }, button_3_down }, /* ^2 */
- { { noop, noop }, button_3_down }, /* v3 */
- { { deliver, noop }, start }, /* ^3 */
- { { deliver, noop }, button_3_down }, /* vo */
- { { deliver, noop }, button_3_down }, /* ^o */
- { { deliver, noop }, button_3_down }, /* <> */
- { { deliver, noop }, button_3_down }, /* <-> */
- { { noop, noop }, button_3_down }, /* k */
- { { noop, noop }, button_3_down }, /* ... */
- },
+ {{deliver, noop}, button_3_down}, /* v1 */
+ {{deliver, noop}, button_3_down}, /* ^1 */
+ {{deliver, noop}, button_3_down}, /* v2 */
+ {{deliver, noop}, button_3_down}, /* ^2 */
+ {{noop, noop}, button_3_down}, /* v3 */
+ {{deliver, noop}, start}, /* ^3 */
+ {{deliver, noop}, button_3_down}, /* vo */
+ {{deliver, noop}, button_3_down}, /* ^o */
+ {{deliver, noop}, button_3_down}, /* <> */
+ {{deliver, noop}, button_3_down}, /* <-> */
+ {{noop, noop}, button_3_down}, /* k */
+ {{noop, noop}, button_3_down}, /* ... */
+ },
/* synthetic_2_down_13 */
{
- { { noop, noop }, synth_2_down_13 }, /* v1 */
- { { gen_up_2, noop }, synth_2_down_3 }, /* ^1 */
- { { noop, noop }, synth_2_down_13 }, /* v2 */
- { { noop, noop }, synth_2_down_13 }, /* ^2 */
- { { noop, noop }, synth_2_down_13 }, /* v3 */
- { { gen_up_2, noop }, synth_2_down_1 }, /* ^3 */
- { { deliver, noop }, synth_2_down_13 }, /* vo */
- { { deliver, noop }, synth_2_down_13 }, /* ^o */
- { { deliver, noop }, synth_2_down_13 }, /* <> */
- { { deliver, noop }, synth_2_down_13 }, /* <-> */
- { { noop, noop }, synth_2_down_13 }, /* k */
- { { noop, noop }, synth_2_down_13 }, /* ... */
- },
+ {{noop, noop}, synth_2_down_13}, /* v1 */
+ {{gen_up_2, noop}, synth_2_down_3}, /* ^1 */
+ {{noop, noop}, synth_2_down_13}, /* v2 */
+ {{noop, noop}, synth_2_down_13}, /* ^2 */
+ {{noop, noop}, synth_2_down_13}, /* v3 */
+ {{gen_up_2, noop}, synth_2_down_1}, /* ^3 */
+ {{deliver, noop}, synth_2_down_13}, /* vo */
+ {{deliver, noop}, synth_2_down_13}, /* ^o */
+ {{deliver, noop}, synth_2_down_13}, /* <> */
+ {{deliver, noop}, synth_2_down_13}, /* <-> */
+ {{noop, noop}, synth_2_down_13}, /* k */
+ {{noop, noop}, synth_2_down_13}, /* ... */
+ },
/* synthetic_2_down_3 */
{
- { { deliver, noop }, synth_2_down_3 }, /* v1 */
- { { deliver, noop }, synth_2_down_3 }, /* ^1 */
- { { deliver, noop }, synth_2_down_3 }, /* v2 */
- { { deliver, noop }, synth_2_down_3 }, /* ^2 */
- { { noop, noop }, synth_2_down_3 }, /* v3 */
- { { noop, noop }, start }, /* ^3 */
- { { deliver, noop }, synth_2_down_3 }, /* vo */
- { { deliver, noop }, synth_2_down_3 }, /* ^o */
- { { deliver, noop }, synth_2_down_3 }, /* <> */
- { { deliver, noop }, synth_2_down_3 }, /* <-> */
- { { noop, noop }, synth_2_down_3 }, /* k */
- { { noop, noop }, synth_2_down_3 }, /* ... */
- },
+ {{deliver, noop}, synth_2_down_3}, /* v1 */
+ {{deliver, noop}, synth_2_down_3}, /* ^1 */
+ {{deliver, noop}, synth_2_down_3}, /* v2 */
+ {{deliver, noop}, synth_2_down_3}, /* ^2 */
+ {{noop, noop}, synth_2_down_3}, /* v3 */
+ {{noop, noop}, start}, /* ^3 */
+ {{deliver, noop}, synth_2_down_3}, /* vo */
+ {{deliver, noop}, synth_2_down_3}, /* ^o */
+ {{deliver, noop}, synth_2_down_3}, /* <> */
+ {{deliver, noop}, synth_2_down_3}, /* <-> */
+ {{noop, noop}, synth_2_down_3}, /* k */
+ {{noop, noop}, synth_2_down_3}, /* ... */
+ },
/* synthetic_2_down_1 */
{
- { { noop, noop }, synth_2_down_1 }, /* v1 */
- { { noop, noop }, start }, /* ^1 */
- { { deliver, noop }, synth_2_down_1 }, /* v2 */
- { { deliver, noop }, synth_2_down_1 }, /* ^2 */
- { { deliver, noop }, synth_2_down_1 }, /* v3 */
- { { deliver, noop }, synth_2_down_1 }, /* ^3 */
- { { deliver, noop }, synth_2_down_1 }, /* vo */
- { { deliver, noop }, synth_2_down_1 }, /* ^o */
- { { deliver, noop }, synth_2_down_1 }, /* <> */
- { { deliver, noop }, synth_2_down_1 }, /* <-> */
- { { noop, noop }, synth_2_down_1 }, /* k */
- { { noop, noop }, synth_2_down_1 }, /* ... */
- },
+ {{noop, noop}, synth_2_down_1}, /* v1 */
+ {{noop, noop}, start}, /* ^1 */
+ {{deliver, noop}, synth_2_down_1}, /* v2 */
+ {{deliver, noop}, synth_2_down_1}, /* ^2 */
+ {{deliver, noop}, synth_2_down_1}, /* v3 */
+ {{deliver, noop}, synth_2_down_1}, /* ^3 */
+ {{deliver, noop}, synth_2_down_1}, /* vo */
+ {{deliver, noop}, synth_2_down_1}, /* ^o */
+ {{deliver, noop}, synth_2_down_1}, /* <> */
+ {{deliver, noop}, synth_2_down_1}, /* <-> */
+ {{noop, noop}, synth_2_down_1}, /* k */
+ {{noop, noop}, synth_2_down_1}, /* ... */
+ },
};
#define EMULATION_WINDOW 10
#define EMULATION_TIMEOUT 100
static int
-KdInsideEmulationWindow (KdPointerInfo *pi, int x, int y, int z)
+KdInsideEmulationWindow(KdPointerInfo * pi, int x, int y, int z)
{
pi->emulationDx = pi->heldEvent.x - x;
pi->emulationDy = pi->heldEvent.y - y;
- return (abs (pi->emulationDx) < EMULATION_WINDOW &&
- abs (pi->emulationDy) < EMULATION_WINDOW);
+ return (abs(pi->emulationDx) < EMULATION_WINDOW &&
+ abs(pi->emulationDy) < EMULATION_WINDOW);
}
static KdInputClass
-KdClassifyInput (KdPointerInfo *pi, int type, int x, int y, int z, int b)
+KdClassifyInput(KdPointerInfo * pi, int type, int x, int y, int z, int b)
{
switch (type) {
case ButtonPress:
- switch (b) {
- case 1: return down_1;
- case 2: return down_2;
- case 3: return down_3;
- default: return down_o;
- }
- break;
+ switch (b) {
+ case 1:
+ return down_1;
+ case 2:
+ return down_2;
+ case 3:
+ return down_3;
+ default:
+ return down_o;
+ }
+ break;
case ButtonRelease:
- switch (b) {
- case 1: return up_1;
- case 2: return up_2;
- case 3: return up_3;
- default: return up_o;
- }
- break;
+ switch (b) {
+ case 1:
+ return up_1;
+ case 2:
+ return up_2;
+ case 3:
+ return up_3;
+ default:
+ return up_o;
+ }
+ break;
case MotionNotify:
- if (pi->eventHeld && !KdInsideEmulationWindow(pi, x, y, z))
- return outside_box;
- else
- return motion;
+ if (pi->eventHeld && !KdInsideEmulationWindow(pi, x, y, z))
+ return outside_box;
+ else
+ return motion;
default:
- return keyboard;
+ return keyboard;
}
return keyboard;
}
#ifdef DEBUG
-char *kdStateNames[] = {
+char *kdStateNames[] = {
"start",
"button_1_pend",
"button_1_down",
@@ -1681,7 +1676,7 @@ char *kdStateNames[] = {
"num_input_states"
};
-char *kdClassNames[] = {
+char *kdClassNames[] = {
"down_1", "up_1",
"down_2", "up_2",
"down_3", "up_3",
@@ -1700,95 +1695,92 @@ char *kdActionNames[] = {
"gen_down_2",
"gen_up_2",
};
-#endif /* DEBUG */
+#endif /* DEBUG */
static void
-KdQueueEvent (DeviceIntPtr pDev, InternalEvent *ev)
+KdQueueEvent(DeviceIntPtr pDev, InternalEvent *ev)
{
- KdAssertSigioBlocked ("KdQueueEvent");
- mieqEnqueue (pDev, ev);
+ KdAssertSigioBlocked("KdQueueEvent");
+ mieqEnqueue(pDev, ev);
}
/* We return true if we're stealing the event. */
static Bool
-KdRunMouseMachine (KdPointerInfo *pi, KdInputClass c, int type, int x, int y,
- int z, int b, int absrel)
+KdRunMouseMachine(KdPointerInfo * pi, KdInputClass c, int type, int x, int y,
+ int z, int b, int absrel)
{
const KdInputTransition *t;
- int a;
+ int a;
c = KdClassifyInput(pi, type, x, y, z, b);
t = &kdInputMachine[pi->mouseState][c];
- for (a = 0; a < MAX_ACTIONS; a++)
- {
- switch (t->actions[a]) {
- case noop:
- break;
- case hold:
- pi->eventHeld = TRUE;
- pi->emulationDx = 0;
- pi->emulationDy = 0;
- pi->heldEvent.type = type;
+ for (a = 0; a < MAX_ACTIONS; a++) {
+ switch (t->actions[a]) {
+ case noop:
+ break;
+ case hold:
+ pi->eventHeld = TRUE;
+ pi->emulationDx = 0;
+ pi->emulationDy = 0;
+ pi->heldEvent.type = type;
pi->heldEvent.x = x;
pi->heldEvent.y = y;
pi->heldEvent.z = z;
pi->heldEvent.flags = b;
pi->heldEvent.absrel = absrel;
return TRUE;
- break;
- case setto:
- pi->emulationTimeout = GetTimeInMillis () + EMULATION_TIMEOUT;
- pi->timeoutPending = TRUE;
- break;
- case deliver:
- _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
- pi->heldEvent.y, pi->heldEvent.z,
- pi->heldEvent.flags, pi->heldEvent.absrel,
- TRUE);
- break;
- case release:
- pi->eventHeld = FALSE;
- pi->timeoutPending = FALSE;
- _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
- pi->heldEvent.y, pi->heldEvent.z,
- pi->heldEvent.flags, pi->heldEvent.absrel,
- TRUE);
+ break;
+ case setto:
+ pi->emulationTimeout = GetTimeInMillis() + EMULATION_TIMEOUT;
+ pi->timeoutPending = TRUE;
+ break;
+ case deliver:
+ _KdEnqueuePointerEvent(pi, pi->heldEvent.type, pi->heldEvent.x,
+ pi->heldEvent.y, pi->heldEvent.z,
+ pi->heldEvent.flags, pi->heldEvent.absrel,
+ TRUE);
+ break;
+ case release:
+ pi->eventHeld = FALSE;
+ pi->timeoutPending = FALSE;
+ _KdEnqueuePointerEvent(pi, pi->heldEvent.type, pi->heldEvent.x,
+ pi->heldEvent.y, pi->heldEvent.z,
+ pi->heldEvent.flags, pi->heldEvent.absrel,
+ TRUE);
return TRUE;
- break;
- case clearto:
- pi->timeoutPending = FALSE;
- break;
- case gen_down_2:
- _KdEnqueuePointerEvent (pi, ButtonPress, x, y, z, 2, absrel,
- TRUE);
- pi->eventHeld = FALSE;
+ break;
+ case clearto:
+ pi->timeoutPending = FALSE;
+ break;
+ case gen_down_2:
+ _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, 2, absrel, TRUE);
+ pi->eventHeld = FALSE;
return TRUE;
- break;
- case gen_up_2:
- _KdEnqueuePointerEvent (pi, ButtonRelease, x, y, z, 2, absrel,
- TRUE);
+ break;
+ case gen_up_2:
+ _KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, 2, absrel, TRUE);
return TRUE;
- break;
- }
+ break;
+ }
}
pi->mouseState = t->nextState;
return FALSE;
}
static int
-KdHandlePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z, int b,
- int absrel)
+KdHandlePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z, int b,
+ int absrel)
{
if (pi->emulateMiddleButton)
- return KdRunMouseMachine (pi, KdClassifyInput(pi, type, x, y, z, b),
- type, x, y, z, b, absrel);
+ return KdRunMouseMachine(pi, KdClassifyInput(pi, type, x, y, z, b),
+ type, x, y, z, b, absrel);
return FALSE;
}
static void
-KdReceiveTimeout (KdPointerInfo *pi)
+KdReceiveTimeout(KdPointerInfo * pi)
{
- KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0);
+ KdRunMouseMachine(pi, timeout, 0, 0, 0, 0, 0, 0);
}
/*
@@ -1805,17 +1797,16 @@ KdReceiveTimeout (KdPointerInfo *pi)
extern int nClients;
void
-KdReleaseAllKeys (void)
+KdReleaseAllKeys(void)
{
#if 0
- int key;
+ int key;
KdKeyboardInfo *ki;
- KdBlockSigio ();
+ KdBlockSigio();
for (ki = kdKeyboards; ki; ki = ki->next) {
- for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode;
- key++) {
+ for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) {
if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) {
KdHandleKeyboardEvent(ki, KeyRelease, key);
QueueGetKeyboardEvents(ki->dixdev, KeyRelease, key, NULL);
@@ -1823,56 +1814,55 @@ KdReleaseAllKeys (void)
}
}
- KdUnblockSigio ();
+ KdUnblockSigio();
#endif
}
static void
-KdCheckLock (void)
+KdCheckLock(void)
{
- KeyClassPtr keyc = NULL;
- Bool isSet = FALSE, shouldBeSet = FALSE;
- KdKeyboardInfo *tmp = NULL;
+ KeyClassPtr keyc = NULL;
+ Bool isSet = FALSE, shouldBeSet = FALSE;
+ KdKeyboardInfo *tmp = NULL;
for (tmp = kdKeyboards; tmp; tmp = tmp->next) {
if (tmp->LockLed && tmp->dixdev && tmp->dixdev->key) {
keyc = tmp->dixdev->key;
- isSet = (tmp->leds & (1 << (tmp->LockLed-1))) != 0;
+ isSet = (tmp->leds & (1 << (tmp->LockLed - 1))) != 0;
/* FIXME: Just use XKB indicators! */
- shouldBeSet = !!(XkbStateFieldFromRec(&keyc->xkbInfo->state) & LockMask);
+ shouldBeSet =
+ ! !(XkbStateFieldFromRec(&keyc->xkbInfo->state) & LockMask);
if (isSet != shouldBeSet)
- KdSetLed (tmp, tmp->LockLed, shouldBeSet);
+ KdSetLed(tmp, tmp->LockLed, shouldBeSet);
}
}
}
void
-KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
- unsigned char scan_code,
- unsigned char is_up)
+KdEnqueueKeyboardEvent(KdKeyboardInfo * ki,
+ unsigned char scan_code, unsigned char is_up)
{
unsigned char key_code;
- KeyClassPtr keyc = NULL;
+ KeyClassPtr keyc = NULL;
KeybdCtrl *ctrl = NULL;
int type;
if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
- return;
+ return;
keyc = ki->dixdev->key;
ctrl = &ki->dixdev->kbdfeed->ctrl;
- if (scan_code >= ki->minScanCode && scan_code <= ki->maxScanCode)
- {
- key_code = scan_code + KD_MIN_KEYCODE - ki->minScanCode;
+ if (scan_code >= ki->minScanCode && scan_code <= ki->maxScanCode) {
+ key_code = scan_code + KD_MIN_KEYCODE - ki->minScanCode;
- /*
- * Set up this event -- the type may be modified below
- */
- if (is_up)
- type = KeyRelease;
- else
- type = KeyPress;
+ /*
+ * Set up this event -- the type may be modified below
+ */
+ if (is_up)
+ type = KeyRelease;
+ else
+ type = KeyPress;
QueueKeyboardEvents(ki->dixdev, type, key_code, NULL);
}
@@ -1893,74 +1883,72 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
/* FIXME do something a little more clever to deal with multiple axes here */
void
-KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+KdEnqueuePointerEvent(KdPointerInfo * pi, unsigned long flags, int rx, int ry,
int rz)
{
- CARD32 ms;
+ CARD32 ms;
unsigned char buttons;
- int x, y, z;
- int (*matrix)[3] = kdPointerMatrix.matrix;
+ int x, y, z;
+ int (*matrix)[3] = kdPointerMatrix.matrix;
unsigned long button;
- int n;
- int dixflags = 0;
+ int n;
+ int dixflags = 0;
if (!pi)
- return;
+ return;
ms = GetTimeInMillis();
/* we don't need to transform z, so we don't. */
if (flags & KD_MOUSE_DELTA) {
- if (pi->transformCoordinates) {
- x = matrix[0][0] * rx + matrix[0][1] * ry;
- y = matrix[1][0] * rx + matrix[1][1] * ry;
- }
- else {
- x = rx;
- y = ry;
- }
+ if (pi->transformCoordinates) {
+ x = matrix[0][0] * rx + matrix[0][1] * ry;
+ y = matrix[1][0] * rx + matrix[1][1] * ry;
+ }
+ else {
+ x = rx;
+ y = ry;
+ }
}
else {
- if (pi->transformCoordinates) {
- x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2];
- y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2];
- }
- else {
- x = rx;
- y = ry;
- }
+ if (pi->transformCoordinates) {
+ x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2];
+ y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2];
+ }
+ else {
+ x = rx;
+ y = ry;
+ }
}
z = rz;
- if (flags & KD_MOUSE_DELTA)
- {
- if (x || y || z)
- {
+ if (flags & KD_MOUSE_DELTA) {
+ if (x || y || z) {
dixflags = POINTER_RELATIVE | POINTER_ACCELERATE;
- _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
+ _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags,
+ FALSE);
}
- } else
- {
+ }
+ else {
dixflags = POINTER_ABSOLUTE;
if (x != pi->dixdev->last.valuators[0] ||
y != pi->dixdev->last.valuators[1])
- _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
+ _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags,
+ FALSE);
}
buttons = flags;
- for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
- button <<= 1, n++) {
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons; button <<= 1, n++) {
if (((pi->buttonState & button) ^ (buttons & button)) &&
- !(buttons & button)) {
+ !(buttons & button)) {
_KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, n,
dixflags, FALSE);
- }
+ }
}
- for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
- button <<= 1, n++) {
- if (((pi->buttonState & button) ^ (buttons & button)) &&
- (buttons & button)) {
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons; button <<= 1, n++) {
+ if (((pi->buttonState & button) ^ (buttons & button)) &&
+ (buttons & button)) {
_KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n,
dixflags, FALSE);
}
@@ -1970,8 +1958,8 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
}
void
-_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
- int b, int absrel, Bool force)
+_KdEnqueuePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force)
{
int valuators[3] = { x, y, z };
ValuatorMask mask;
@@ -1986,73 +1974,60 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
}
void
-KdBlockHandler (int screen,
- pointer blockData,
- pointer timeout,
- pointer readmask)
+KdBlockHandler(int screen, pointer blockData, pointer timeout, pointer readmask)
{
- KdPointerInfo *pi;
- int myTimeout=0;
-
- for (pi = kdPointers; pi; pi = pi->next)
- {
- if (pi->timeoutPending)
- {
- int ms;
+ KdPointerInfo *pi;
+ int myTimeout = 0;
- ms = pi->emulationTimeout - GetTimeInMillis ();
- if (ms < 1)
- ms = 1;
- if(ms<myTimeout || myTimeout==0)
- myTimeout=ms;
- }
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->timeoutPending) {
+ int ms;
+
+ ms = pi->emulationTimeout - GetTimeInMillis();
+ if (ms < 1)
+ ms = 1;
+ if (ms < myTimeout || myTimeout == 0)
+ myTimeout = ms;
+ }
}
/* if we need to poll for events, do that */
- if(kdOsFuncs->pollEvents)
- {
- (*kdOsFuncs->pollEvents)();
- myTimeout=20;
+ if (kdOsFuncs->pollEvents) {
+ (*kdOsFuncs->pollEvents) ();
+ myTimeout = 20;
}
- if(myTimeout>0)
- AdjustWaitForDelay (timeout, myTimeout);
+ if (myTimeout > 0)
+ AdjustWaitForDelay(timeout, myTimeout);
}
void
-KdWakeupHandler (int screen,
- pointer data,
- unsigned long lresult,
- pointer readmask)
+KdWakeupHandler(int screen,
+ pointer data, unsigned long lresult, pointer readmask)
{
- int result = (int) lresult;
- fd_set *pReadmask = (fd_set *) readmask;
- int i;
- KdPointerInfo *pi;
+ int result = (int) lresult;
+ fd_set *pReadmask = (fd_set *) readmask;
+ int i;
+ KdPointerInfo *pi;
- if (kdInputEnabled && result > 0)
- {
- for (i = 0; i < kdNumInputFds; i++)
- if (FD_ISSET (kdInputFds[i].fd, pReadmask))
- {
- KdBlockSigio ();
- (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
- KdUnblockSigio ();
- }
- }
- for (pi = kdPointers; pi; pi = pi->next)
- {
- if (pi->timeoutPending)
- {
- if ((long) (GetTimeInMillis () - pi->emulationTimeout) >= 0)
- {
- pi->timeoutPending = FALSE;
- KdBlockSigio ();
- KdReceiveTimeout (pi);
- KdUnblockSigio ();
- }
- }
+ if (kdInputEnabled && result > 0) {
+ for (i = 0; i < kdNumInputFds; i++)
+ if (FD_ISSET(kdInputFds[i].fd, pReadmask)) {
+ KdBlockSigio();
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+ KdUnblockSigio();
+ }
+ }
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->timeoutPending) {
+ if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
+ pi->timeoutPending = FALSE;
+ KdBlockSigio();
+ KdReceiveTimeout(pi);
+ KdUnblockSigio();
+ }
+ }
}
if (kdSwitchPending)
- KdProcessSwitch ();
+ KdProcessSwitch();
}
#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin))
@@ -2060,84 +2035,75 @@ KdWakeupHandler (int screen,
static Bool
KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
{
- ScreenPtr pScreen = *ppScreen;
- ScreenPtr pNewScreen;
- int n;
- int dx, dy;
- int best_x, best_y;
- int n_best_x, n_best_y;
- CARD32 ms;
+ ScreenPtr pScreen = *ppScreen;
+ ScreenPtr pNewScreen;
+ int n;
+ int dx, dy;
+ int best_x, best_y;
+ int n_best_x, n_best_y;
+ CARD32 ms;
if (kdDisableZaphod || screenInfo.numScreens <= 1)
- return FALSE;
+ return FALSE;
if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height)
- return FALSE;
+ return FALSE;
- ms = GetTimeInMillis ();
+ ms = GetTimeInMillis();
if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
- return FALSE;
+ return FALSE;
kdOffScreen = TRUE;
kdOffScreenTime = ms;
n_best_x = -1;
best_x = 32767;
n_best_y = -1;
best_y = 32767;
- for (n = 0; n < screenInfo.numScreens; n++)
- {
- pNewScreen = screenInfo.screens[n];
- if (pNewScreen == pScreen)
- continue;
- dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x;
- dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y;
- if (*x < 0)
- {
- if (dx <= 0 && -dx < best_x)
- {
- best_x = -dx;
- n_best_x = n;
- }
- }
- else if (*x >= pScreen->width)
- {
- if (dx >= 0 && dx < best_x)
- {
- best_x = dx;
- n_best_x = n;
- }
- }
- if (*y < 0)
- {
- if (dy <= 0 && -dy < best_y)
- {
- best_y = -dy;
- n_best_y = n;
- }
- }
- else if (*y >= pScreen->height)
- {
- if (dy >= 0 && dy < best_y)
- {
- best_y = dy;
- n_best_y = n;
- }
- }
+ for (n = 0; n < screenInfo.numScreens; n++) {
+ pNewScreen = screenInfo.screens[n];
+ if (pNewScreen == pScreen)
+ continue;
+ dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x;
+ dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y;
+ if (*x < 0) {
+ if (dx <= 0 && -dx < best_x) {
+ best_x = -dx;
+ n_best_x = n;
+ }
+ }
+ else if (*x >= pScreen->width) {
+ if (dx >= 0 && dx < best_x) {
+ best_x = dx;
+ n_best_x = n;
+ }
+ }
+ if (*y < 0) {
+ if (dy <= 0 && -dy < best_y) {
+ best_y = -dy;
+ n_best_y = n;
+ }
+ }
+ else if (*y >= pScreen->height) {
+ if (dy >= 0 && dy < best_y) {
+ best_y = dy;
+ n_best_y = n;
+ }
+ }
}
if (best_y < best_x)
- n_best_x = n_best_y;
+ n_best_x = n_best_y;
if (n_best_x == -1)
- return FALSE;
+ return FALSE;
pNewScreen = screenInfo.screens[n_best_x];
if (*x < 0)
- *x += pNewScreen->width;
+ *x += pNewScreen->width;
if (*y < 0)
- *y += pNewScreen->height;
+ *y += pNewScreen->height;
if (*x >= pScreen->width)
- *x -= pScreen->width;
+ *x -= pScreen->width;
if (*y >= pScreen->height)
- *y -= pScreen->height;
+ *y -= pScreen->height;
*ppScreen = pNewScreen;
return TRUE;
@@ -2148,31 +2114,30 @@ KdCrossScreen(ScreenPtr pScreen, Bool entering)
{
}
-int KdCurScreen; /* current event screen */
+int KdCurScreen; /* current event screen */
static void
-KdWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- KdBlockSigio ();
+ KdBlockSigio();
KdCurScreen = pScreen->myNum;
miPointerWarpCursor(pDev, pScreen, x, y);
- KdUnblockSigio ();
+ KdUnblockSigio();
}
-miPointerScreenFuncRec kdPointerScreenFuncs =
-{
+miPointerScreenFuncRec kdPointerScreenFuncs = {
KdCursorOffScreen,
KdCrossScreen,
KdWarpCursor
};
void
-ProcessInputEvents (void)
+ProcessInputEvents(void)
{
mieqProcessInputEvents();
if (kdSwitchPending)
- KdProcessSwitch ();
- KdCheckLock ();
+ KdProcessSwitch();
+ KdCheckLock();
}
/* At the moment, absolute/relative is up to the client. */
@@ -2191,7 +2156,7 @@ SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
int
ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
- xDeviceCtl *control)
+ xDeviceCtl * control)
{
switch (control->control) {
case DEVICE_RESOLUTION:
@@ -2214,7 +2179,7 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
}
int
-NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
DeviceIntPtr *pdev)
{
InputOption *option = NULL;
@@ -2243,16 +2208,14 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
}
#ifdef CONFIG_HAL
else if (strcmp(key, "_source") == 0 &&
- strcmp(value, "server/hal") == 0)
- {
+ strcmp(value, "server/hal") == 0) {
ErrorF("Ignoring device from HAL.\n");
return BadValue;
}
#endif
#ifdef CONFIG_UDEV
else if (strcmp(key, "_source") == 0 &&
- strcmp(value, "server/udev") == 0)
- {
+ strcmp(value, "server/udev") == 0) {
ErrorF("Ignoring device from udev.\n");
return BadValue;
}
@@ -2317,7 +2280,8 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
if (pi) {
*pdev = pi->dixdev;
- } else if(ki) {
+ }
+ else if (ki) {
*pdev = ki->dixdev;
}
diff --git a/xorg-server/hw/kdrive/src/kmode.c b/xorg-server/hw/kdrive/src/kmode.c
index 38b7bc881..ef1b6b4fa 100644
--- a/xorg-server/hw/kdrive/src/kmode.c
+++ b/xorg-server/hw/kdrive/src/kmode.c
@@ -26,223 +26,222 @@
#endif
#include "kdrive.h"
-const KdMonitorTiming kdMonitorTimings[] = {
- /* H V Hz KHz */
- /* FP BP BLANK POLARITY */
+const KdMonitorTiming kdMonitorTimings[] = {
+ /* H V Hz KHz */
+ /* FP BP BLANK POLARITY */
/* IPAQ modeline:
*
* Modeline "320x240" 5.7222 320 337 340 352 240 241 244 254"
*/
- { 320, 240, 64, 16256,
- 17, 12, 32, KdSyncNegative,
- 1, 11, 14, KdSyncNegative,
- },
+ {320, 240, 64, 16256,
+ 17, 12, 32, KdSyncNegative,
+ 1, 11, 14, KdSyncNegative,
+ },
/* Other VESA modes */
- { 640, 350, 85, 31500, /* VESA */
- 32, 96, 192, KdSyncPositive, /* 26.413 */
- 32, 60, 95, KdSyncNegative, /* 59.354 */
- },
- { 640, 400, 60, 31500, /* VESA */
- 32, 96, 192, KdSyncNegative, /* 26.413 */
- 1, 41, 45, KdSyncPositive, /* 59.354 */
- },
- { 720, 400, 85, 35500, /* VESA */
- 36, 108, 216, KdSyncNegative, /* 37.927 */
- 1, 42, 46, KdSyncPositive, /* 85.039 */
- },
-
+ {640, 350, 85, 31500, /* VESA */
+ 32, 96, 192, KdSyncPositive, /* 26.413 */
+ 32, 60, 95, KdSyncNegative, /* 59.354 */
+ },
+ {640, 400, 60, 31500, /* VESA */
+ 32, 96, 192, KdSyncNegative, /* 26.413 */
+ 1, 41, 45, KdSyncPositive, /* 59.354 */
+ },
+ {720, 400, 85, 35500, /* VESA */
+ 36, 108, 216, KdSyncNegative, /* 37.927 */
+ 1, 42, 46, KdSyncPositive, /* 85.039 */
+ },
/* Modeline "720x576" 29.000 720 736 800 880 576 577 580 625 */
{
- 720, 576, 52, 32954, /* PAL Video */
- 16, 80, 160, KdSyncPositive, /* 32.954 */
- 1, 45, 49, KdSyncPositive, /* 52.727 */
- },
+ 720, 576, 52, 32954, /* PAL Video */
+ 16, 80, 160, KdSyncPositive, /* 32.954 */
+ 1, 45, 49, KdSyncPositive, /* 52.727 */
+ },
/* 640x480 modes */
- { 640, 480, 85, 36000, /* VESA */
- 56, 80, 192, KdSyncNegative, /* 43.269 */
- 1, 25, 29, KdSyncNegative, /* 85.008 */
- },
- { 640, 480, 75, 31500, /* VESA */
- 16, 120, 200, KdSyncNegative, /* 37.500 */
- 1, 16, 20, KdSyncNegative, /* 75.000 */
- },
- { 640, 480, 72, 31500, /* VESA */
- 16, 120, 176, KdSyncNegative, /* 37.861 */
- 1, 20, 24, KdSyncNegative, /* 72.809 */
- },
- { 640, 480, 60, 25175, /* VESA */
- 16, 48, 160, KdSyncNegative, /* 31.469 */
- 10, 33, 45, KdSyncNegative, /* 59.940 */
- },
+ {640, 480, 85, 36000, /* VESA */
+ 56, 80, 192, KdSyncNegative, /* 43.269 */
+ 1, 25, 29, KdSyncNegative, /* 85.008 */
+ },
+ {640, 480, 75, 31500, /* VESA */
+ 16, 120, 200, KdSyncNegative, /* 37.500 */
+ 1, 16, 20, KdSyncNegative, /* 75.000 */
+ },
+ {640, 480, 72, 31500, /* VESA */
+ 16, 120, 176, KdSyncNegative, /* 37.861 */
+ 1, 20, 24, KdSyncNegative, /* 72.809 */
+ },
+ {640, 480, 60, 25175, /* VESA */
+ 16, 48, 160, KdSyncNegative, /* 31.469 */
+ 10, 33, 45, KdSyncNegative, /* 59.940 */
+ },
/* 800x600 modes */
- { 800, 600, 85, 56250, /* VESA */
- 32, 152, 248, KdSyncPositive, /* 53.674 */
- 1, 27, 31, KdSyncPositive, /* 85.061 */
- },
- { 800, 600, 75, 49500, /* VESA */
- 16, 160, 256, KdSyncPositive, /* 46.875 */
- 1, 21, 25, KdSyncPositive, /* 75.000 */
- },
+ {800, 600, 85, 56250, /* VESA */
+ 32, 152, 248, KdSyncPositive, /* 53.674 */
+ 1, 27, 31, KdSyncPositive, /* 85.061 */
+ },
+ {800, 600, 75, 49500, /* VESA */
+ 16, 160, 256, KdSyncPositive, /* 46.875 */
+ 1, 21, 25, KdSyncPositive, /* 75.000 */
+ },
/* DEFAULT */
#define MONITOR_TIMING_DEFAULT 9
- { 800, 600, 72, 50000, /* VESA */
- 56, 64, 240, KdSyncPositive, /* 48.077 */
- 37, 23, 66, KdSyncPositive, /* 72.188 */
- },
- { 800, 600, 60, 40000, /* VESA */
- 40, 88, 256, KdSyncPositive, /* 37.879 */
- 1, 23, 28, KdSyncPositive, /* 60.317 */
- },
- { 800, 600, 56, 36000, /* VESA */
- 24, 128, 224, KdSyncPositive, /* 35.156 */
- 1, 22, 25, KdSyncPositive, /* 56.250 */
- },
+ {800, 600, 72, 50000, /* VESA */
+ 56, 64, 240, KdSyncPositive, /* 48.077 */
+ 37, 23, 66, KdSyncPositive, /* 72.188 */
+ },
+ {800, 600, 60, 40000, /* VESA */
+ 40, 88, 256, KdSyncPositive, /* 37.879 */
+ 1, 23, 28, KdSyncPositive, /* 60.317 */
+ },
+ {800, 600, 56, 36000, /* VESA */
+ 24, 128, 224, KdSyncPositive, /* 35.156 */
+ 1, 22, 25, KdSyncPositive, /* 56.250 */
+ },
/* 1024x768 modes */
- { 1024, 768, 85, 94500, /* VESA */
- 48, 208, 352, KdSyncPositive, /* 68.677 */
- 1, 36, 40, KdSyncPositive, /* 84.997 */
- },
- { 1024, 768, 75, 78750, /* VESA */
- 16, 176, 288, KdSyncPositive, /* 60.023 */
- 1, 28, 32, KdSyncPositive, /* 75.029 */
- },
- { 1024, 768, 70, 75000, /* VESA */
- 24, 144, 304, KdSyncNegative, /* 56.476 */
- 3, 29, 38, KdSyncNegative, /* 70.069 */
- },
- { 1024, 768, 60, 65000, /* VESA */
- 24, 160, 320, KdSyncNegative, /* 48.363 */
- 3, 29, 38, KdSyncNegative, /* 60.004 */
- },
+ {1024, 768, 85, 94500, /* VESA */
+ 48, 208, 352, KdSyncPositive, /* 68.677 */
+ 1, 36, 40, KdSyncPositive, /* 84.997 */
+ },
+ {1024, 768, 75, 78750, /* VESA */
+ 16, 176, 288, KdSyncPositive, /* 60.023 */
+ 1, 28, 32, KdSyncPositive, /* 75.029 */
+ },
+ {1024, 768, 70, 75000, /* VESA */
+ 24, 144, 304, KdSyncNegative, /* 56.476 */
+ 3, 29, 38, KdSyncNegative, /* 70.069 */
+ },
+ {1024, 768, 60, 65000, /* VESA */
+ 24, 160, 320, KdSyncNegative, /* 48.363 */
+ 3, 29, 38, KdSyncNegative, /* 60.004 */
+ },
/* 1152x864 mode */
- { 1152, 864, 75, 108000, /* VESA */
- 64, 256, 448, KdSyncPositive, /* 67.500 */
- 1, 32, 36, KdSyncPositive, /* 75.000 */
- },
+ {1152, 864, 75, 108000, /* VESA */
+ 64, 256, 448, KdSyncPositive, /* 67.500 */
+ 1, 32, 36, KdSyncPositive, /* 75.000 */
+ },
/* 1152x900 modes */
- { 1152, 900, 85, 122500, /* ADDED */
- 48, 208, 384, KdSyncPositive, /* 79.753 */
- 1, 32, 38, KdSyncPositive, /* 85.024 */
- },
- { 1152, 900, 75, 108250, /* ADDED */
- 32, 208, 384, KdSyncPositive, /* 70.475 */
- 1, 32, 38, KdSyncPositive, /* 75.133 */
- },
- { 1152, 900, 70, 100250, /* ADDED */
- 32, 208, 384, KdSyncPositive, /* 65.267 */
- 2, 32, 38, KdSyncPositive, /* 69.581 */
- },
- { 1152, 900, 66, 95000, /* ADDED */
- 32, 208, 384, KdSyncPositive, /* 61.849 */
- 1, 32, 38, KdSyncPositive, /* 65.937 */
- },
+ {1152, 900, 85, 122500, /* ADDED */
+ 48, 208, 384, KdSyncPositive, /* 79.753 */
+ 1, 32, 38, KdSyncPositive, /* 85.024 */
+ },
+ {1152, 900, 75, 108250, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 70.475 */
+ 1, 32, 38, KdSyncPositive, /* 75.133 */
+ },
+ {1152, 900, 70, 100250, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 65.267 */
+ 2, 32, 38, KdSyncPositive, /* 69.581 */
+ },
+ {1152, 900, 66, 95000, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 61.849 */
+ 1, 32, 38, KdSyncPositive, /* 65.937 */
+ },
/* 1280x854 modes */
- { 1280, 854, 103, 12500, /* ADDED */
- 56, 16, 128, KdSyncPositive, /* 102.554 */
- 1, 216, 12, KdSyncPositive,
- },
+ {1280, 854, 103, 12500, /* ADDED */
+ 56, 16, 128, KdSyncPositive, /* 102.554 */
+ 1, 216, 12, KdSyncPositive,
+ },
/* 1280x960 modes */
- { 1280, 960, 85, 148500, /* VESA */
- 64, 224, 448, KdSyncPositive, /* 85.938 */
- 1, 47, 51, KdSyncPositive, /* 85.002 */
- },
- { 1280, 960, 60, 108000, /* VESA */
- 96, 312, 520, KdSyncPositive, /* 60.000 */
- 1, 36, 40, KdSyncPositive, /* 60.000 */
- },
+ {1280, 960, 85, 148500, /* VESA */
+ 64, 224, 448, KdSyncPositive, /* 85.938 */
+ 1, 47, 51, KdSyncPositive, /* 85.002 */
+ },
+ {1280, 960, 60, 108000, /* VESA */
+ 96, 312, 520, KdSyncPositive, /* 60.000 */
+ 1, 36, 40, KdSyncPositive, /* 60.000 */
+ },
/* 1280x1024 modes */
- { 1280, 1024, 85, 157500, /* VESA */
- 64, 224, 448, KdSyncPositive, /* 91.146 */
- 1, 44, 48, KdSyncPositive, /* 85.024 */
- },
- { 1280, 1024, 75, 135000, /* VESA */
- 16, 248, 408, KdSyncPositive, /* 79.976 */
- 1, 38, 42, KdSyncPositive, /* 75.025 */
- },
- { 1280, 1024, 60, 108000, /* VESA */
- 48, 248, 408, KdSyncPositive, /* 63.981 */
- 1, 38, 42, KdSyncPositive, /* 60.020 */
- },
+ {1280, 1024, 85, 157500, /* VESA */
+ 64, 224, 448, KdSyncPositive, /* 91.146 */
+ 1, 44, 48, KdSyncPositive, /* 85.024 */
+ },
+ {1280, 1024, 75, 135000, /* VESA */
+ 16, 248, 408, KdSyncPositive, /* 79.976 */
+ 1, 38, 42, KdSyncPositive, /* 75.025 */
+ },
+ {1280, 1024, 60, 108000, /* VESA */
+ 48, 248, 408, KdSyncPositive, /* 63.981 */
+ 1, 38, 42, KdSyncPositive, /* 60.020 */
+ },
/* 1600x1200 modes */
- { 1600, 1200, 85, 229500, /* VESA */
- 64, 304, 560, KdSyncPositive, /* 106.250 */
- 1, 46, 50, KdSyncPositive, /* 85.000 */
- },
- { 1600, 1200, 75, 202500, /* VESA */
- 64, 304, 560, KdSyncPositive, /* 93.750 */
- 1, 46, 50, KdSyncPositive, /* 75.000 */
- },
- { 1600, 1200, 70, 189000, /* VESA */
- 64, 304, 560, KdSyncPositive, /* 87.500 */
- 1, 46, 50, KdSyncPositive, /* 70.000 */
- },
- { 1600, 1200, 65, 175500, /* VESA */
- 64, 304, 560, KdSyncPositive, /* 81.250 */
- 1, 46, 50, KdSyncPositive, /* 65.000 */
- },
- { 1600, 1200, 60, 162000, /* VESA */
- 64, 304, 560, KdSyncPositive, /* 75.000 */
- 1, 46, 50, KdSyncPositive, /* 60.000 */
- },
+ {1600, 1200, 85, 229500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 106.250 */
+ 1, 46, 50, KdSyncPositive, /* 85.000 */
+ },
+ {1600, 1200, 75, 202500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 93.750 */
+ 1, 46, 50, KdSyncPositive, /* 75.000 */
+ },
+ {1600, 1200, 70, 189000, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 87.500 */
+ 1, 46, 50, KdSyncPositive, /* 70.000 */
+ },
+ {1600, 1200, 65, 175500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 81.250 */
+ 1, 46, 50, KdSyncPositive, /* 65.000 */
+ },
+ {1600, 1200, 60, 162000, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 75.000 */
+ 1, 46, 50, KdSyncPositive, /* 60.000 */
+ },
/* 1792x1344 modes */
- { 1792, 1344, 85, 301500, /* ADDED */
- 96, 352, 672, KdSyncNegative, /* 122.362 */
- 1, 92, 96, KdSyncPositive, /* 84.974 */
- },
- { 1792, 1344, 75, 261000, /* VESA */
- 96, 352, 664, KdSyncNegative, /* 106.270 */
- 1, 69, 73, KdSyncPositive, /* 74.997 */
- },
- { 1792, 1344, 60, 204750, /* VESA */
- 128, 328, 656, KdSyncNegative, /* 83.640 */
- 1, 46, 50, KdSyncPositive, /* 60.000 */
- },
+ {1792, 1344, 85, 301500, /* ADDED */
+ 96, 352, 672, KdSyncNegative, /* 122.362 */
+ 1, 92, 96, KdSyncPositive, /* 84.974 */
+ },
+ {1792, 1344, 75, 261000, /* VESA */
+ 96, 352, 664, KdSyncNegative, /* 106.270 */
+ 1, 69, 73, KdSyncPositive, /* 74.997 */
+ },
+ {1792, 1344, 60, 204750, /* VESA */
+ 128, 328, 656, KdSyncNegative, /* 83.640 */
+ 1, 46, 50, KdSyncPositive, /* 60.000 */
+ },
#if 0
- { 1800, 1012, 75 },
- { 1906, 1072, 68 },
+ {1800, 1012, 75},
+ {1906, 1072, 68},
#endif
/* 1856x1392 modes */
- { 1856, 1392, 85, 330500, /* ADDED */
- 160, 352, 736, KdSyncNegative, /* 127.508 */
- 1, 104, 108, KdSyncPositive, /* 85.001 */
- },
- { 1856, 1392, 75, 288000, /* VESA */
- 128, 352, 704, KdSyncNegative, /* 112.500 */
- 1, 104, 108, KdSyncPositive, /* 75.000 */
- },
- { 1856, 1392, 60, 218250, /* VESA */
- 96, 352, 672, KdSyncNegative, /* 86.333 */
- 1, 43, 47, KdSyncPositive, /* 59.995 */
- },
+ {1856, 1392, 85, 330500, /* ADDED */
+ 160, 352, 736, KdSyncNegative, /* 127.508 */
+ 1, 104, 108, KdSyncPositive, /* 85.001 */
+ },
+ {1856, 1392, 75, 288000, /* VESA */
+ 128, 352, 704, KdSyncNegative, /* 112.500 */
+ 1, 104, 108, KdSyncPositive, /* 75.000 */
+ },
+ {1856, 1392, 60, 218250, /* VESA */
+ 96, 352, 672, KdSyncNegative, /* 86.333 */
+ 1, 43, 47, KdSyncPositive, /* 59.995 */
+ },
/* 1920x1440 modes */
- { 1920, 1440, 85, 341750, /* ADDED */
- 160, 352, 760, KdSyncNegative, /* 127.512 */
- 1, 56, 60, KdSyncPositive, /* 85.012 */
- },
- { 1920, 1440, 75, 297000, /* VESA */
- 144, 352, 720, KdSyncNegative, /* 112.500 */
- 1, 56, 60, KdSyncPositive, /* 75.000 */
- },
- { 1920, 1440, 60, 234000, /* VESA */
- 128, 244, 680, KdSyncNegative, /* 90.000 */
- 1, 56, 60, KdSyncPositive, /* 60.000 */
- },
+ {1920, 1440, 85, 341750, /* ADDED */
+ 160, 352, 760, KdSyncNegative, /* 127.512 */
+ 1, 56, 60, KdSyncPositive, /* 85.012 */
+ },
+ {1920, 1440, 75, 297000, /* VESA */
+ 144, 352, 720, KdSyncNegative, /* 112.500 */
+ 1, 56, 60, KdSyncPositive, /* 75.000 */
+ },
+ {1920, 1440, 60, 234000, /* VESA */
+ 128, 244, 680, KdSyncNegative, /* 90.000 */
+ 1, 56, 60, KdSyncPositive, /* 60.000 */
+ },
};
#define NUM_MONITOR_TIMINGS (sizeof kdMonitorTimings/sizeof kdMonitorTimings[0])
@@ -250,148 +249,129 @@ const KdMonitorTiming kdMonitorTimings[] = {
const int kdNumMonitorTimings = NUM_MONITOR_TIMINGS;
const KdMonitorTiming *
-KdFindMode (KdScreenInfo *screen,
- Bool (*supported) (KdScreenInfo *,
- const KdMonitorTiming *))
+KdFindMode(KdScreenInfo * screen,
+ Bool (*supported) (KdScreenInfo *, const KdMonitorTiming *))
{
- int i;
- const KdMonitorTiming *t;
-
- for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
- {
- if ((*supported) (screen, t) &&
- t->horizontal == screen->width &&
- t->vertical == screen->height &&
- (!screen->rate || t->rate <= screen->rate))
- {
- return t;
- }
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++) {
+ if ((*supported) (screen, t) &&
+ t->horizontal == screen->width &&
+ t->vertical == screen->height &&
+ (!screen->rate || t->rate <= screen->rate)) {
+ return t;
+ }
}
ErrorF("Warning: mode not found, using default\n");
return &kdMonitorTimings[MONITOR_TIMING_DEFAULT];
}
static const KdMonitorTiming *
-kdFindPrevSize (const KdMonitorTiming *old)
+kdFindPrevSize(const KdMonitorTiming * old)
{
- const KdMonitorTiming *new, *prev;
+ const KdMonitorTiming *new, *prev;
if (old == kdMonitorTimings)
- return 0;
+ return 0;
new = old;
/*
* Search for the previous size
*/
- while (new != kdMonitorTimings)
- {
- new--;
- if (new->horizontal != old->horizontal &&
- new->vertical != old->vertical)
- {
- break;
- }
+ while (new != kdMonitorTimings) {
+ new--;
+ if (new->horizontal != old->horizontal &&
+ new->vertical != old->vertical) {
+ break;
+ }
}
/*
* Match the refresh rate (<=)
*/
- while (new != kdMonitorTimings)
- {
- prev = new - 1;
- if (prev->horizontal == new->horizontal &&
- prev->vertical == new->vertical &&
- prev->rate > old->rate)
- {
- break;
- }
- new--;
+ while (new != kdMonitorTimings) {
+ prev = new - 1;
+ if (prev->horizontal == new->horizontal &&
+ prev->vertical == new->vertical && prev->rate > old->rate) {
+ break;
+ }
+ new--;
}
return new;
}
Bool
-KdTuneMode (KdScreenInfo *screen,
- Bool (*usable) (KdScreenInfo *),
- Bool (*supported) (KdScreenInfo *,
- const KdMonitorTiming *))
+KdTuneMode(KdScreenInfo * screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *, const KdMonitorTiming *))
{
- const KdMonitorTiming *t;
-
- while (!(*usable) (screen))
- {
- /*
- * Fix requested depth and geometry until it works
- */
- if (screen->fb.depth > 16)
- screen->fb.depth = 16;
- else if (screen->fb.depth > 8)
- screen->fb.depth = 8;
- else
- {
- t = kdFindPrevSize (KdFindMode (screen, supported));
- if (!t)
- return FALSE;
- screen->width = t->horizontal;
- screen->height = t->vertical;
- screen->rate = t->rate;
- }
+ const KdMonitorTiming *t;
+
+ while (!(*usable) (screen)) {
+ /*
+ * Fix requested depth and geometry until it works
+ */
+ if (screen->fb.depth > 16)
+ screen->fb.depth = 16;
+ else if (screen->fb.depth > 8)
+ screen->fb.depth = 8;
+ else {
+ t = kdFindPrevSize(KdFindMode(screen, supported));
+ if (!t)
+ return FALSE;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+ screen->rate = t->rate;
+ }
}
return TRUE;
}
#ifdef RANDR
Bool
-KdRandRGetInfo (ScreenPtr pScreen,
- int randr,
- Bool (*supported) (ScreenPtr pScreen,
- const KdMonitorTiming *))
+KdRandRGetInfo(ScreenPtr pScreen,
+ int randr,
+ Bool (*supported) (ScreenPtr pScreen, const KdMonitorTiming *))
{
KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- int i;
- const KdMonitorTiming *t;
-
- for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
- {
- if ((*supported) (pScreen, t))
- {
- RRScreenSizePtr pSize;
-
- pSize = RRRegisterSize (pScreen,
- t->horizontal,
- t->vertical,
- screen->width_mm,
- screen->height_mm);
- if (!pSize)
- return FALSE;
- if (!RRRegisterRate (pScreen, pSize, t->rate))
- return FALSE;
- if (t->horizontal == screen->width &&
- t->vertical == screen->height &&
- t->rate == screen->rate)
- RRSetCurrentConfig (pScreen, randr, t->rate, pSize);
- }
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++) {
+ if ((*supported) (pScreen, t)) {
+ RRScreenSizePtr pSize;
+
+ pSize = RRRegisterSize(pScreen,
+ t->horizontal,
+ t->vertical,
+ screen->width_mm, screen->height_mm);
+ if (!pSize)
+ return FALSE;
+ if (!RRRegisterRate(pScreen, pSize, t->rate))
+ return FALSE;
+ if (t->horizontal == screen->width &&
+ t->vertical == screen->height && t->rate == screen->rate)
+ RRSetCurrentConfig(pScreen, randr, t->rate, pSize);
+ }
}
return TRUE;
}
const KdMonitorTiming *
-KdRandRGetTiming (ScreenPtr pScreen,
- Bool (*supported) (ScreenPtr pScreen,
- const KdMonitorTiming *),
- int rate,
- RRScreenSizePtr pSize)
+KdRandRGetTiming(ScreenPtr pScreen,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *),
+ int rate, RRScreenSizePtr pSize)
{
- int i;
- const KdMonitorTiming *t;
-
- for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
- {
- if (t->horizontal == pSize->width &&
- t->vertical == pSize->height &&
- t->rate == rate &&
- (*supported) (pScreen, t))
- return t;
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++) {
+ if (t->horizontal == pSize->width &&
+ t->vertical == pSize->height &&
+ t->rate == rate && (*supported) (pScreen, t))
+ return t;
}
return 0;
}
diff --git a/xorg-server/hw/kdrive/src/kshadow.c b/xorg-server/hw/kdrive/src/kshadow.c
index 63bb87bc6..828ea19a6 100644
--- a/xorg-server/hw/kdrive/src/kshadow.c
+++ b/xorg-server/hw/kdrive/src/kshadow.c
@@ -26,21 +26,21 @@
#include "kdrive.h"
Bool
-KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate)
+KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate)
{
- int paddedWidth;
- void *buf;
- int width = rotate ? screen->height : screen->width;
- int height = rotate ? screen->width : screen->height;
- int bpp = screen->fb.bitsPerPixel;
+ int paddedWidth;
+ void *buf;
+ int width = rotate ? screen->height : screen->width;
+ int height = rotate ? screen->width : screen->height;
+ int bpp = screen->fb.bitsPerPixel;
/* use fb computation for width */
- paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
+ paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
buf = malloc(paddedWidth * height);
if (!buf)
- return FALSE;
+ return FALSE;
if (screen->fb.shadow)
- free(screen->fb.frameBuffer);
+ free(screen->fb.frameBuffer);
screen->fb.shadow = TRUE;
screen->fb.frameBuffer = buf;
screen->fb.byteStride = paddedWidth;
@@ -49,33 +49,32 @@ KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate)
}
void
-KdShadowFbFree (KdScreenInfo *screen)
+KdShadowFbFree(KdScreenInfo * screen)
{
- if (screen->fb.shadow)
- {
- free(screen->fb.frameBuffer);
- screen->fb.frameBuffer = 0;
- screen->fb.shadow = FALSE;
+ if (screen->fb.shadow) {
+ free(screen->fb.frameBuffer);
+ screen->fb.frameBuffer = 0;
+ screen->fb.shadow = FALSE;
}
}
Bool
-KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window)
+KdShadowSet(ScreenPtr pScreen, int randr, ShadowUpdateProc update,
+ ShadowWindowProc window)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
- shadowRemove (pScreen, pScreen->GetScreenPixmap(pScreen));
- if(screen->fb.shadow)
- {
- return shadowAdd (pScreen, pScreen->GetScreenPixmap(pScreen),
- update, window, randr, 0);
+ shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+ if (screen->fb.shadow) {
+ return shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen),
+ update, window, randr, 0);
}
return TRUE;
}
void
-KdShadowUnset (ScreenPtr pScreen)
+KdShadowUnset(ScreenPtr pScreen)
{
shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
}
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
index e76a2c419..7097aee5c 100644
--- a/xorg-server/hw/kdrive/src/kxv.c
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -1,1906 +1,1891 @@
-/*
-
- XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
- Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
-
- Copyright (C) 2000, 2001 - Nokia Home Communications
- Copyright (C) 1998, 1999 - The XFree86 Project 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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-
-#include "scrnintstr.h"
-#include "regionstr.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "mivalidate.h"
-#include "validate.h"
-#include "resource.h"
-#include "gcstruct.h"
-#include "dixstruct.h"
-
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/Xvproto.h>
-
-#include "kxv.h"
-#include "fourcc.h"
-
-
-/* XvScreenRec fields */
-
-static Bool KdXVCloseScreen(int, ScreenPtr);
-static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
-
-/* XvAdaptorRec fields */
-
-static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
-static int KdXVFreePort(XvPortPtr);
-static int KdXVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int KdXVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int KdXVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int KdXVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
-static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
-static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
-static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
- CARD16, CARD16,CARD16, CARD16,
- unsigned int*, unsigned int*);
-static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16,
- XvImagePtr, unsigned char*, Bool,
- CARD16, CARD16);
-static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
- CARD16*, CARD16*, int*, int*);
-
-
-/* ScreenRec fields */
-
-static Bool KdXVCreateWindow(WindowPtr pWin);
-static Bool KdXVDestroyWindow(WindowPtr pWin);
-static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
-static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
-
-/* misc */
-static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
-
-static DevPrivateKeyRec KdXVWindowKeyRec;
-#define KdXVWindowKey (&KdXVWindowKeyRec)
-static DevPrivateKey KdXvScreenKey;
-static unsigned long KdXVGeneration = 0;
-static unsigned long PortResource = 0;
-
-DevPrivateKey (*XvGetScreenKeyProc)(void) = XvGetScreenKey;
-unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort;
-int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit;
-
-#define GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
-
-#define GET_KDXV_SCREEN(pScreen) \
- ((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
-
-#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
-
-static KdXVInitGenericAdaptorPtr *GenDrivers = NULL;
-static int NumGenDrivers = 0;
-
-int
-KdXVRegisterGenericAdaptorDriver(
- KdXVInitGenericAdaptorPtr InitFunc
-){
- KdXVInitGenericAdaptorPtr *newdrivers;
-
-/* fprintf(stderr,"KdXVRegisterGenericAdaptorDriver\n"); */
-
- newdrivers = realloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) *
- (1 + NumGenDrivers));
- if (!newdrivers)
- return 0;
- GenDrivers = newdrivers;
-
- GenDrivers[NumGenDrivers++] = InitFunc;
-
- return 1;
-}
-
-int
-KdXVListGenericAdaptors(
- KdScreenInfo * screen,
- KdVideoAdaptorPtr **adaptors
-){
- int i,j,n,num;
- KdVideoAdaptorPtr *DrivAdap,*new;
-
- num = 0;
- *adaptors = NULL;
- for (i = 0; i < NumGenDrivers; i++) {
- n = GenDrivers[i](screen,&DrivAdap);
- if (0 == n)
- continue;
- new = realloc(*adaptors, sizeof(KdVideoAdaptorPtr) * (num+n));
- if (NULL == new)
- continue;
- *adaptors = new;
- for (j = 0; j < n; j++, num++)
- (*adaptors)[num] = DrivAdap[j];
- }
- return num;
-}
-
-KdVideoAdaptorPtr
-KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen)
-{
- return calloc(1, sizeof(KdVideoAdaptorRec));
-}
-
-void
-KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr)
-{
- free(ptr);
-}
-
-
-Bool
-KdXVScreenInit(
- ScreenPtr pScreen,
- KdVideoAdaptorPtr *adaptors,
- int num
-){
- KdXVScreenPtr ScreenPriv;
- XvScreenPtr pxvs;
-
-/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
-
- if (KdXVGeneration != serverGeneration)
- KdXVGeneration = serverGeneration;
-
- if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
-
- if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
-
- if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
-
- KdXvScreenKey = (*XvGetScreenKeyProc)();
- PortResource = (*XvGetRTPortProc)();
-
- pxvs = GET_XV_SCREEN(pScreen);
-
-
- /* Anyone initializing the Xv layer must provide these two.
- The Xv di layer calls them without even checking if they exist! */
-
- pxvs->ddCloseScreen = KdXVCloseScreen;
- pxvs->ddQueryAdaptors = KdXVQueryAdaptors;
-
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
-
- ScreenPriv = malloc(sizeof(KdXVScreenRec));
- pxvs->devPriv.ptr = (pointer)ScreenPriv;
-
- if(!ScreenPriv) return FALSE;
-
-
- ScreenPriv->CreateWindow = pScreen->CreateWindow;
- ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
- ScreenPriv->WindowExposures = pScreen->WindowExposures;
- ScreenPriv->ClipNotify = pScreen->ClipNotify;
-
-/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */
-
- pScreen->CreateWindow = KdXVCreateWindow;
- pScreen->DestroyWindow = KdXVDestroyWindow;
- pScreen->WindowExposures = KdXVWindowExposures;
- pScreen->ClipNotify = KdXVClipNotify;
-
- if(!KdXVInitAdaptors(pScreen, adaptors, num))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
-{
- int i;
-
- free(pAdaptor->name);
-
- if(pAdaptor->pEncodings) {
- XvEncodingPtr pEncode = pAdaptor->pEncodings;
-
- for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
- free(pEncode->name);
- }
- free(pAdaptor->pEncodings);
- }
-
- free(pAdaptor->pFormats);
-
- if(pAdaptor->pPorts) {
- XvPortPtr pPort = pAdaptor->pPorts;
- XvPortRecPrivatePtr pPriv;
-
- for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- if(pPriv) {
- if(pPriv->clientClip)
- RegionDestroy(pPriv->clientClip);
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
- free(pPriv);
- }
- }
- free(pAdaptor->pPorts);
- }
-
- if(pAdaptor->nAttributes) {
- XvAttributePtr pAttribute = pAdaptor->pAttributes;
-
- for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
- free(pAttribute->name);
- }
-
- free(pAdaptor->pAttributes);
- }
-
- free(pAdaptor->pImages);
-
- free(pAdaptor->devPriv.ptr);
-}
-
-static Bool
-KdXVInitAdaptors(
- ScreenPtr pScreen,
- KdVideoAdaptorPtr *infoPtr,
- int number
-) {
- KdScreenPriv(pScreen);
- KdScreenInfo * screen = pScreenPriv->screen;
-
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- KdVideoAdaptorPtr adaptorPtr;
- XvAdaptorPtr pAdaptor, pa;
- XvAdaptorRecPrivatePtr adaptorPriv;
- int na, numAdaptor;
- XvPortRecPrivatePtr portPriv;
- XvPortPtr pPort, pp;
- int numPort;
- KdAttributePtr attributePtr;
- XvAttributePtr pAttribute, pat;
- KdVideoFormatPtr formatPtr;
- XvFormatPtr pFormat, pf;
- int numFormat, totFormat;
- KdVideoEncodingPtr encodingPtr;
- XvEncodingPtr pEncode, pe;
- KdImagePtr imagePtr;
- XvImagePtr pImage, pi;
- int numVisuals;
- VisualPtr pVisual;
- int i;
-
- pxvs->nAdaptors = 0;
- pxvs->pAdaptors = NULL;
-
- if(!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
- return FALSE;
-
- for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
- adaptorPtr = infoPtr[na];
-
- if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
- !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
- continue;
-
- /* client libs expect at least one encoding */
- if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
- continue;
-
- pa->type = adaptorPtr->type;
-
- if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
- pa->type &= ~XvVideoMask;
-
- if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
- pa->type &= ~XvStillMask;
-
- if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
- pa->type &= ~XvImageMask;
-
- if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
- !adaptorPtr->PutStill)
- pa->type &= ~XvInputMask;
-
- if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
- pa->type &= ~XvOutputMask;
-
- if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
- continue;
- if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
- continue;
-
- pa->pScreen = pScreen;
- pa->ddAllocatePort = KdXVAllocatePort;
- pa->ddFreePort = KdXVFreePort;
- pa->ddPutVideo = KdXVPutVideo;
- pa->ddPutStill = KdXVPutStill;
- pa->ddGetVideo = KdXVGetVideo;
- pa->ddGetStill = KdXVGetStill;
- pa->ddStopVideo = KdXVStopVideo;
- pa->ddPutImage = KdXVPutImage;
- pa->ddSetPortAttribute = KdXVSetPortAttribute;
- pa->ddGetPortAttribute = KdXVGetPortAttribute;
- pa->ddQueryBestSize = KdXVQueryBestSize;
- pa->ddQueryImageAttributes = KdXVQueryImageAttributes;
- pa->name = strdup(adaptorPtr->name);
-
- if(adaptorPtr->nEncodings &&
- (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
-
- for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
- i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
- {
- pe->id = encodingPtr->id;
- pe->pScreen = pScreen;
- pe->name = strdup(encodingPtr->name);
- pe->width = encodingPtr->width;
- pe->height = encodingPtr->height;
- pe->rate.numerator = encodingPtr->rate.numerator;
- pe->rate.denominator = encodingPtr->rate.denominator;
- }
- pa->nEncodings = adaptorPtr->nEncodings;
- pa->pEncodings = pEncode;
- }
-
- if(adaptorPtr->nImages &&
- (pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
-
- for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
- i < adaptorPtr->nImages; i++, pi++, imagePtr++)
- {
- pi->id = imagePtr->id;
- pi->type = imagePtr->type;
- pi->byte_order = imagePtr->byte_order;
- memcpy(pi->guid, imagePtr->guid, 16);
- pi->bits_per_pixel = imagePtr->bits_per_pixel;
- pi->format = imagePtr->format;
- pi->num_planes = imagePtr->num_planes;
- pi->depth = imagePtr->depth;
- pi->red_mask = imagePtr->red_mask;
- pi->green_mask = imagePtr->green_mask;
- pi->blue_mask = imagePtr->blue_mask;
- pi->y_sample_bits = imagePtr->y_sample_bits;
- pi->u_sample_bits = imagePtr->u_sample_bits;
- pi->v_sample_bits = imagePtr->v_sample_bits;
- pi->horz_y_period = imagePtr->horz_y_period;
- pi->horz_u_period = imagePtr->horz_u_period;
- pi->horz_v_period = imagePtr->horz_v_period;
- pi->vert_y_period = imagePtr->vert_y_period;
- pi->vert_u_period = imagePtr->vert_u_period;
- pi->vert_v_period = imagePtr->vert_v_period;
- memcpy(pi->component_order, imagePtr->component_order, 32);
- pi->scanline_order = imagePtr->scanline_order;
- }
- pa->nImages = adaptorPtr->nImages;
- pa->pImages = pImage;
- }
-
- if(adaptorPtr->nAttributes &&
- (pAttribute = calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
- {
- for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
- i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
- {
- pat->flags = attributePtr->flags;
- pat->min_value = attributePtr->min_value;
- pat->max_value = attributePtr->max_value;
- pat->name = strdup(attributePtr->name);
- }
- pa->nAttributes = adaptorPtr->nAttributes;
- pa->pAttributes = pAttribute;
- }
-
-
- totFormat = adaptorPtr->nFormats;
-
- if(!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
- KdXVFreeAdaptor(pa);
- continue;
- }
- for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
- i < adaptorPtr->nFormats; i++, formatPtr++)
- {
- numVisuals = pScreen->numVisuals;
- pVisual = pScreen->visuals;
-
- while(numVisuals--) {
- if((pVisual->class == formatPtr->class) &&
- (pVisual->nplanes == formatPtr->depth)) {
-
- if(numFormat >= totFormat) {
- void *moreSpace;
- totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
- if(!moreSpace) break;
- pFormat = moreSpace;
- pf = pFormat + numFormat;
- }
-
- pf->visual = pVisual->vid;
- pf->depth = formatPtr->depth;
-
- pf++;
- numFormat++;
- }
- pVisual++;
- }
- }
- pa->nFormats = numFormat;
- pa->pFormats = pFormat;
- if(!numFormat) {
- KdXVFreeAdaptor(pa);
- continue;
- }
-
- if(!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
- KdXVFreeAdaptor(pa);
- continue;
- }
-
- adaptorPriv->flags = adaptorPtr->flags;
- adaptorPriv->PutVideo = adaptorPtr->PutVideo;
- adaptorPriv->PutStill = adaptorPtr->PutStill;
- adaptorPriv->GetVideo = adaptorPtr->GetVideo;
- adaptorPriv->GetStill = adaptorPtr->GetStill;
- adaptorPriv->StopVideo = adaptorPtr->StopVideo;
- adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
- adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
- adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
- adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
- adaptorPriv->PutImage = adaptorPtr->PutImage;
- adaptorPriv->ReputImage = adaptorPtr->ReputImage;
-
- pa->devPriv.ptr = (pointer)adaptorPriv;
-
- if(!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
- KdXVFreeAdaptor(pa);
- continue;
- }
- for(pp = pPort, i = 0, numPort = 0;
- i < adaptorPtr->nPorts; i++) {
-
- if(!(pp->id = FakeClientID(0)))
- continue;
-
- if(!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
- continue;
-
- if(!AddResource(pp->id, PortResource, pp)) {
- free(portPriv);
- continue;
- }
-
- pp->pAdaptor = pa;
- pp->pNotify = (XvPortNotifyPtr)NULL;
- pp->pDraw = (DrawablePtr)NULL;
- pp->client = (ClientPtr)NULL;
- pp->grab.client = (ClientPtr)NULL;
- pp->time = currentTime;
- pp->devPriv.ptr = portPriv;
-
- portPriv->screen = screen;
- portPriv->AdaptorRec = adaptorPriv;
- portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
-
- pp++;
- numPort++;
- }
- pa->nPorts = numPort;
- pa->pPorts = pPort;
- if(!numPort) {
- KdXVFreeAdaptor(pa);
- continue;
- }
-
- pa->base_id = pPort->id;
-
- pa++;
- numAdaptor++;
- }
-
- if(numAdaptor) {
- pxvs->nAdaptors = numAdaptor;
- pxvs->pAdaptors = pAdaptor;
- } else {
- free(pAdaptor);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Video should be clipped to the intersection of the window cliplist
- and the client cliplist specified in the GC for which the video was
- initialized. When we need to reclip a window, the GC that started
- the video may not even be around anymore. That's why we save the
- client clip from the GC when the video is initialized. We then
- use KdXVUpdateCompositeClip to calculate the new composite clip
- when we need it. This is different from what DEC did. They saved
- the GC and used it's clip list when they needed to reclip the window,
- even if the client clip was different from the one the video was
- initialized with. If the original GC was destroyed, they had to stop
- the video. I like the new method better (MArk).
-
- This function only works for windows. Will need to rewrite when
- (if) we support pixmap rendering.
-*/
-
-static void
-KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
-{
- RegionPtr pregWin, pCompositeClip;
- WindowPtr pWin;
- Bool freeCompClip = FALSE;
-
- if(portPriv->pCompositeClip)
- return;
-
- pWin = (WindowPtr)portPriv->pDraw;
-
- /* get window clip list */
- if(portPriv->subWindowMode == IncludeInferiors) {
- pregWin = NotClippedByChildren(pWin);
- freeCompClip = TRUE;
- } else
- pregWin = &pWin->clipList;
-
- if(!portPriv->clientClip) {
- portPriv->pCompositeClip = pregWin;
- portPriv->FreeCompositeClip = freeCompClip;
- return;
- }
-
- pCompositeClip = RegionCreate(NullBox, 1);
- RegionCopy(pCompositeClip, portPriv->clientClip);
- RegionTranslate(pCompositeClip,
- portPriv->pDraw->x + portPriv->clipOrg.x,
- portPriv->pDraw->y + portPriv->clipOrg.y);
- RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
-
- portPriv->pCompositeClip = pCompositeClip;
- portPriv->FreeCompositeClip = TRUE;
-
- if(freeCompClip) {
- RegionDestroy(pregWin);
- }
-}
-
-/* Save the current clientClip and update the CompositeClip whenever
- we have a fresh GC */
-
-static void
-KdXVCopyClip(
- XvPortRecPrivatePtr portPriv,
- GCPtr pGC
-){
- /* copy the new clip if it exists */
- if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
- if(!portPriv->clientClip)
- portPriv->clientClip = RegionCreate(NullBox, 1);
- /* Note: this is in window coordinates */
- RegionCopy(portPriv->clientClip, pGC->clientClip);
- } else if(portPriv->clientClip) { /* free the old clientClip */
- RegionDestroy(portPriv->clientClip);
- portPriv->clientClip = NULL;
- }
-
- /* get rid of the old clip list */
- if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- RegionDestroy(portPriv->pCompositeClip);
- }
-
- portPriv->clipOrg = pGC->clipOrg;
- portPriv->pCompositeClip = pGC->pCompositeClip;
- portPriv->FreeCompositeClip = FALSE;
- portPriv->subWindowMode = pGC->subWindowMode;
-}
-
-static int
-KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
-{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- KdXVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionInit(&ClipRegion, NullBox, 1);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr);
-
- if(ret == Success)
- portPriv->isOn = XV_ON;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-static int
-KdXVReputVideo(XvPortRecPrivatePtr portPriv)
-{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- ScreenPtr pScreen = portPriv->pDraw->pScreen;
- KdScreenPriv(pScreen);
- KdScreenInfo *screen=pScreenPriv->screen;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- KdXVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionInit(&ClipRegion, NullBox, 1);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* clip and translate to the viewport */
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = 0;
- VPBox.y1 = 0;
- VPBox.x2 = screen->width;
- VPBox.y2 = screen->height;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr);
-
- if(ret == Success) portPriv->isOn = XV_ON;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-static int
-KdXVReputImage(XvPortRecPrivatePtr portPriv)
-{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- ScreenPtr pScreen = portPriv->pDraw->pScreen;
- KdScreenPriv(pScreen);
- KdScreenInfo *screen=pScreenPriv->screen;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- KdXVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionInit(&ClipRegion, NullBox, 1);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* clip and translate to the viewport */
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = 0;
- VPBox.y1 = 0;
- VPBox.x2 = screen->width;
- VPBox.y2 = screen->height;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen, portPriv->pDraw,
- WinBox.x1, WinBox.y1,
- &ClipRegion, portPriv->DevPriv.ptr);
-
- portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-static int
-KdXVReputAllVideo(WindowPtr pWin, pointer data)
-{
- KdXVWindowPtr WinPriv;
-
- if (pWin->drawable.type != DRAWABLE_WINDOW)
- return WT_DONTWALKCHILDREN;
-
- WinPriv = GET_KDXV_WINDOW(pWin);
-
- while(WinPriv) {
- if(WinPriv->PortRec->type == XvInputMask)
- KdXVReputVideo(WinPriv->PortRec);
- else
- KdXVRegetVideo(WinPriv->PortRec);
- WinPriv = WinPriv->next;
- }
-
- return WT_WALKCHILDREN;
-}
-
-static int
-KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
-{
- KdXVWindowPtr winPriv, PrivRoot;
-
- winPriv = PrivRoot = GET_KDXV_WINDOW(pWin);
-
- /* Enlist our port in the window private */
- while(winPriv) {
- if(winPriv->PortRec == portPriv) /* we're already listed */
- break;
- winPriv = winPriv->next;
- }
-
- if(!winPriv) {
- winPriv = malloc(sizeof(KdXVWindowRec));
- if(!winPriv) return BadAlloc;
- winPriv->PortRec = portPriv;
- winPriv->next = PrivRoot;
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
- }
- return Success;
-}
-
-
-static void
-KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
-{
- KdXVWindowPtr winPriv, prevPriv = NULL;
-
- winPriv = GET_KDXV_WINDOW(pWin);
-
- while(winPriv) {
- if(winPriv->PortRec == portPriv) {
- if(prevPriv)
- prevPriv->next = winPriv->next;
- else
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
- free(winPriv);
- break;
- }
- prevPriv = winPriv;
- winPriv = winPriv->next;
- }
- portPriv->pDraw = NULL;
-}
-
-/**** ScreenRec fields ****/
-
-
-static Bool
-KdXVCreateWindow(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
- int ret;
-
- pScreen->CreateWindow = ScreenPriv->CreateWindow;
- ret = (*pScreen->CreateWindow)(pWin);
- pScreen->CreateWindow = KdXVCreateWindow;
-
- if (ret)
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
-
- return ret;
-}
-
-
-static Bool
-KdXVDestroyWindow(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
- KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin);
- int ret;
-
- while(WinPriv) {
- XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
-
- if(pPriv->isOn > XV_OFF) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->screen, pPriv->DevPriv.ptr, TRUE);
- pPriv->isOn = XV_OFF;
- }
-
- pPriv->pDraw = NULL;
- tmp = WinPriv;
- WinPriv = WinPriv->next;
- free(tmp);
- }
-
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
-
- pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
- ret = (*pScreen->DestroyWindow)(pWin);
- pScreen->DestroyWindow = KdXVDestroyWindow;
-
- return ret;
-}
-
-
-static void
-KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
- KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
- KdXVWindowPtr pPrev;
- XvPortRecPrivatePtr pPriv;
- Bool AreasExposed;
-
- AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
-
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
- (*pScreen->WindowExposures)(pWin, reg1, reg2);
- pScreen->WindowExposures = KdXVWindowExposures;
-
- /* filter out XClearWindow/Area */
- if (!pWin->valdata) return;
-
- pPrev = NULL;
-
- while(WinPriv) {
- pPriv = WinPriv->PortRec;
-
- /* Reput anyone with a reput function */
-
- switch(pPriv->type) {
- case XvInputMask:
- KdXVReputVideo(pPriv);
- break;
- case XvOutputMask:
- KdXVRegetVideo(pPriv);
- break;
- default: /* overlaid still/image*/
- if (pPriv->AdaptorRec->ReputImage)
- KdXVReputImage(pPriv);
- else if(AreasExposed) {
- KdXVWindowPtr tmp;
-
- if (pPriv->isOn == XV_ON) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->screen, pPriv->DevPriv.ptr, FALSE);
- pPriv->isOn = XV_PENDING;
- }
- pPriv->pDraw = NULL;
-
- if(!pPrev)
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
- else
- pPrev->next = WinPriv->next;
- tmp = WinPriv;
- WinPriv = WinPriv->next;
- free(tmp);
- continue;
- }
- break;
- }
- pPrev = WinPriv;
- WinPriv = WinPriv->next;
- }
-}
-
-
-static void
-KdXVClipNotify(WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
- KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
- KdXVWindowPtr tmp, pPrev = NULL;
- XvPortRecPrivatePtr pPriv;
- Bool visible = (pWin->visibility == VisibilityUnobscured) ||
- (pWin->visibility == VisibilityPartiallyObscured);
-
- while(WinPriv) {
- pPriv = WinPriv->PortRec;
-
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
-
- pPriv->pCompositeClip = NULL;
-
- /* Stop everything except images, but stop them too if the
- window isn't visible. But we only remove the images. */
-
- if(pPriv->type || !visible) {
- if(pPriv->isOn == XV_ON) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->screen, pPriv->DevPriv.ptr, FALSE);
- pPriv->isOn = XV_PENDING;
- }
-
- if(!pPriv->type) { /* overlaid still/image */
- pPriv->pDraw = NULL;
-
- if(!pPrev)
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
- else
- pPrev->next = WinPriv->next;
- tmp = WinPriv;
- WinPriv = WinPriv->next;
- free(tmp);
- continue;
- }
- }
-
- pPrev = WinPriv;
- WinPriv = WinPriv->next;
- }
-
- if(ScreenPriv->ClipNotify) {
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
- (*pScreen->ClipNotify)(pWin, dx, dy);
- pScreen->ClipNotify = KdXVClipNotify;
- }
-}
-
-
-
-/**** Required XvScreenRec fields ****/
-
-static Bool
-KdXVCloseScreen(int i, ScreenPtr pScreen)
-{
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
- XvAdaptorPtr pa;
- int c;
-
- if(!ScreenPriv) return TRUE;
-
- pScreen->CreateWindow = ScreenPriv->CreateWindow;
- pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
-
-/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */
-
- for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
- KdXVFreeAdaptor(pa);
- }
-
- free(pxvs->pAdaptors);
- free(ScreenPriv);
-
- return TRUE;
-}
-
-
-static int
-KdXVQueryAdaptors(
- ScreenPtr pScreen,
- XvAdaptorPtr *p_pAdaptors,
- int *p_nAdaptors
-){
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
-
- *p_nAdaptors = pxvs->nAdaptors;
- *p_pAdaptors = pxvs->pAdaptors;
-
- return Success;
-}
-
-static Bool
-KdXVRunning (ScreenPtr pScreen)
-{
- return (KdXVGeneration == serverGeneration &&
- GET_XV_SCREEN(pScreen) != 0);
-}
-
-Bool
-KdXVEnable(ScreenPtr pScreen)
-{
- if (!KdXVRunning (pScreen))
- return TRUE;
-
- WalkTree(pScreen, KdXVReputAllVideo, 0);
-
- return TRUE;
-}
-
-void
-KdXVDisable(ScreenPtr pScreen)
-{
- XvScreenPtr pxvs;
- KdXVScreenPtr ScreenPriv;
- XvAdaptorPtr pAdaptor;
- XvPortPtr pPort;
- XvPortRecPrivatePtr pPriv;
- int i, j;
-
- if (!KdXVRunning (pScreen))
- return;
-
- pxvs = GET_XV_SCREEN(pScreen);
- ScreenPriv = GET_KDXV_SCREEN(pScreen);
-
- for(i = 0; i < pxvs->nAdaptors; i++) {
- pAdaptor = &pxvs->pAdaptors[i];
- for(j = 0; j < pAdaptor->nPorts; j++) {
- pPort = &pAdaptor->pPorts[j];
- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- if(pPriv->isOn > XV_OFF) {
-
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->screen, pPriv->DevPriv.ptr, TRUE);
- pPriv->isOn = XV_OFF;
-
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
-
- pPriv->pCompositeClip = NULL;
-
- if(!pPriv->type && pPriv->pDraw) { /* still */
- KdXVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
- }
- }
- }
- }
-}
-
-/**** XvAdaptorRec fields ****/
-
-static int
-KdXVAllocatePort(
- unsigned long port,
- XvPortPtr pPort,
- XvPortPtr *ppPort
-){
- *ppPort = pPort;
- return Success;
-}
-
-static int
-KdXVFreePort(XvPortPtr pPort)
-{
- return Success;
-}
-
-static int
-KdXVPutVideo(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- KdScreenPriv(portPriv->screen->pScreen);
- int result;
-
- /* No dumping video to pixmaps... For now anyhow */
- if(pDraw->type != DRAWABLE_WINDOW) {
- pPort->pDraw = (DrawablePtr)NULL;
- return BadAlloc;
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- result = KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(result != Success) return result;
-
- portPriv->pDraw = pDraw;
- portPriv->type = XvInputMask;
-
- /* save a copy of these parameters */
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
-
- /* make sure we have the most recent copy of the clientClip */
- KdXVCopyClip(portPriv, pGC);
-
- /* To indicate to the DI layer that we were successful */
- pPort->pDraw = pDraw;
-
- if (!pScreenPriv->enabled) return Success;
-
- return(KdXVReputVideo(portPriv));
-}
-
-static int
-KdXVPutStill(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen = pDraw->pScreen;
- KdScreenPriv(pScreen);
- KdScreenInfo *screen=pScreenPriv->screen;
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if (!pScreenPriv->enabled) return Success;
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionInit(&ClipRegion, NullBox, 1);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = 0;
- VPBox.y1 = 0;
- VPBox.x2 = screen->width;
- VPBox.y2 = screen->height;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- if(portPriv->pDraw) {
- KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen, pDraw,
- vid_x, vid_y, WinBox.x1, WinBox.y1,
- vid_w, vid_h, drw_w, drw_h,
- &ClipRegion, portPriv->DevPriv.ptr);
-
- if((ret == Success) &&
- (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
-
- KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- portPriv->isOn = XV_ON;
- portPriv->pDraw = pDraw;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
- portPriv->type = 0; /* no mask means it's transient and should
- not be reput once it's removed */
- pPort->pDraw = pDraw; /* make sure we can get stop requests */
- }
-
-PUT_STILL_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-static int
-KdXVGetVideo(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- int result;
- KdScreenPriv(portPriv->screen->pScreen);
-
- /* No pixmaps... For now anyhow */
- if(pDraw->type != DRAWABLE_WINDOW) {
- pPort->pDraw = (DrawablePtr)NULL;
- return BadAlloc;
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- result = KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(result != Success) return result;
-
- portPriv->pDraw = pDraw;
- portPriv->type = XvOutputMask;
-
- /* save a copy of these parameters */
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
-
- /* make sure we have the most recent copy of the clientClip */
- KdXVCopyClip(portPriv, pGC);
-
- /* To indicate to the DI layer that we were successful */
- pPort->pDraw = pDraw;
-
- if(!pScreenPriv->enabled) return Success;
-
- return(KdXVRegetVideo(portPriv));
-}
-
-static int
-KdXVGetStill(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen = pDraw->pScreen;
- KdScreenPriv(pScreen);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!pScreenPriv->enabled) return Success;
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionInit(&ClipRegion, NullBox, 1);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->pDraw) {
- KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto GET_STILL_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen, pDraw,
- vid_x, vid_y, WinBox.x1, WinBox.y1,
- vid_w, vid_h, drw_w, drw_h,
- &ClipRegion, portPriv->DevPriv.ptr);
-
-GET_STILL_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-
-static int
-KdXVStopVideo(
- ClientPtr client,
- XvPortPtr pPort,
- DrawablePtr pDraw
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- KdScreenPriv(portPriv->screen->pScreen);
-
- if(pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- KdXVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
-
- if(!pScreenPriv->enabled) return Success;
-
- /* Must free resources. */
-
- if(portPriv->isOn > XV_OFF) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, TRUE);
- portPriv->isOn = XV_OFF;
- }
-
- return Success;
-}
-
-static int
-KdXVSetPortAttribute(
- ClientPtr client,
- XvPortPtr pPort,
- Atom attribute,
- INT32 value
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->screen,
- attribute, value, portPriv->DevPriv.ptr));
-}
-
-
-static int
-KdXVGetPortAttribute(
- ClientPtr client,
- XvPortPtr pPort,
- Atom attribute,
- INT32 *p_value
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->screen,
- attribute, (int *) p_value, portPriv->DevPriv.ptr));
-}
-
-
-
-static int
-KdXVQueryBestSize(
- ClientPtr client,
- XvPortPtr pPort,
- CARD8 motion,
- CARD16 vid_w, CARD16 vid_h,
- CARD16 drw_w, CARD16 drw_h,
- unsigned int *p_w, unsigned int *p_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- (*portPriv->AdaptorRec->QueryBestSize)(portPriv->screen,
- (Bool)motion, vid_w, vid_h, drw_w, drw_h,
- p_w, p_h, portPriv->DevPriv.ptr);
-
- return Success;
-}
-
-
-static int
-KdXVPutImage(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 src_x, INT16 src_y,
- CARD16 src_w, CARD16 src_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h,
- XvImagePtr format,
- unsigned char* data,
- Bool sync,
- CARD16 width, CARD16 height
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen = pDraw->pScreen;
- KdScreenPriv(pScreen);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!pScreenPriv->enabled) return Success;
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionInit(&ClipRegion, NullBox, 1);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = 0;
- VPBox.y1 = 0;
- VPBox.x2 = pScreen->width;
- VPBox.y2 = pScreen->height;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- if(portPriv->pDraw) {
- KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen, pDraw,
- src_x, src_y, WinBox.x1, WinBox.y1,
- src_w, src_h, drw_w, drw_h, format->id, data, width, height,
- sync, &ClipRegion, portPriv->DevPriv.ptr);
-
- if((ret == Success) &&
- (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
-
- KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- portPriv->isOn = XV_ON;
- portPriv->pDraw = pDraw;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
- portPriv->type = 0; /* no mask means it's transient and should
- not be reput once it's removed */
- pPort->pDraw = pDraw; /* make sure we can get stop requests */
- }
-
-PUT_IMAGE_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->screen, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-static int
-KdXVQueryImageAttributes(
- ClientPtr client,
- XvPortPtr pPort,
- XvImagePtr format,
- CARD16 *width,
- CARD16 *height,
- int *pitches,
- int *offsets
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->screen,
- format->id, width, height, pitches, offsets);
-}
-
-
-/**************** Common video manipulation functions *******************/
-
-void
-KdXVCopyPackedData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
- int srcPitch, int dstPitch, int srcW, int srcH, int top, int left,
- int h, int w)
-{
- int srcDown = srcPitch, srcRight = 2, srcNext;
- int p;
-
- switch (randr & RR_Rotate_All) {
- case RR_Rotate_0:
- srcDown = srcPitch;
- srcRight = 2;
- break;
- case RR_Rotate_90:
- src += (srcH - 1) * 2;
- srcDown = -2;
- srcRight = srcPitch;
- break;
- case RR_Rotate_180:
- src += srcPitch * (srcH - 1) + (srcW - 1) * 2;
- srcDown = -srcPitch;
- srcRight = -2;
- break;
- case RR_Rotate_270:
- src += srcPitch * (srcW - 1);
- srcDown = 2;
- srcRight = -srcPitch;
- break;
- }
-
- src = src + top * srcDown + left * srcRight;
-
- w >>= 1;
- /* srcRight >>= 1; */
- srcNext = srcRight >> 1;
- while (h--) {
- CARD16 *s = (CARD16 *)src;
- CARD32 *d = (CARD32 *)dst;
- p = w;
- while (p--) {
- *d++ = s[0] | (s[srcNext] << 16);
- s += srcRight;
- }
- src += srcPitch;
- dst += dstPitch;
- }
-}
-
-void
-KdXVCopyPlanarData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
- int srcPitch, int srcPitch2, int dstPitch, int srcW, int srcH, int height,
- int top, int left, int h, int w, int id)
-{
- int i, j;
- CARD8 *src1, *src2, *src3, *dst1;
- int srcDown = srcPitch, srcDown2 = srcPitch2;
- int srcRight = 2, srcRight2 = 1, srcNext = 1;
-
- /* compute source data pointers */
- src1 = src;
- src2 = src1 + height * srcPitch;
- src3 = src2 + (height >> 1) * srcPitch2;
- switch (randr & RR_Rotate_All) {
- case RR_Rotate_0:
- srcDown = srcPitch;
- srcDown2 = srcPitch2;
- srcRight = 2;
- srcRight2 = 1;
- srcNext = 1;
- break;
- case RR_Rotate_90:
- src1 = src1 + srcH - 1;
- src2 = src2 + (srcH >> 1) - 1;
- src3 = src3 + (srcH >> 1) - 1;
- srcDown = -1;
- srcDown2 = -1;
- srcRight = srcPitch * 2;
- srcRight2 = srcPitch2;
- srcNext = srcPitch;
- break;
- case RR_Rotate_180:
- src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
- src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
- src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
- srcDown = -srcPitch;
- srcDown2 = -srcPitch2;
- srcRight = -2;
- srcRight2 = -1;
- srcNext = -1;
- break;
- case RR_Rotate_270:
- src1 = src1 + srcPitch * (srcW - 1);
- src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
- src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
- srcDown = 1;
- srcDown2 = 1;
- srcRight = -srcPitch * 2;
- srcRight2 = -srcPitch2;
- srcNext = -srcPitch;
- break;
- }
-
- /* adjust for origin */
- src1 += top * srcDown + left * srcNext;
- src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
- src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
-
- if (id == FOURCC_I420) {
- CARD8 *srct = src2;
- src2 = src3;
- src3 = srct;
- }
-
- dst1 = dst;
-
- w >>= 1;
- for (j = 0; j < h; j++) {
- CARD32 *dst = (CARD32 *)dst1;
- CARD8 *s1l = src1;
- CARD8 *s1r = src1 + srcNext;
- CARD8 *s2 = src2;
- CARD8 *s3 = src3;
-
- for (i = 0; i < w; i++) {
- *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
- s1l += srcRight;
- s1r += srcRight;
- s2 += srcRight2;
- s3 += srcRight2;
- }
- src1 += srcDown;
- dst1 += dstPitch;
- if (j & 1) {
- src2 += srcDown2;
- src3 += srcDown2;
- }
- }
-}
-
-void
-KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
-{
- GCPtr pGC;
- ChangeGCVal val[2];
- xRectangle *rects, *r;
- BoxPtr pBox = RegionRects (pRgn);
- int nBox = RegionNumRects (pRgn);
-
- rects = malloc(nBox * sizeof (xRectangle));
- if (!rects)
- goto bail0;
- r = rects;
- while (nBox--)
- {
- r->x = pBox->x1 - pDraw->x;
- r->y = pBox->y1 - pDraw->y;
- r->width = pBox->x2 - pBox->x1;
- r->height = pBox->y2 - pBox->y1;
- r++;
- pBox++;
- }
-
- pGC = GetScratchGC (pDraw->depth, pDraw->pScreen);
- if (!pGC)
- goto bail1;
-
- val[0].val = fg;
- val[1].val = IncludeInferiors;
- ChangeGC (NullClient, pGC, GCForeground|GCSubwindowMode, val);
-
- ValidateGC (pDraw, pGC);
-
- (*pGC->ops->PolyFillRect) (pDraw, pGC,
- RegionNumRects (pRgn), rects);
-
- FreeScratchGC (pGC);
-bail1:
- free(rects);
-bail0:
- ;
-}
+/*
+
+ XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
+ Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
+
+ Copyright (C) 2000, 2001 - Nokia Home Communications
+ Copyright (C) 1998, 1999 - The XFree86 Project 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, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "mivalidate.h"
+#include "validate.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+#include "kxv.h"
+#include "fourcc.h"
+
+/* XvScreenRec fields */
+
+static Bool KdXVCloseScreen(int, ScreenPtr);
+static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
+
+/* XvAdaptorRec fields */
+
+static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr *);
+static int KdXVFreePort(XvPortPtr);
+static int KdXVPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
+static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
+static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
+static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
+ CARD16, CARD16, CARD16, CARD16,
+ unsigned int *, unsigned int *);
+static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
+static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+ CARD16 *, CARD16 *, int *, int *);
+
+/* ScreenRec fields */
+
+static Bool KdXVCreateWindow(WindowPtr pWin);
+static Bool KdXVDestroyWindow(WindowPtr pWin);
+static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
+static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
+
+/* misc */
+static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr *, int);
+
+static DevPrivateKeyRec KdXVWindowKeyRec;
+
+#define KdXVWindowKey (&KdXVWindowKeyRec)
+static DevPrivateKey KdXvScreenKey;
+static unsigned long KdXVGeneration = 0;
+static unsigned long PortResource = 0;
+
+DevPrivateKey (*XvGetScreenKeyProc) (void) = XvGetScreenKey;
+unsigned long (*XvGetRTPortProc) (void) = XvGetRTPort;
+int (*XvScreenInitProc) (ScreenPtr) = XvScreenInit;
+
+#define GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
+
+#define GET_KDXV_SCREEN(pScreen) \
+ ((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+
+#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
+
+static KdXVInitGenericAdaptorPtr *GenDrivers = NULL;
+static int NumGenDrivers = 0;
+
+int
+KdXVRegisterGenericAdaptorDriver(KdXVInitGenericAdaptorPtr InitFunc)
+{
+ KdXVInitGenericAdaptorPtr *newdrivers;
+
+/* fprintf(stderr,"KdXVRegisterGenericAdaptorDriver\n"); */
+
+ newdrivers = realloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) *
+ (1 + NumGenDrivers));
+ if (!newdrivers)
+ return 0;
+ GenDrivers = newdrivers;
+
+ GenDrivers[NumGenDrivers++] = InitFunc;
+
+ return 1;
+}
+
+int
+KdXVListGenericAdaptors(KdScreenInfo * screen, KdVideoAdaptorPtr ** adaptors)
+{
+ int i, j, n, num;
+ KdVideoAdaptorPtr *DrivAdap, *new;
+
+ num = 0;
+ *adaptors = NULL;
+ for (i = 0; i < NumGenDrivers; i++) {
+ n = GenDrivers[i] (screen, &DrivAdap);
+ if (0 == n)
+ continue;
+ new = realloc(*adaptors, sizeof(KdVideoAdaptorPtr) * (num + n));
+ if (NULL == new)
+ continue;
+ *adaptors = new;
+ for (j = 0; j < n; j++, num++)
+ (*adaptors)[num] = DrivAdap[j];
+ }
+ return num;
+}
+
+KdVideoAdaptorPtr
+KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen)
+{
+ return calloc(1, sizeof(KdVideoAdaptorRec));
+}
+
+void
+KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr)
+{
+ free(ptr);
+}
+
+Bool
+KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr * adaptors, int num)
+{
+ KdXVScreenPtr ScreenPriv;
+ XvScreenPtr pxvs;
+
+/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
+
+ if (KdXVGeneration != serverGeneration)
+ KdXVGeneration = serverGeneration;
+
+ if (!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ if (Success != (*XvScreenInitProc) (pScreen))
+ return FALSE;
+
+ KdXvScreenKey = (*XvGetScreenKeyProc) ();
+ PortResource = (*XvGetRTPortProc) ();
+
+ pxvs = GET_XV_SCREEN(pScreen);
+
+ /* Anyone initializing the Xv layer must provide these two.
+ The Xv di layer calls them without even checking if they exist! */
+
+ pxvs->ddCloseScreen = KdXVCloseScreen;
+ pxvs->ddQueryAdaptors = KdXVQueryAdaptors;
+
+ /* The Xv di layer provides us with a private hook so that we don't
+ have to allocate our own screen private. They also provide
+ a CloseScreen hook so that we don't have to wrap it. I'm not
+ sure that I appreciate that. */
+
+ ScreenPriv = malloc(sizeof(KdXVScreenRec));
+ pxvs->devPriv.ptr = (pointer) ScreenPriv;
+
+ if (!ScreenPriv)
+ return FALSE;
+
+ ScreenPriv->CreateWindow = pScreen->CreateWindow;
+ ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ ScreenPriv->WindowExposures = pScreen->WindowExposures;
+ ScreenPriv->ClipNotify = pScreen->ClipNotify;
+
+/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */
+
+ pScreen->CreateWindow = KdXVCreateWindow;
+ pScreen->DestroyWindow = KdXVDestroyWindow;
+ pScreen->WindowExposures = KdXVWindowExposures;
+ pScreen->ClipNotify = KdXVClipNotify;
+
+ if (!KdXVInitAdaptors(pScreen, adaptors, num))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
+{
+ int i;
+
+ free(pAdaptor->name);
+
+ if (pAdaptor->pEncodings) {
+ XvEncodingPtr pEncode = pAdaptor->pEncodings;
+
+ for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
+ free(pEncode->name);
+ }
+ free(pAdaptor->pEncodings);
+ }
+
+ free(pAdaptor->pFormats);
+
+ if (pAdaptor->pPorts) {
+ XvPortPtr pPort = pAdaptor->pPorts;
+ XvPortRecPrivatePtr pPriv;
+
+ for (i = 0; i < pAdaptor->nPorts; i++, pPort++) {
+ pPriv = (XvPortRecPrivatePtr) pPort->devPriv.ptr;
+ if (pPriv) {
+ if (pPriv->clientClip)
+ RegionDestroy(pPriv->clientClip);
+ if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+ free(pPriv);
+ }
+ }
+ free(pAdaptor->pPorts);
+ }
+
+ if (pAdaptor->nAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
+ free(pAttribute->name);
+ }
+
+ free(pAdaptor->pAttributes);
+ }
+
+ free(pAdaptor->pImages);
+
+ free(pAdaptor->devPriv.ptr);
+}
+
+static Bool
+KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ KdVideoAdaptorPtr adaptorPtr;
+ XvAdaptorPtr pAdaptor, pa;
+ XvAdaptorRecPrivatePtr adaptorPriv;
+ int na, numAdaptor;
+ XvPortRecPrivatePtr portPriv;
+ XvPortPtr pPort, pp;
+ int numPort;
+ KdAttributePtr attributePtr;
+ XvAttributePtr pAttribute, pat;
+ KdVideoFormatPtr formatPtr;
+ XvFormatPtr pFormat, pf;
+ int numFormat, totFormat;
+ KdVideoEncodingPtr encodingPtr;
+ XvEncodingPtr pEncode, pe;
+ KdImagePtr imagePtr;
+ XvImagePtr pImage, pi;
+ int numVisuals;
+ VisualPtr pVisual;
+ int i;
+
+ pxvs->nAdaptors = 0;
+ pxvs->pAdaptors = NULL;
+
+ if (!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
+ return FALSE;
+
+ for (pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
+ adaptorPtr = infoPtr[na];
+
+ if (!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
+ !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
+ continue;
+
+ /* client libs expect at least one encoding */
+ if (!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
+ continue;
+
+ pa->type = adaptorPtr->type;
+
+ if (!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
+ pa->type &= ~XvVideoMask;
+
+ if (!adaptorPtr->PutStill && !adaptorPtr->GetStill)
+ pa->type &= ~XvStillMask;
+
+ if (!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
+ pa->type &= ~XvImageMask;
+
+ if (!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ !adaptorPtr->PutStill)
+ pa->type &= ~XvInputMask;
+
+ if (!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
+ pa->type &= ~XvOutputMask;
+
+ if (!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+ continue;
+ if (!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ continue;
+
+ pa->pScreen = pScreen;
+ pa->ddAllocatePort = KdXVAllocatePort;
+ pa->ddFreePort = KdXVFreePort;
+ pa->ddPutVideo = KdXVPutVideo;
+ pa->ddPutStill = KdXVPutStill;
+ pa->ddGetVideo = KdXVGetVideo;
+ pa->ddGetStill = KdXVGetStill;
+ pa->ddStopVideo = KdXVStopVideo;
+ pa->ddPutImage = KdXVPutImage;
+ pa->ddSetPortAttribute = KdXVSetPortAttribute;
+ pa->ddGetPortAttribute = KdXVGetPortAttribute;
+ pa->ddQueryBestSize = KdXVQueryBestSize;
+ pa->ddQueryImageAttributes = KdXVQueryImageAttributes;
+ pa->name = strdup(adaptorPtr->name);
+
+ if (adaptorPtr->nEncodings &&
+ (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
+
+ for (pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) {
+ pe->id = encodingPtr->id;
+ pe->pScreen = pScreen;
+ pe->name = strdup(encodingPtr->name);
+ pe->width = encodingPtr->width;
+ pe->height = encodingPtr->height;
+ pe->rate.numerator = encodingPtr->rate.numerator;
+ pe->rate.denominator = encodingPtr->rate.denominator;
+ }
+ pa->nEncodings = adaptorPtr->nEncodings;
+ pa->pEncodings = pEncode;
+ }
+
+ if (adaptorPtr->nImages &&
+ (pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
+
+ for (i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++) {
+ pi->id = imagePtr->id;
+ pi->type = imagePtr->type;
+ pi->byte_order = imagePtr->byte_order;
+ memcpy(pi->guid, imagePtr->guid, 16);
+ pi->bits_per_pixel = imagePtr->bits_per_pixel;
+ pi->format = imagePtr->format;
+ pi->num_planes = imagePtr->num_planes;
+ pi->depth = imagePtr->depth;
+ pi->red_mask = imagePtr->red_mask;
+ pi->green_mask = imagePtr->green_mask;
+ pi->blue_mask = imagePtr->blue_mask;
+ pi->y_sample_bits = imagePtr->y_sample_bits;
+ pi->u_sample_bits = imagePtr->u_sample_bits;
+ pi->v_sample_bits = imagePtr->v_sample_bits;
+ pi->horz_y_period = imagePtr->horz_y_period;
+ pi->horz_u_period = imagePtr->horz_u_period;
+ pi->horz_v_period = imagePtr->horz_v_period;
+ pi->vert_y_period = imagePtr->vert_y_period;
+ pi->vert_u_period = imagePtr->vert_u_period;
+ pi->vert_v_period = imagePtr->vert_v_period;
+ memcpy(pi->component_order, imagePtr->component_order, 32);
+ pi->scanline_order = imagePtr->scanline_order;
+ }
+ pa->nImages = adaptorPtr->nImages;
+ pa->pImages = pImage;
+ }
+
+ if (adaptorPtr->nAttributes &&
+ (pAttribute =
+ calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) {
+ for (pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i =
+ 0; i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) {
+ pat->flags = attributePtr->flags;
+ pat->min_value = attributePtr->min_value;
+ pat->max_value = attributePtr->max_value;
+ pat->name = strdup(attributePtr->name);
+ }
+ pa->nAttributes = adaptorPtr->nAttributes;
+ pa->pAttributes = pAttribute;
+ }
+
+ totFormat = adaptorPtr->nFormats;
+
+ if (!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+ for (pf = pFormat, i = 0, numFormat = 0, formatPtr =
+ adaptorPtr->pFormats; i < adaptorPtr->nFormats; i++, formatPtr++) {
+ numVisuals = pScreen->numVisuals;
+ pVisual = pScreen->visuals;
+
+ while (numVisuals--) {
+ if ((pVisual->class == formatPtr->class) &&
+ (pVisual->nplanes == formatPtr->depth)) {
+
+ if (numFormat >= totFormat) {
+ void *moreSpace;
+
+ totFormat *= 2;
+ moreSpace = realloc(pFormat,
+ totFormat * sizeof(XvFormatRec));
+ if (!moreSpace)
+ break;
+ pFormat = moreSpace;
+ pf = pFormat + numFormat;
+ }
+
+ pf->visual = pVisual->vid;
+ pf->depth = formatPtr->depth;
+
+ pf++;
+ numFormat++;
+ }
+ pVisual++;
+ }
+ }
+ pa->nFormats = numFormat;
+ pa->pFormats = pFormat;
+ if (!numFormat) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+
+ if (!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+
+ adaptorPriv->flags = adaptorPtr->flags;
+ adaptorPriv->PutVideo = adaptorPtr->PutVideo;
+ adaptorPriv->PutStill = adaptorPtr->PutStill;
+ adaptorPriv->GetVideo = adaptorPtr->GetVideo;
+ adaptorPriv->GetStill = adaptorPtr->GetStill;
+ adaptorPriv->StopVideo = adaptorPtr->StopVideo;
+ adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
+ adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
+ adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
+ adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
+ adaptorPriv->PutImage = adaptorPtr->PutImage;
+ adaptorPriv->ReputImage = adaptorPtr->ReputImage;
+
+ pa->devPriv.ptr = (pointer) adaptorPriv;
+
+ if (!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+ for (pp = pPort, i = 0, numPort = 0; i < adaptorPtr->nPorts; i++) {
+
+ if (!(pp->id = FakeClientID(0)))
+ continue;
+
+ if (!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
+ continue;
+
+ if (!AddResource(pp->id, PortResource, pp)) {
+ free(portPriv);
+ continue;
+ }
+
+ pp->pAdaptor = pa;
+ pp->pNotify = (XvPortNotifyPtr) NULL;
+ pp->pDraw = (DrawablePtr) NULL;
+ pp->client = (ClientPtr) NULL;
+ pp->grab.client = (ClientPtr) NULL;
+ pp->time = currentTime;
+ pp->devPriv.ptr = portPriv;
+
+ portPriv->screen = screen;
+ portPriv->AdaptorRec = adaptorPriv;
+ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
+
+ pp++;
+ numPort++;
+ }
+ pa->nPorts = numPort;
+ pa->pPorts = pPort;
+ if (!numPort) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+
+ pa->base_id = pPort->id;
+
+ pa++;
+ numAdaptor++;
+ }
+
+ if (numAdaptor) {
+ pxvs->nAdaptors = numAdaptor;
+ pxvs->pAdaptors = pAdaptor;
+ }
+ else {
+ free(pAdaptor);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Video should be clipped to the intersection of the window cliplist
+ and the client cliplist specified in the GC for which the video was
+ initialized. When we need to reclip a window, the GC that started
+ the video may not even be around anymore. That's why we save the
+ client clip from the GC when the video is initialized. We then
+ use KdXVUpdateCompositeClip to calculate the new composite clip
+ when we need it. This is different from what DEC did. They saved
+ the GC and used it's clip list when they needed to reclip the window,
+ even if the client clip was different from the one the video was
+ initialized with. If the original GC was destroyed, they had to stop
+ the video. I like the new method better (MArk).
+
+ This function only works for windows. Will need to rewrite when
+ (if) we support pixmap rendering.
+*/
+
+static void
+KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
+{
+ RegionPtr pregWin, pCompositeClip;
+ WindowPtr pWin;
+ Bool freeCompClip = FALSE;
+
+ if (portPriv->pCompositeClip)
+ return;
+
+ pWin = (WindowPtr) portPriv->pDraw;
+
+ /* get window clip list */
+ if (portPriv->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeCompClip = TRUE;
+ }
+ else
+ pregWin = &pWin->clipList;
+
+ if (!portPriv->clientClip) {
+ portPriv->pCompositeClip = pregWin;
+ portPriv->FreeCompositeClip = freeCompClip;
+ return;
+ }
+
+ pCompositeClip = RegionCreate(NullBox, 1);
+ RegionCopy(pCompositeClip, portPriv->clientClip);
+ RegionTranslate(pCompositeClip,
+ portPriv->pDraw->x + portPriv->clipOrg.x,
+ portPriv->pDraw->y + portPriv->clipOrg.y);
+ RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
+
+ portPriv->pCompositeClip = pCompositeClip;
+ portPriv->FreeCompositeClip = TRUE;
+
+ if (freeCompClip) {
+ RegionDestroy(pregWin);
+ }
+}
+
+/* Save the current clientClip and update the CompositeClip whenever
+ we have a fresh GC */
+
+static void
+KdXVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
+{
+ /* copy the new clip if it exists */
+ if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+ if (!portPriv->clientClip)
+ portPriv->clientClip = RegionCreate(NullBox, 1);
+ /* Note: this is in window coordinates */
+ RegionCopy(portPriv->clientClip, pGC->clientClip);
+ }
+ else if (portPriv->clientClip) { /* free the old clientClip */
+ RegionDestroy(portPriv->clientClip);
+ portPriv->clientClip = NULL;
+ }
+
+ /* get rid of the old clip list */
+ if (portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
+ RegionDestroy(portPriv->pCompositeClip);
+ }
+
+ portPriv->clipOrg = pGC->clipOrg;
+ portPriv->pCompositeClip = pGC->pCompositeClip;
+ portPriv->FreeCompositeClip = FALSE;
+ portPriv->subWindowMode = pGC->subWindowMode;
+}
+
+static int
+KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ KdXVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* that's all if it's totally obscured */
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetVideo) (portPriv->screen, portPriv->pDraw,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion,
+ portPriv->DevPriv.ptr);
+
+ if (ret == Success)
+ portPriv->isOn = XV_ON;
+
+ CLIP_VIDEO_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVReputVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen = portPriv->pDraw->pScreen;
+
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ KdXVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = screen->width;
+ VPBox.y2 = screen->height;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutVideo) (portPriv->screen, portPriv->pDraw,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion,
+ portPriv->DevPriv.ptr);
+
+ if (ret == Success)
+ portPriv->isOn = XV_ON;
+
+ CLIP_VIDEO_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVReputImage(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen = portPriv->pDraw->pScreen;
+
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ KdXVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = screen->width;
+ VPBox.y2 = screen->height;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret =
+ (*portPriv->AdaptorRec->ReputImage) (portPriv->screen, portPriv->pDraw,
+ WinBox.x1, WinBox.y1, &ClipRegion,
+ portPriv->DevPriv.ptr);
+
+ portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
+
+ CLIP_VIDEO_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if (!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVReputAllVideo(WindowPtr pWin, pointer data)
+{
+ KdXVWindowPtr WinPriv;
+
+ if (pWin->drawable.type != DRAWABLE_WINDOW)
+ return WT_DONTWALKCHILDREN;
+
+ WinPriv = GET_KDXV_WINDOW(pWin);
+
+ while (WinPriv) {
+ if (WinPriv->PortRec->type == XvInputMask)
+ KdXVReputVideo(WinPriv->PortRec);
+ else
+ KdXVRegetVideo(WinPriv->PortRec);
+ WinPriv = WinPriv->next;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static int
+KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ KdXVWindowPtr winPriv, PrivRoot;
+
+ winPriv = PrivRoot = GET_KDXV_WINDOW(pWin);
+
+ /* Enlist our port in the window private */
+ while (winPriv) {
+ if (winPriv->PortRec == portPriv) /* we're already listed */
+ break;
+ winPriv = winPriv->next;
+ }
+
+ if (!winPriv) {
+ winPriv = malloc(sizeof(KdXVWindowRec));
+ if (!winPriv)
+ return BadAlloc;
+ winPriv->PortRec = portPriv;
+ winPriv->next = PrivRoot;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
+ }
+ return Success;
+}
+
+static void
+KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ KdXVWindowPtr winPriv, prevPriv = NULL;
+
+ winPriv = GET_KDXV_WINDOW(pWin);
+
+ while (winPriv) {
+ if (winPriv->PortRec == portPriv) {
+ if (prevPriv)
+ prevPriv->next = winPriv->next;
+ else
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
+ free(winPriv);
+ break;
+ }
+ prevPriv = winPriv;
+ winPriv = winPriv->next;
+ }
+ portPriv->pDraw = NULL;
+}
+
+/**** ScreenRec fields ****/
+
+static Bool
+KdXVCreateWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ int ret;
+
+ pScreen->CreateWindow = ScreenPriv->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ pScreen->CreateWindow = KdXVCreateWindow;
+
+ if (ret)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
+
+ return ret;
+}
+
+static Bool
+KdXVDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin);
+ int ret;
+
+ while (WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if (pPriv->isOn > XV_OFF) {
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->screen, pPriv->DevPriv.ptr,
+ TRUE);
+ pPriv->isOn = XV_OFF;
+ }
+
+ pPriv->pDraw = NULL;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ free(tmp);
+ }
+
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ ret = (*pScreen->DestroyWindow) (pWin);
+ pScreen->DestroyWindow = KdXVDestroyWindow;
+
+ return ret;
+}
+
+static void
+KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
+ KdXVWindowPtr pPrev;
+ XvPortRecPrivatePtr pPriv;
+ Bool AreasExposed;
+
+ AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
+
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ (*pScreen->WindowExposures) (pWin, reg1, reg2);
+ pScreen->WindowExposures = KdXVWindowExposures;
+
+ /* filter out XClearWindow/Area */
+ if (!pWin->valdata)
+ return;
+
+ pPrev = NULL;
+
+ while (WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ /* Reput anyone with a reput function */
+
+ switch (pPriv->type) {
+ case XvInputMask:
+ KdXVReputVideo(pPriv);
+ break;
+ case XvOutputMask:
+ KdXVRegetVideo(pPriv);
+ break;
+ default: /* overlaid still/image */
+ if (pPriv->AdaptorRec->ReputImage)
+ KdXVReputImage(pPriv);
+ else if (AreasExposed) {
+ KdXVWindowPtr tmp;
+
+ if (pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->screen,
+ pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+ pPriv->pDraw = NULL;
+
+ if (!pPrev)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey,
+ WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ free(tmp);
+ continue;
+ }
+ break;
+ }
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+}
+
+static void
+KdXVClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
+ KdXVWindowPtr tmp, pPrev = NULL;
+ XvPortRecPrivatePtr pPriv;
+ Bool visible = (pWin->visibility == VisibilityUnobscured) ||
+ (pWin->visibility == VisibilityPartiallyObscured);
+
+ while (WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ /* Stop everything except images, but stop them too if the
+ window isn't visible. But we only remove the images. */
+
+ if (pPriv->type || !visible) {
+ if (pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->screen,
+ pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+
+ if (!pPriv->type) { /* overlaid still/image */
+ pPriv->pDraw = NULL;
+
+ if (!pPrev)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey,
+ WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ free(tmp);
+ continue;
+ }
+ }
+
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+
+ if (ScreenPriv->ClipNotify) {
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ pScreen->ClipNotify = KdXVClipNotify;
+ }
+}
+
+/**** Required XvScreenRec fields ****/
+
+static Bool
+KdXVCloseScreen(int i, ScreenPtr pScreen)
+{
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ XvAdaptorPtr pa;
+ int c;
+
+ if (!ScreenPriv)
+ return TRUE;
+
+ pScreen->CreateWindow = ScreenPriv->CreateWindow;
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+
+/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */
+
+ for (c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
+ KdXVFreeAdaptor(pa);
+ }
+
+ free(pxvs->pAdaptors);
+ free(ScreenPriv);
+
+ return TRUE;
+}
+
+static int
+KdXVQueryAdaptors(ScreenPtr pScreen,
+ XvAdaptorPtr * p_pAdaptors, int *p_nAdaptors)
+{
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+
+ *p_nAdaptors = pxvs->nAdaptors;
+ *p_pAdaptors = pxvs->pAdaptors;
+
+ return Success;
+}
+
+static Bool
+KdXVRunning(ScreenPtr pScreen)
+{
+ return (KdXVGeneration == serverGeneration && GET_XV_SCREEN(pScreen) != 0);
+}
+
+Bool
+KdXVEnable(ScreenPtr pScreen)
+{
+ if (!KdXVRunning(pScreen))
+ return TRUE;
+
+ WalkTree(pScreen, KdXVReputAllVideo, 0);
+
+ return TRUE;
+}
+
+void
+KdXVDisable(ScreenPtr pScreen)
+{
+ XvScreenPtr pxvs;
+ KdXVScreenPtr ScreenPriv;
+ XvAdaptorPtr pAdaptor;
+ XvPortPtr pPort;
+ XvPortRecPrivatePtr pPriv;
+ int i, j;
+
+ if (!KdXVRunning(pScreen))
+ return;
+
+ pxvs = GET_XV_SCREEN(pScreen);
+ ScreenPriv = GET_KDXV_SCREEN(pScreen);
+
+ for (i = 0; i < pxvs->nAdaptors; i++) {
+ pAdaptor = &pxvs->pAdaptors[i];
+ for (j = 0; j < pAdaptor->nPorts; j++) {
+ pPort = &pAdaptor->pPorts[j];
+ pPriv = (XvPortRecPrivatePtr) pPort->devPriv.ptr;
+ if (pPriv->isOn > XV_OFF) {
+
+ (*pPriv->AdaptorRec->StopVideo) (pPriv->screen,
+ pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+
+ if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ if (!pPriv->type && pPriv->pDraw) { /* still */
+ KdXVRemovePortFromWindow((WindowPtr) pPriv->pDraw, pPriv);
+ }
+ }
+ }
+ }
+}
+
+/**** XvAdaptorRec fields ****/
+
+static int
+KdXVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
+{
+ *ppPort = pPort;
+ return Success;
+}
+
+static int
+KdXVFreePort(XvPortPtr pPort)
+{
+ return Success;
+}
+
+static int
+KdXVPutVideo(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ KdScreenPriv(portPriv->screen->pScreen);
+ int result;
+
+ /* No dumping video to pixmaps... For now anyhow */
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr) NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if (portPriv->pDraw && (portPriv->pDraw != pDraw))
+ KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ if (result != Success)
+ return result;
+
+ portPriv->pDraw = pDraw;
+ portPriv->type = XvInputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x;
+ portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w;
+ portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ KdXVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if (!pScreenPriv->enabled)
+ return Success;
+
+ return (KdXVReputVideo(portPriv));
+}
+
+static int
+KdXVPutStill(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!pScreenPriv->enabled)
+ return Success;
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = screen->width;
+ VPBox.y2 = screen->height;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ if (portPriv->pDraw) {
+ KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+ }
+
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutStill) (portPriv->screen, pDraw,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion,
+ portPriv->DevPriv.ptr);
+
+ if ((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
+
+ KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->pDraw = pDraw;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+ PUT_STILL_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVGetVideo(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ int result;
+
+ KdScreenPriv(portPriv->screen->pScreen);
+
+ /* No pixmaps... For now anyhow */
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr) NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if (portPriv->pDraw && (portPriv->pDraw != pDraw))
+ KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ if (result != Success)
+ return result;
+
+ portPriv->pDraw = pDraw;
+ portPriv->type = XvOutputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x;
+ portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w;
+ portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ KdXVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if (!pScreenPriv->enabled)
+ return Success;
+
+ return (KdXVRegetVideo(portPriv));
+}
+
+static int
+KdXVGetStill(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+
+ KdScreenPriv(pScreen);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!pScreenPriv->enabled)
+ return Success;
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if (portPriv->pDraw) {
+ KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+ }
+
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto GET_STILL_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetStill) (portPriv->screen, pDraw,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion,
+ portPriv->DevPriv.ptr);
+
+ GET_STILL_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ KdScreenPriv(portPriv->screen->pScreen);
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ KdXVRemovePortFromWindow((WindowPtr) pDraw, portPriv);
+
+ if (!pScreenPriv->enabled)
+ return Success;
+
+ /* Must free resources. */
+
+ if (portPriv->isOn > XV_OFF) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, TRUE);
+ portPriv->isOn = XV_OFF;
+ }
+
+ return Success;
+}
+
+static int
+KdXVSetPortAttribute(ClientPtr client,
+ XvPortPtr pPort, Atom attribute, INT32 value)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ return ((*portPriv->AdaptorRec->SetPortAttribute) (portPriv->screen,
+ attribute, value,
+ portPriv->DevPriv.ptr));
+}
+
+static int
+KdXVGetPortAttribute(ClientPtr client,
+ XvPortPtr pPort, Atom attribute, INT32 *p_value)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ return ((*portPriv->AdaptorRec->GetPortAttribute) (portPriv->screen,
+ attribute,
+ (int *) p_value,
+ portPriv->DevPriv.ptr));
+}
+
+static int
+KdXVQueryBestSize(ClientPtr client,
+ XvPortPtr pPort,
+ CARD8 motion,
+ CARD16 vid_w, CARD16 vid_h,
+ CARD16 drw_w, CARD16 drw_h,
+ unsigned int *p_w, unsigned int *p_h)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ (*portPriv->AdaptorRec->QueryBestSize) (portPriv->screen,
+ (Bool) motion, vid_w, vid_h, drw_w,
+ drw_h, p_w, p_h,
+ portPriv->DevPriv.ptr);
+
+ return Success;
+}
+
+static int
+KdXVPutImage(ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr format,
+ unsigned char *data, Bool sync, CARD16 width, CARD16 height)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+
+ KdScreenPriv(pScreen);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!pScreenPriv->enabled)
+ return Success;
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionInit(&ClipRegion, NullBox, 1);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = pScreen->width;
+ VPBox.y2 = pScreen->height;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ if (portPriv->pDraw) {
+ KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
+ }
+
+ if (!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+
+ if ((RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+ }
+
+ if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutImage) (portPriv->screen, pDraw,
+ src_x, src_y, WinBox.x1, WinBox.y1,
+ src_w, src_h, drw_w, drw_h,
+ format->id, data, width, height,
+ sync, &ClipRegion,
+ portPriv->DevPriv.ptr);
+
+ if ((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
+
+ KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->pDraw = pDraw;
+ portPriv->drw_x = drw_x;
+ portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w;
+ portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+ PUT_IMAGE_BAILOUT:
+
+ if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
+ portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVQueryImageAttributes(ClientPtr client,
+ XvPortPtr pPort,
+ XvImagePtr format,
+ CARD16 *width,
+ CARD16 *height, int *pitches, int *offsets)
+{
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+ return (*portPriv->AdaptorRec->QueryImageAttributes) (portPriv->screen,
+ format->id, width,
+ height, pitches,
+ offsets);
+}
+
+/**************** Common video manipulation functions *******************/
+
+void
+KdXVCopyPackedData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int dstPitch, int srcW, int srcH, int top,
+ int left, int h, int w)
+{
+ int srcDown = srcPitch, srcRight = 2, srcNext;
+ int p;
+
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ srcDown = srcPitch;
+ srcRight = 2;
+ break;
+ case RR_Rotate_90:
+ src += (srcH - 1) * 2;
+ srcDown = -2;
+ srcRight = srcPitch;
+ break;
+ case RR_Rotate_180:
+ src += srcPitch * (srcH - 1) + (srcW - 1) * 2;
+ srcDown = -srcPitch;
+ srcRight = -2;
+ break;
+ case RR_Rotate_270:
+ src += srcPitch * (srcW - 1);
+ srcDown = 2;
+ srcRight = -srcPitch;
+ break;
+ }
+
+ src = src + top * srcDown + left * srcRight;
+
+ w >>= 1;
+ /* srcRight >>= 1; */
+ srcNext = srcRight >> 1;
+ while (h--) {
+ CARD16 *s = (CARD16 *) src;
+ CARD32 *d = (CARD32 *) dst;
+
+ p = w;
+ while (p--) {
+ *d++ = s[0] | (s[srcNext] << 16);
+ s += srcRight;
+ }
+ src += srcPitch;
+ dst += dstPitch;
+ }
+}
+
+void
+KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int srcPitch2, int dstPitch, int srcW,
+ int srcH, int height, int top, int left, int h, int w,
+ int id)
+{
+ int i, j;
+ CARD8 *src1, *src2, *src3, *dst1;
+ int srcDown = srcPitch, srcDown2 = srcPitch2;
+ int srcRight = 2, srcRight2 = 1, srcNext = 1;
+
+ /* compute source data pointers */
+ src1 = src;
+ src2 = src1 + height * srcPitch;
+ src3 = src2 + (height >> 1) * srcPitch2;
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ srcDown = srcPitch;
+ srcDown2 = srcPitch2;
+ srcRight = 2;
+ srcRight2 = 1;
+ srcNext = 1;
+ break;
+ case RR_Rotate_90:
+ src1 = src1 + srcH - 1;
+ src2 = src2 + (srcH >> 1) - 1;
+ src3 = src3 + (srcH >> 1) - 1;
+ srcDown = -1;
+ srcDown2 = -1;
+ srcRight = srcPitch * 2;
+ srcRight2 = srcPitch2;
+ srcNext = srcPitch;
+ break;
+ case RR_Rotate_180:
+ src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
+ src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
+ src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
+ srcDown = -srcPitch;
+ srcDown2 = -srcPitch2;
+ srcRight = -2;
+ srcRight2 = -1;
+ srcNext = -1;
+ break;
+ case RR_Rotate_270:
+ src1 = src1 + srcPitch * (srcW - 1);
+ src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
+ src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
+ srcDown = 1;
+ srcDown2 = 1;
+ srcRight = -srcPitch * 2;
+ srcRight2 = -srcPitch2;
+ srcNext = -srcPitch;
+ break;
+ }
+
+ /* adjust for origin */
+ src1 += top * srcDown + left * srcNext;
+ src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
+ src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
+
+ if (id == FOURCC_I420) {
+ CARD8 *srct = src2;
+
+ src2 = src3;
+ src3 = srct;
+ }
+
+ dst1 = dst;
+
+ w >>= 1;
+ for (j = 0; j < h; j++) {
+ CARD32 *dst = (CARD32 *) dst1;
+ CARD8 *s1l = src1;
+ CARD8 *s1r = src1 + srcNext;
+ CARD8 *s2 = src2;
+ CARD8 *s3 = src3;
+
+ for (i = 0; i < w; i++) {
+ *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
+ s1l += srcRight;
+ s1r += srcRight;
+ s2 += srcRight2;
+ s3 += srcRight2;
+ }
+ src1 += srcDown;
+ dst1 += dstPitch;
+ if (j & 1) {
+ src2 += srcDown2;
+ src3 += srcDown2;
+ }
+ }
+}
+
+void
+KXVPaintRegion(DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
+{
+ GCPtr pGC;
+ ChangeGCVal val[2];
+ xRectangle *rects, *r;
+ BoxPtr pBox = RegionRects(pRgn);
+ int nBox = RegionNumRects(pRgn);
+
+ rects = malloc(nBox * sizeof(xRectangle));
+ if (!rects)
+ goto bail0;
+ r = rects;
+ while (nBox--) {
+ r->x = pBox->x1 - pDraw->x;
+ r->y = pBox->y1 - pDraw->y;
+ r->width = pBox->x2 - pBox->x1;
+ r->height = pBox->y2 - pBox->y1;
+ r++;
+ pBox++;
+ }
+
+ pGC = GetScratchGC(pDraw->depth, pDraw->pScreen);
+ if (!pGC)
+ goto bail1;
+
+ val[0].val = fg;
+ val[1].val = IncludeInferiors;
+ ChangeGC(NullClient, pGC, GCForeground | GCSubwindowMode, val);
+
+ ValidateGC(pDraw, pGC);
+
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, RegionNumRects(pRgn), rects);
+
+ FreeScratchGC(pGC);
+ bail1:
+ free(rects);
+ bail0:
+ ;
+}
diff --git a/xorg-server/hw/kdrive/src/kxv.h b/xorg-server/hw/kdrive/src/kxv.h
index 21a295be3..29118bc96 100644
--- a/xorg-server/hw/kdrive/src/kxv.h
+++ b/xorg-server/hw/kdrive/src/kxv.h
@@ -57,80 +57,86 @@ of the copyright holder.
#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
typedef struct {
- int id;
- int type;
- int byte_order;
- unsigned char guid[16];
- int bits_per_pixel;
- int format;
- int num_planes;
-
- /* for RGB formats only */
- int depth;
- unsigned int red_mask;
- unsigned int green_mask;
- unsigned int blue_mask;
-
- /* for YUV formats only */
- unsigned int y_sample_bits;
- unsigned int u_sample_bits;
- unsigned int v_sample_bits;
- unsigned int horz_y_period;
- unsigned int horz_u_period;
- unsigned int horz_v_period;
- unsigned int vert_y_period;
- unsigned int vert_u_period;
- unsigned int vert_v_period;
- char component_order[32];
- int scanline_order;
+ int id;
+ int type;
+ int byte_order;
+ unsigned char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats only */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats only */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
} KdImageRec, *KdImagePtr;
-
typedef struct {
- KdScreenInfo * screen;
- int id;
- unsigned short width, height;
- int *pitches; /* bytes */
- int *offsets; /* in bytes from start of framebuffer */
- DevUnion devPrivate;
+ KdScreenInfo *screen;
+ int id;
+ unsigned short width, height;
+ int *pitches; /* bytes */
+ int *offsets; /* in bytes from start of framebuffer */
+ DevUnion devPrivate;
} KdSurfaceRec, *KdSurfacePtr;
-
-typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
-typedef int (* PutStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
-typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
-typedef int (* GetStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
- short vid_x, short vid_y, short drw_x, short drw_y,
- short vid_w, short vid_h, short drw_w, short drw_h,
- RegionPtr clipBoxes, pointer data );
-typedef void (* StopVideoFuncPtr)(KdScreenInfo * screen, pointer data, Bool Exit);
-typedef int (* SetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
- int value, pointer data);
-typedef int (* GetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
- int *value, pointer data);
-typedef void (* QueryBestSizeFuncPtr)(KdScreenInfo * screen, Bool motion,
- short vid_w, short vid_h, short drw_w, short drw_h,
- unsigned int *p_w, unsigned int *p_h, pointer data);
-typedef int (* PutImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
- short src_x, short src_y, short drw_x, short drw_y,
- short src_w, short src_h, short drw_w, short drw_h,
- int image, unsigned char* buf, short width, short height, Bool Sync,
- RegionPtr clipBoxes, pointer data );
-typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
- short drw_x, short drw_y,
- RegionPtr clipBoxes, pointer data );
-typedef int (*QueryImageAttributesFuncPtr)(KdScreenInfo * screen,
- int image, unsigned short *width, unsigned short *height,
- int *pitches, int *offsets);
+typedef int (*PutVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
+ short vid_x, short vid_y, short drw_x,
+ short drw_y, short vid_w, short vid_h,
+ short drw_w, short drw_h, RegionPtr clipBoxes,
+ pointer data);
+typedef int (*PutStillFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
+ short vid_x, short vid_y, short drw_x,
+ short drw_y, short vid_w, short vid_h,
+ short drw_w, short drw_h, RegionPtr clipBoxes,
+ pointer data);
+typedef int (*GetVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
+ short vid_x, short vid_y, short drw_x,
+ short drw_y, short vid_w, short vid_h,
+ short drw_w, short drw_h, RegionPtr clipBoxes,
+ pointer data);
+typedef int (*GetStillFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
+ short vid_x, short vid_y, short drw_x,
+ short drw_y, short vid_w, short vid_h,
+ short drw_w, short drw_h, RegionPtr clipBoxes,
+ pointer data);
+typedef void (*StopVideoFuncPtr) (KdScreenInfo * screen, pointer data,
+ Bool Exit);
+typedef int (*SetPortAttributeFuncPtr) (KdScreenInfo * screen, Atom attribute,
+ int value, pointer data);
+typedef int (*GetPortAttributeFuncPtr) (KdScreenInfo * screen, Atom attribute,
+ int *value, pointer data);
+typedef void (*QueryBestSizeFuncPtr) (KdScreenInfo * screen, Bool motion,
+ short vid_w, short vid_h, short drw_w,
+ short drw_h, unsigned int *p_w,
+ unsigned int *p_h, pointer data);
+typedef int (*PutImageFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
+ short src_x, short src_y, short drw_x,
+ short drw_y, short src_w, short src_h,
+ short drw_w, short drw_h, int image,
+ unsigned char *buf, short width, short height,
+ Bool Sync, RegionPtr clipBoxes, pointer data);
+typedef int (*ReputImageFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
+ short drw_x, short drw_y, RegionPtr clipBoxes,
+ pointer data);
+typedef int (*QueryImageAttributesFuncPtr) (KdScreenInfo * screen, int image,
+ unsigned short *width,
+ unsigned short *height,
+ int *pitches, int *offsets);
typedef enum {
XV_OFF,
@@ -141,84 +147,78 @@ typedef enum {
/*** this is what the driver needs to fill out ***/
typedef struct {
- int id;
- char *name;
- unsigned short width, height;
- XvRationalRec rate;
+ int id;
+ char *name;
+ unsigned short width, height;
+ XvRationalRec rate;
} KdVideoEncodingRec, *KdVideoEncodingPtr;
typedef struct {
- char depth;
- short class;
+ char depth;
+ short class;
} KdVideoFormatRec, *KdVideoFormatPtr;
typedef struct {
- int flags;
- int min_value;
- int max_value;
- char *name;
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
} KdAttributeRec, *KdAttributePtr;
typedef struct {
- unsigned int type;
- int flags;
- char *name;
- int nEncodings;
- KdVideoEncodingPtr pEncodings;
- int nFormats;
- KdVideoFormatPtr pFormats;
- int nPorts;
- DevUnion *pPortPrivates;
- int nAttributes;
- KdAttributePtr pAttributes;
- int nImages;
- KdImagePtr pImages;
- PutVideoFuncPtr PutVideo;
- PutStillFuncPtr PutStill;
- GetVideoFuncPtr GetVideo;
- GetStillFuncPtr GetStill;
- StopVideoFuncPtr StopVideo;
- SetPortAttributeFuncPtr SetPortAttribute;
- GetPortAttributeFuncPtr GetPortAttribute;
- QueryBestSizeFuncPtr QueryBestSize;
- PutImageFuncPtr PutImage;
- ReputImageFuncPtr ReputImage;
- QueryImageAttributesFuncPtr QueryImageAttributes;
+ unsigned int type;
+ int flags;
+ char *name;
+ int nEncodings;
+ KdVideoEncodingPtr pEncodings;
+ int nFormats;
+ KdVideoFormatPtr pFormats;
+ int nPorts;
+ DevUnion *pPortPrivates;
+ int nAttributes;
+ KdAttributePtr pAttributes;
+ int nImages;
+ KdImagePtr pImages;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
} KdVideoAdaptorRec, *KdVideoAdaptorPtr;
Bool
-KdXVScreenInit(
- ScreenPtr pScreen,
- KdVideoAdaptorPtr *Adaptors,
- int num
-);
+ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr * Adaptors, int num);
-typedef int (* KdXVInitGenericAdaptorPtr)(KdScreenInfo * screen,
- KdVideoAdaptorPtr **Adaptors);
+typedef int (*KdXVInitGenericAdaptorPtr) (KdScreenInfo * screen,
+ KdVideoAdaptorPtr ** Adaptors);
int
-KdXVRegisterGenericAdaptorDriver(
- KdXVInitGenericAdaptorPtr InitFunc
-);
+ KdXVRegisterGenericAdaptorDriver(KdXVInitGenericAdaptorPtr InitFunc);
int
-KdXVListGenericAdaptors(
- KdScreenInfo * screen,
- KdVideoAdaptorPtr **Adaptors
-);
+ KdXVListGenericAdaptors(KdScreenInfo * screen, KdVideoAdaptorPtr ** Adaptors);
void
-KdXVCopyPackedData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
- int srcPitch, int dstPitch, int srcW, int srcH, int top, int left,
- int h, int w);
+
+KdXVCopyPackedData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int dstPitch, int srcW, int srcH, int top,
+ int left, int h, int w);
void
-KdXVCopyPlanarData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
- int srcPitch, int srcPitch2, int dstPitch, int srcW, int srcH, int height,
- int top, int left, int h, int w, int id);
+
+KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int srcPitch2, int dstPitch, int srcW,
+ int srcH, int height, int top, int left, int h, int w,
+ int id);
void
-KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg);
+ KXVPaintRegion(DrawablePtr pDraw, RegionPtr pRgn, Pixel fg);
KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen);
@@ -230,50 +230,48 @@ void KdXVDisable(ScreenPtr);
/*** These are DDX layer privates ***/
-
typedef struct {
- CreateWindowProcPtr CreateWindow;
- DestroyWindowProcPtr DestroyWindow;
- ClipNotifyProcPtr ClipNotify;
- WindowExposuresProcPtr WindowExposures;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ ClipNotifyProcPtr ClipNotify;
+ WindowExposuresProcPtr WindowExposures;
} KdXVScreenRec, *KdXVScreenPtr;
typedef struct {
- int flags;
- PutVideoFuncPtr PutVideo;
- PutStillFuncPtr PutStill;
- GetVideoFuncPtr GetVideo;
- GetStillFuncPtr GetStill;
- StopVideoFuncPtr StopVideo;
- SetPortAttributeFuncPtr SetPortAttribute;
- GetPortAttributeFuncPtr GetPortAttribute;
- QueryBestSizeFuncPtr QueryBestSize;
- PutImageFuncPtr PutImage;
- ReputImageFuncPtr ReputImage;
- QueryImageAttributesFuncPtr QueryImageAttributes;
+ int flags;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
typedef struct {
- KdScreenInfo * screen;
- DrawablePtr pDraw;
- unsigned char type;
- unsigned int subWindowMode;
- DDXPointRec clipOrg;
- RegionPtr clientClip;
- RegionPtr pCompositeClip;
- Bool FreeCompositeClip;
- XvAdaptorRecPrivatePtr AdaptorRec;
- XvStatus isOn;
- Bool moved;
- int vid_x, vid_y, vid_w, vid_h;
- int drw_x, drw_y, drw_w, drw_h;
- DevUnion DevPriv;
+ KdScreenInfo *screen;
+ DrawablePtr pDraw;
+ unsigned char type;
+ unsigned int subWindowMode;
+ DDXPointRec clipOrg;
+ RegionPtr clientClip;
+ RegionPtr pCompositeClip;
+ Bool FreeCompositeClip;
+ XvAdaptorRecPrivatePtr AdaptorRec;
+ XvStatus isOn;
+ Bool moved;
+ int vid_x, vid_y, vid_w, vid_h;
+ int drw_x, drw_y, drw_w, drw_h;
+ DevUnion DevPriv;
} XvPortRecPrivate, *XvPortRecPrivatePtr;
-typedef struct _KdXVWindowRec{
- XvPortRecPrivatePtr PortRec;
- struct _KdXVWindowRec *next;
+typedef struct _KdXVWindowRec {
+ XvPortRecPrivatePtr PortRec;
+ struct _KdXVWindowRec *next;
} KdXVWindowRec, *KdXVWindowPtr;
-#endif /* _XVDIX_H_ */
-
+#endif /* _XVDIX_H_ */