compat-api.h revision 42542f5f
103b705cfSriastradh/* 203b705cfSriastradh * Copyright 2012 Red Hat, Inc. 303b705cfSriastradh * 403b705cfSriastradh * Permission is hereby granted, free of charge, to any person obtaining a 503b705cfSriastradh * copy of this software and associated documentation files (the "Software"), 603b705cfSriastradh * to deal in the Software without restriction, including without limitation 703b705cfSriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 803b705cfSriastradh * and/or sell copies of the Software, and to permit persons to whom the 903b705cfSriastradh * Software is furnished to do so, subject to the following conditions: 1003b705cfSriastradh * 1103b705cfSriastradh * The above copyright notice and this permission notice (including the next 1203b705cfSriastradh * paragraph) shall be included in all copies or substantial portions of the 1303b705cfSriastradh * Software. 1403b705cfSriastradh * 1503b705cfSriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1603b705cfSriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1703b705cfSriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1803b705cfSriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1903b705cfSriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2003b705cfSriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2103b705cfSriastradh * DEALINGS IN THE SOFTWARE. 2203b705cfSriastradh * 2303b705cfSriastradh * Author: Dave Airlie <airlied@redhat.com> 2403b705cfSriastradh */ 2503b705cfSriastradh 2603b705cfSriastradh/* this file provides API compat between server post 1.13 and pre it, 2703b705cfSriastradh it should be reused inside as many drivers as possible */ 2803b705cfSriastradh#ifndef COMPAT_API_H 2903b705cfSriastradh#define COMPAT_API_H 3003b705cfSriastradh 3103b705cfSriastradh#include <xorg-server.h> 3203b705cfSriastradh#include <xorgVersion.h> 3303b705cfSriastradh 3403b705cfSriastradh#include <picturestr.h> 3503b705cfSriastradh#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR 3603b705cfSriastradh#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum] 3703b705cfSriastradh#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p 3803b705cfSriastradh#endif 3903b705cfSriastradh 4003b705cfSriastradh#ifndef XF86_HAS_SCRN_CONV 4103b705cfSriastradh#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum] 4203b705cfSriastradh#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex] 4303b705cfSriastradh#endif 4403b705cfSriastradh 4503b705cfSriastradh#ifndef XF86_SCRN_INTERFACE 4603b705cfSriastradh 4703b705cfSriastradh#define SCRN_ARG_TYPE int 4803b705cfSriastradh#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = xf86Screens[(arg1)] 4903b705cfSriastradh 5003b705cfSriastradh#define SCREEN_ARG_TYPE int 5103b705cfSriastradh#define SCREEN_PTR(arg1) ScreenPtr screen = screenInfo.screens[(arg1)] 5203b705cfSriastradh 5303b705cfSriastradh#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr screen, int argc, char **argv 5403b705cfSriastradh 5503b705cfSriastradh#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer timeout, pointer read_mask 5603b705cfSriastradh#define BLOCKHANDLER_ARGS arg, blockData, timeout, read_mask 5703b705cfSriastradh 5803b705cfSriastradh#define WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long result, pointer read_mask 5903b705cfSriastradh#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask 6003b705cfSriastradh 6103b705cfSriastradh#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr screen 6203b705cfSriastradh#define CLOSE_SCREEN_ARGS scrnIndex, screen 6303b705cfSriastradh 6403b705cfSriastradh#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags 6503b705cfSriastradh#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0 6603b705cfSriastradh 6703b705cfSriastradh#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags 6803b705cfSriastradh#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0 6903b705cfSriastradh 7003b705cfSriastradh#define FREE_SCREEN_ARGS_DECL int arg, int flags 7103b705cfSriastradh 7203b705cfSriastradh#define VT_FUNC_ARGS_DECL int arg, int flags 7303b705cfSriastradh#define VT_FUNC_ARGS(flags) scrn->scrnIndex, (flags) 7403b705cfSriastradh 7503b705cfSriastradh#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex) 7603b705cfSriastradh 7703b705cfSriastradh#else 7803b705cfSriastradh#define SCRN_ARG_TYPE ScrnInfoPtr 7903b705cfSriastradh#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = (arg1) 8003b705cfSriastradh 8103b705cfSriastradh#define SCREEN_ARG_TYPE ScreenPtr 8203b705cfSriastradh#define SCREEN_PTR(arg1) ScreenPtr screen = (arg1) 8303b705cfSriastradh 8403b705cfSriastradh#define SCREEN_INIT_ARGS_DECL ScreenPtr screen, int argc, char **argv 8503b705cfSriastradh 8603b705cfSriastradh#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer timeout, pointer read_mask 8703b705cfSriastradh#define BLOCKHANDLER_ARGS arg, timeout, read_mask 8803b705cfSriastradh 8903b705cfSriastradh#define WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer read_mask 9003b705cfSriastradh#define WAKEUPHANDLER_ARGS arg, result, read_mask 9103b705cfSriastradh 9203b705cfSriastradh#define CLOSE_SCREEN_ARGS_DECL ScreenPtr screen 9303b705cfSriastradh#define CLOSE_SCREEN_ARGS screen 9403b705cfSriastradh 9503b705cfSriastradh#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y 9603b705cfSriastradh#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y 9703b705cfSriastradh 9803b705cfSriastradh#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode 9903b705cfSriastradh#define SWITCH_MODE_ARGS(arg, m) arg, m 10003b705cfSriastradh 10103b705cfSriastradh#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg 10203b705cfSriastradh 10303b705cfSriastradh#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg 10403b705cfSriastradh#define VT_FUNC_ARGS(flags) scrn 10503b705cfSriastradh 10603b705cfSriastradh#define XF86_ENABLEDISABLEFB_ARG(x) (x) 10703b705cfSriastradh 10803b705cfSriastradh#endif 10903b705cfSriastradh 11042542f5fSchristosstatic inline int 11142542f5fSchristosregion_num_rects(const RegionRec *r) 11242542f5fSchristos{ 11342542f5fSchristos return r->data ? r->data->numRects : 1; 11442542f5fSchristos} 11542542f5fSchristos 11642542f5fSchristosstatic inline int 11742542f5fSchristosregion_nil(const RegionRec *r) 11842542f5fSchristos{ 11942542f5fSchristos return region_num_rects(r) == 0; 12042542f5fSchristos} 12142542f5fSchristos 12242542f5fSchristosstatic inline BoxPtr 12342542f5fSchristosregion_boxptr(const RegionRec *r) 12442542f5fSchristos{ 12542542f5fSchristos return (BoxPtr)(r->data + 1); 12642542f5fSchristos} 12742542f5fSchristos 12842542f5fSchristosstatic inline const BoxRec * 12942542f5fSchristosregion_rects(const RegionRec *r) 13042542f5fSchristos{ 13142542f5fSchristos return r->data ? (const BoxRec *)(r->data + 1) : &r->extents; 13242542f5fSchristos} 13342542f5fSchristos 13403b705cfSriastradh#ifndef INCLUDE_LEGACY_REGION_DEFINES 13503b705cfSriastradh#define RegionCreate(r, s) REGION_CREATE(NULL, r, s) 13603b705cfSriastradh#define RegionBreak(r) REGION_BREAK(NULL, r) 13703b705cfSriastradh#define RegionSizeof REGION_SZOF 13803b705cfSriastradh#define RegionBoxptr REGION_BOXPTR 13903b705cfSriastradh#define RegionEnd REGION_END 14003b705cfSriastradh#define RegionExtents(r) REGION_EXTENTS(NULL, r) 14103b705cfSriastradh#define RegionRects REGION_RECTS 14203b705cfSriastradh#define RegionNumRects REGION_NUM_RECTS 14303b705cfSriastradh#define RegionContainsRect(r, b) RECT_IN_REGION(NULL, r, b) 14403b705cfSriastradh#define RegionContainsPoint(r, x, y, b) POINT_IN_REGION(NULL, r, x, y, b) 14503b705cfSriastradh#define RegionCopy(res, r) REGION_COPY(NULL, res, r) 14603b705cfSriastradh#define RegionIntersect(res, r1, r2) REGION_INTERSECT(NULL, res, r1, r2) 14703b705cfSriastradh#define RegionUnion(res, r1, r2) REGION_UNION(NULL, res, r1, r2) 14842542f5fSchristos#define RegionSubtract(res, r1, r2) REGION_SUBTRACT(NULL, res, r1, r2) 14903b705cfSriastradh#define RegionTranslate(r, x, y) REGION_TRANSLATE(NULL, r, x, y) 15003b705cfSriastradh#define RegionUninit(r) REGION_UNINIT(NULL, r) 15103b705cfSriastradh#define region_from_bitmap BITMAP_TO_REGION 15203b705cfSriastradh#define RegionNil REGION_NIL 15303b705cfSriastradh#define RegionNull(r) REGION_NULL(NULL, r) 15403b705cfSriastradh#define RegionNotEmpty(r) REGION_NOTEMPTY(NULL, r) 15503b705cfSriastradh#define RegionEmpty(r) REGION_EMPTY(NULL, r) 15603b705cfSriastradh#define RegionEqual(a, b) REGION_EQUAL(NULL, a, b) 15703b705cfSriastradh#define RegionDestroy(r) REGION_DESTROY(NULL, r) 15803b705cfSriastradh#else 15903b705cfSriastradh#define region_from_bitmap BitmapToRegion 16003b705cfSriastradh#endif 16103b705cfSriastradh 16203b705cfSriastradh#ifndef _X_UNUSED 16303b705cfSriastradh#define _X_UNUSED 16403b705cfSriastradh#endif 16503b705cfSriastradh 16603b705cfSriastradh#if HAS_DEVPRIVATEKEYREC 16703b705cfSriastradh#define __get_private(p, key) dixGetPrivateAddr(&(p)->devPrivates, &(key)) 16803b705cfSriastradh#else 16903b705cfSriastradh#define __get_private(p, key) dixLookupPrivate(&(p)->devPrivates, &(key)) 17003b705cfSriastradhtypedef int DevPrivateKeyRec; 17103b705cfSriastradhstatic inline void FreePixmap(PixmapPtr pixmap) 17203b705cfSriastradh{ 17303b705cfSriastradh dixFreePrivates(pixmap->devPrivates); 17403b705cfSriastradh free(pixmap); 17503b705cfSriastradh} 17603b705cfSriastradh#endif 17703b705cfSriastradh 17842542f5fSchristos#if !HAS_DIXREGISTERPRIVATEKEY 17942542f5fSchristos#define dixPrivateKeyRegistered(key__) (*(key__) != 0) 18042542f5fSchristos#endif 18142542f5fSchristos 18203b705cfSriastradh#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,9,99,902,0) 18303b705cfSriastradh#define SourceValidate(d, x, y, w, h, mode) \ 18403b705cfSriastradh if ((d)->pScreen->SourceValidate) (d)->pScreen->SourceValidate(d, x, y, w, h, mode) 18503b705cfSriastradh#else 18603b705cfSriastradh#define SourceValidate(d, x, y, w, h, mode) \ 18703b705cfSriastradh if ((d)->pScreen->SourceValidate) (d)->pScreen->SourceValidate(d, x, y, w, h) 18803b705cfSriastradh#endif 18903b705cfSriastradh 19042542f5fSchristos#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0) 19142542f5fSchristos#define DamageUnregister(d, dd) DamageUnregister(dd) 19242542f5fSchristos#endif 19342542f5fSchristos 19442542f5fSchristos#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,16,99,1,0) 19542542f5fSchristos 19642542f5fSchristos#define XORG_XV_VERSION 2 19742542f5fSchristos#define ddStopVideo_ARGS XvPortPtr port, DrawablePtr draw 19842542f5fSchristos#define ddSetPortAttribute_ARGS XvPortPtr port, Atom attribute, INT32 value 19942542f5fSchristos#define ddGetPortAttribute_ARGS XvPortPtr port, Atom attribute, INT32 *value 20042542f5fSchristos#define ddQueryBestSize_ARGS XvPortPtr port, CARD8 motion, CARD16 vid_w, CARD16 vid_h, CARD16 drw_w, CARD16 drw_h, unsigned int *p_w, unsigned int *p_h 20142542f5fSchristos#define ddPutImage_ARGS DrawablePtr draw, XvPortPtr port, GCPtr gc, 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 *buf, Bool sync, CARD16 width, CARD16 height 20242542f5fSchristos#define ddQueryImageAttributes_ARGS XvPortPtr port, XvImagePtr format, unsigned short *w, unsigned short *h, int *pitches, int *offsets 20342542f5fSchristos 20442542f5fSchristos#else 20542542f5fSchristos 20642542f5fSchristos#define XORG_XV_VERSION 1 20742542f5fSchristos#define ddStopVideo_ARGS ClientPtr client, XvPortPtr port, DrawablePtr draw 20842542f5fSchristos#define ddSetPortAttribute_ARGS ClientPtr client, XvPortPtr port, Atom attribute, INT32 value 20942542f5fSchristos#define ddGetPortAttribute_ARGS ClientPtr client, XvPortPtr port, Atom attribute, INT32 *value 21042542f5fSchristos#define ddQueryBestSize_ARGS ClientPtr client, XvPortPtr port, CARD8 motion, CARD16 vid_w, CARD16 vid_h, CARD16 drw_w, CARD16 drw_h, unsigned int *p_w, unsigned int *p_h 21142542f5fSchristos#define ddPutImage_ARGS ClientPtr client, DrawablePtr draw, XvPortPtr port, GCPtr gc, 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 *buf, Bool sync, CARD16 width, CARD16 height 21242542f5fSchristos#define ddQueryImageAttributes_ARGS ClientPtr client, XvPortPtr port, XvImagePtr format, unsigned short *w, unsigned short *h, int *pitches, int *offsets 21342542f5fSchristos 21442542f5fSchristos#endif 21542542f5fSchristos 21603b705cfSriastradh#endif 217