📄 xf86dga.c
字号:
/* $XFree86: xc/lib/Xxf86dga/XF86DGA.c,v 3.19 2001/08/18 02:41:30 dawes Exp $ *//*Copyright (c) 1995 Jon TombsCopyright (c) 1995,1996 The XFree86 Project, Inc*//* THIS IS NOT AN X CONSORTIUM STANDARD */#ifdef __EMX__ /* needed here to override certain constants in X headers */#define INCL_DOS#define INCL_DOSIOCTL#include <os2.h>#endif#if defined(linux)#define HAS_MMAP_ANON#include <sys/types.h>#include <sys/mman.h>#include <asm/page.h> /* PAGE_SIZE */#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */#define HAS_GETPAGESIZE#endif /* linux */#if defined(CSRG_BASED)#define HAS_MMAP_ANON#define HAS_GETPAGESIZE#include <sys/types.h>#include <sys/mman.h>#endif /* CSRG_BASED */#if defined(DGUX)#define HAS_GETPAGESIZE#define MMAP_DEV_ZERO#include <sys/types.h>#include <sys/mman.h>#include <unistd.h>#endif /* DGUX */#if defined(SVR4) && !defined(DGUX)#define MMAP_DEV_ZERO#include <sys/types.h>#include <sys/mman.h>#include <unistd.h>#endif /* SVR4 && !DGUX */#if defined(sun) && !defined(SVR4) /* SunOS */#define MMAP_DEV_ZERO /* doesn't SunOS have MAP_ANON ?? */#define HAS_GETPAGESIZE#include <sys/types.h>#include <sys/mman.h>#endif /* sun && !SVR4 */#ifdef XNO_SYSCONF#undef _SC_PAGESIZE#endif#define NEED_EVENTS#define NEED_REPLIES#include <X11/Xlibint.h>#include "xf86dga.h"#include "xf86dgastr.h"#include <X11/extensions/Xext.h>#include "extutil.h"extern XExtDisplayInfo* SDL_NAME(xdga_find_display)(Display*);extern char *SDL_NAME(xdga_extension_name);#define XF86DGACheckExtension(dpy,i,val) \ XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val)/***************************************************************************** * * * public XFree86-DGA Extension routines * * * *****************************************************************************/Bool SDL_NAME(XF86DGAQueryExtension) ( Display *dpy, int *event_basep, int *error_basep){ return SDL_NAME(XDGAQueryExtension)(dpy, event_basep, error_basep);}Bool SDL_NAME(XF86DGAQueryVersion)( Display* dpy, int* majorVersion, int* minorVersion){ return SDL_NAME(XDGAQueryVersion)(dpy, majorVersion, minorVersion);}Bool SDL_NAME(XF86DGAGetVideoLL)( Display* dpy, int screen, int *offset, int *width, int *bank_size, int *ram_size){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetVideoLLReply rep; xXF86DGAGetVideoLLReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAGetVideoLL, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetVideoLL; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *offset = /*(char *)*/rep.offset; *width = rep.width; *bank_size = rep.bank_size; *ram_size = rep.ram_size; UnlockDisplay(dpy); SyncHandle(); return True;} Bool SDL_NAME(XF86DGADirectVideoLL)( Display* dpy, int screen, int enable){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGADirectVideoReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGADirectVideo, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGADirectVideo; req->screen = screen; req->enable = enable; UnlockDisplay(dpy); SyncHandle(); XSync(dpy,False); return True;}Bool SDL_NAME(XF86DGAGetViewPortSize)( Display* dpy, int screen, int *width, int *height){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetViewPortSizeReply rep; xXF86DGAGetViewPortSizeReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAGetViewPortSize, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetViewPortSize; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *width = rep.width; *height = rep.height; UnlockDisplay(dpy); SyncHandle(); return True;} Bool SDL_NAME(XF86DGASetViewPort)( Display* dpy, int screen, int x, int y){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGASetViewPortReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGASetViewPort, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGASetViewPort; req->screen = screen; req->x = x; req->y = y; UnlockDisplay(dpy); SyncHandle(); XSync(dpy,False); return True;} Bool SDL_NAME(XF86DGAGetVidPage)( Display* dpy, int screen, int *vpage){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetVidPageReply rep; xXF86DGAGetVidPageReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAGetVidPage, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetVidPage; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *vpage = rep.vpage; UnlockDisplay(dpy); SyncHandle(); return True;} Bool SDL_NAME(XF86DGASetVidPage)( Display* dpy, int screen, int vpage){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGASetVidPageReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGASetVidPage, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGASetVidPage; req->screen = screen; req->vpage = vpage; UnlockDisplay(dpy); SyncHandle(); XSync(dpy,False); return True;}Bool SDL_NAME(XF86DGAInstallColormap)( Display* dpy, int screen, Colormap cmap){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAInstallColormapReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAInstallColormap, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAInstallColormap; req->screen = screen; req->id = cmap; UnlockDisplay(dpy); SyncHandle(); XSync(dpy,False); return True;}Bool SDL_NAME(XF86DGAQueryDirectVideo)( Display *dpy, int screen, int *flags){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAQueryDirectVideoReply rep; xXF86DGAQueryDirectVideoReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAQueryDirectVideo, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAQueryDirectVideo; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *flags = rep.flags; UnlockDisplay(dpy); SyncHandle(); return True;}Bool SDL_NAME(XF86DGAViewPortChanged)( Display *dpy, int screen, int n){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAViewPortChangedReply rep; xXF86DGAViewPortChangedReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAViewPortChanged, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAViewPortChanged; req->screen = screen; req->n = n; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } UnlockDisplay(dpy); SyncHandle(); return rep.result;}/* Helper functions */#include <X11/Xmd.h>#include <XFree86/extensions/xf86dga.h>#include <stdlib.h>#include <stdio.h>#include <fcntl.h>#if defined(ISC) # define HAS_SVR3_MMAP# include <sys/types.h># include <errno.h># include <sys/at_ansi.h># include <sys/kd.h># include <sys/sysmacros.h># include <sys/immu.h># include <sys/region.h># include <sys/mmap.h>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -