Home | History | Annotate | Download | only in xorg
      1 /*  DO NOT EDIT THIS FILE.
      2 
      3     It has been auto-edited by fixincludes from:
      4 
      5 	"/usr/include/xorg/xf86str.h"
      6 
      7     This had to be done to correct non-standard usages in the
      8     original, manufacturer supplied header file.  */
      9 
     10 /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.97 2003/10/30 17:36:56 tsi Exp $ */
     11 
     12 /*
     13  * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
     14  *
     15  * Permission is hereby granted, free of charge, to any person obtaining a
     16  * copy of this software and associated documentation files (the "Software"),
     17  * to deal in the Software without restriction, including without limitation
     18  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     19  * and/or sell copies of the Software, and to permit persons to whom the
     20  * Software is furnished to do so, subject to the following conditions:
     21  *
     22  * The above copyright notice and this permission notice shall be included in
     23  * all copies or substantial portions of the Software.
     24  *
     25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     26  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     27  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     28  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     29  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     30  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     31  * OTHER DEALINGS IN THE SOFTWARE.
     32  *
     33  * Except as contained in this notice, the name of the copyright holder(s)
     34  * and author(s) shall not be used in advertising or otherwise to promote
     35  * the sale, use or other dealings in this Software without prior written
     36  * authorization from the copyright holder(s) and author(s).
     37  */
     38 
     39 /*
     40  * This file contains definitions of the public XFree86 data structures/types.
     41  * Any data structures that video drivers need to access should go here.
     42  */
     43 
     44 #ifndef _XF86STR_H
     45 #define _XF86STR_H
     46 
     47 #include "misc.h"
     48 #include "input.h"
     49 #include "scrnintstr.h"
     50 #include "pixmapstr.h"
     51 #include "colormapst.h"
     52 #include "xf86Module.h"
     53 #include "xf86Opt.h"
     54 #include "xf86Pci.h"
     55 
     56 /*
     57  * memType is of the size of the addressable memory (machine size)
     58  * usually unsigned long.
     59  */
     60 typedef unsigned long memType;
     61 
     62 /* Video mode flags */
     63 
     64 typedef enum {
     65     V_PHSYNC	= 0x0001,
     66     V_NHSYNC	= 0x0002,
     67     V_PVSYNC	= 0x0004,
     68     V_NVSYNC	= 0x0008,
     69     V_INTERLACE	= 0x0010,
     70     V_DBLSCAN	= 0x0020,
     71     V_CSYNC	= 0x0040,
     72     V_PCSYNC	= 0x0080,
     73     V_NCSYNC	= 0x0100,
     74     V_HSKEW	= 0x0200,	/* hskew provided */
     75     V_BCAST	= 0x0400,
     76     V_PIXMUX	= 0x1000,
     77     V_DBLCLK	= 0x2000,
     78     V_CLKDIV2	= 0x4000
     79 } ModeFlags;
     80 
     81 typedef enum {
     82     INTERLACE_HALVE_V	= 0x0001	/* Halve V values for interlacing */
     83 } CrtcAdjustFlags;
     84 
     85 /* Flags passed to ChipValidMode() */
     86 typedef enum {
     87     MODECHECK_INITIAL = 0,
     88     MODECHECK_FINAL   = 1
     89 } ModeCheckFlags;
     90 
     91 /* These are possible return values for xf86CheckMode() and ValidMode() */
     92 typedef enum {
     93     MODE_OK	= 0,	/* Mode OK */
     94     MODE_HSYNC,		/* hsync out of range */
     95     MODE_VSYNC,		/* vsync out of range */
     96     MODE_H_ILLEGAL,	/* mode has illegal horizontal timings */
     97     MODE_V_ILLEGAL,	/* mode has illegal horizontal timings */
     98     MODE_BAD_WIDTH,	/* requires an unsupported linepitch */
     99     MODE_NOMODE,	/* no mode with a maching name */
    100     MODE_NO_INTERLACE,	/* interlaced mode not supported */
    101     MODE_NO_DBLESCAN,	/* doublescan mode not supported */
    102     MODE_NO_VSCAN,	/* multiscan mode not supported */
    103     MODE_MEM,		/* insufficient video memory */
    104     MODE_VIRTUAL_X,	/* mode width too large for specified virtual size */
    105     MODE_VIRTUAL_Y,	/* mode height too large for specified virtual size */
    106     MODE_MEM_VIRT,	/* insufficient video memory given virtual size */
    107     MODE_NOCLOCK,	/* no fixed clock available */
    108     MODE_CLOCK_HIGH,	/* clock required is too high */
    109     MODE_CLOCK_LOW,	/* clock required is too low */
    110     MODE_CLOCK_RANGE,	/* clock/mode isn't in a ClockRange */
    111     MODE_BAD_HVALUE,	/* horizontal timing was out of range */
    112     MODE_BAD_VVALUE,	/* vertical timing was out of range */
    113     MODE_BAD_VSCAN,	/* VScan value out of range */
    114     MODE_HSYNC_NARROW,	/* horizontal sync too narrow */
    115     MODE_HSYNC_WIDE,	/* horizontal sync too wide */
    116     MODE_HBLANK_NARROW,	/* horizontal blanking too narrow */
    117     MODE_HBLANK_WIDE,	/* horizontal blanking too wide */
    118     MODE_VSYNC_NARROW,	/* vertical sync too narrow */
    119     MODE_VSYNC_WIDE,	/* vertical sync too wide */
    120     MODE_VBLANK_NARROW,	/* vertical blanking too narrow */
    121     MODE_VBLANK_WIDE,	/* vertical blanking too wide */
    122     MODE_PANEL,         /* exceeds panel dimensions */
    123     MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
    124     MODE_ONE_WIDTH,     /* only one width is supported */
    125     MODE_ONE_HEIGHT,    /* only one height is supported */
    126     MODE_ONE_SIZE,      /* only one resolution is supported */
    127     MODE_BAD = -2,	/* unspecified reason */
    128     MODE_ERROR	= -1	/* error condition */
    129 } ModeStatus;
    130 
    131 # define M_T_BUILTIN 0x01        /* built-in mode */
    132 # define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
    133 # define M_T_CRTC_C  (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC  */
    134 # define M_T_CLOCK_CRTC_C  (M_T_CLOCK_C | M_T_CRTC_C)
    135                                /* built-in mode - configure CRTC and clock */
    136 # define M_T_DEFAULT 0x10	/* (VESA) default modes */
    137 # define M_T_USERDEF 0x20	/* One of the modes from the config file */
    138 
    139 /* Video mode */
    140 typedef struct _DisplayModeRec {
    141     struct _DisplayModeRec *	prev;
    142     struct _DisplayModeRec *	next;
    143     char *			name;		/* identifier for the mode */
    144     ModeStatus			status;
    145     int				type;
    146 
    147     /* These are the values that the user sees/provides */
    148     int				Clock;		/* pixel clock freq (kHz) */
    149     int				HDisplay;	/* horizontal timing */
    150     int				HSyncStart;
    151     int				HSyncEnd;
    152     int				HTotal;
    153     int				HSkew;
    154     int				VDisplay;	/* vertical timing */
    155     int				VSyncStart;
    156     int				VSyncEnd;
    157     int				VTotal;
    158     int				VScan;
    159     int				Flags;
    160 
    161   /* These are the values the hardware uses */
    162     int				ClockIndex;
    163     int				SynthClock;	/* Actual clock freq to
    164 					  	 * be programmed  (kHz) */
    165     int				CrtcHDisplay;
    166     int				CrtcHBlankStart;
    167     int				CrtcHSyncStart;
    168     int				CrtcHSyncEnd;
    169     int				CrtcHBlankEnd;
    170     int				CrtcHTotal;
    171     int				CrtcHSkew;
    172     int				CrtcVDisplay;
    173     int				CrtcVBlankStart;
    174     int				CrtcVSyncStart;
    175     int				CrtcVSyncEnd;
    176     int				CrtcVBlankEnd;
    177     int				CrtcVTotal;
    178     Bool			CrtcHAdjusted;
    179     Bool			CrtcVAdjusted;
    180     int				PrivSize;
    181     INT32 *			Private;
    182     int				PrivFlags;
    183 
    184     float			HSync, VRefresh;
    185 } DisplayModeRec, *DisplayModePtr;
    186 
    187 /* The monitor description */
    188 
    189 #define MAX_HSYNC 8
    190 #define MAX_VREFRESH 8
    191 
    192 typedef struct { float hi, lo; } range;
    193 
    194 typedef struct { CARD32 red, green, blue; } rgb;
    195 
    196 typedef struct { float red, green, blue; } Gamma;
    197 
    198 /* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
    199 #define GAMMA_MAX	10.0
    200 #define GAMMA_MIN	(1.0 / GAMMA_MAX)
    201 #define GAMMA_ZERO	(GAMMA_MIN / 100.0)
    202 
    203 typedef struct {
    204     char *		id;
    205     char *		vendor;
    206     char *		model;
    207     int			nHsync;
    208     range		hsync[MAX_HSYNC];
    209     int			nVrefresh;
    210     range		vrefresh[MAX_VREFRESH];
    211     DisplayModePtr	Modes;		/* Start of the monitor's mode list */
    212     DisplayModePtr	Last;		/* End of the monitor's mode list */
    213     Gamma		gamma;		/* Gamma of the monitor */
    214     int			widthmm;
    215     int			heightmm;
    216     pointer		options;
    217     pointer		DDC;
    218 } MonRec, *MonPtr;
    219 
    220 /* the list of clock ranges */
    221 typedef struct x_ClockRange {
    222     struct x_ClockRange *next;
    223     int			minClock;	/* (kHz) */
    224     int			maxClock;	/* (kHz) */
    225     int			clockIndex;	/* -1 for programmable clocks */
    226     Bool		interlaceAllowed;
    227     Bool		doubleScanAllowed;
    228     int			ClockMulFactor;
    229     int			ClockDivFactor;
    230     int			PrivFlags;
    231 } ClockRange, *ClockRangePtr;
    232 
    233 /* Need to store the strategy with clockRange for VidMode extension */
    234 typedef struct x_ClockRanges {
    235     struct x_ClockRanges *next;
    236     int			minClock;
    237     int			maxClock;
    238     int			clockIndex;	/* -1 for programmable clocks */
    239     Bool		interlaceAllowed;
    240     Bool		doubleScanAllowed;
    241     int			ClockMulFactor;
    242     int			ClockDivFactor;
    243     int			PrivFlags;
    244     int			strategy;
    245 } ClockRanges, *ClockRangesPtr;
    246 
    247 /*
    248  * The driverFunc. xorgDriverFuncOp specifies the action driver should
    249  * perform. If requested option is not supported function should return
    250  * FALSE. pointer can be used to pass arguments to the function or
    251  * to return data to the caller.
    252  */
    253 typedef struct _ScrnInfoRec *ScrnInfoPtr;
    254 
    255 /* do not change order */
    256 typedef enum {
    257     RR_GET_INFO,
    258     RR_SET_CONFIG,
    259     RR_GET_MODE_MM,
    260     GET_REQUIRED_HW_INTERFACES = 10
    261 } xorgDriverFuncOp;
    262 
    263 typedef Bool xorgDriverFuncProc		  (ScrnInfoPtr, xorgDriverFuncOp,
    264 					   pointer);
    265 
    266 /* RR_GET_INFO, RR_SET_CONFIG */
    267 typedef struct {
    268     int rotation;
    269     int rate;
    270     int width;
    271     int height;
    272 } xorgRRConfig;
    273 
    274 typedef union {
    275     short RRRotations;
    276     xorgRRConfig RRConfig;
    277 } xorgRRRotation, *xorgRRRotationPtr;
    278 
    279 /* RR_GET_MODE_MM */
    280 typedef struct {
    281     DisplayModePtr mode;
    282     int virtX;
    283     int virtY;
    284     int mmWidth;
    285     int mmHeight;
    286 } xorgRRModeMM, *xorgRRModeMMPtr;
    287 
    288 /* GET_REQUIRED_HW_INTERFACES */
    289 #define HW_IO 1
    290 #define HW_MMIO 2
    291 #define NEED_IO_ENABLED(x) (x & HW_IO)
    292 
    293 typedef CARD32 xorgHWFlags;
    294 
    295 /*
    296  * The driver list struct.  This contains the information required for each
    297  * driver before a ScrnInfoRec has been allocated.
    298  */
    299 struct _DriverRec;
    300 
    301 typedef struct {
    302     int			driverVersion;
    303     char *		driverName;
    304     void		(*Identify)(int flags);
    305     Bool		(*Probe)(struct _DriverRec *drv, int flags);
    306     const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
    307     pointer		module;
    308     int			refCount;
    309 } DriverRec1;
    310 
    311 typedef struct _DriverRec {
    312     int			driverVersion;
    313     char *		driverName;
    314     void		(*Identify)(int flags);
    315     Bool		(*Probe)(struct _DriverRec *drv, int flags);
    316     const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
    317     pointer		module;
    318     int			refCount;
    319     xorgDriverFuncProc  *driverFunc;
    320 } DriverRec, *DriverPtr;
    321 
    322 /*
    323  *  AddDriver flags
    324  */
    325 #define HaveDriverFuncs 1
    326 
    327 
    328 #ifdef XFree86LOADER
    329 /*
    330  * The optional module list struct. This allows modules exporting helping
    331  * functions to configuration tools, the Xserver, or any other
    332  * application/module interested in such information.
    333  */
    334 typedef struct _ModuleInfoRec {
    335     int			moduleVersion;
    336     char *		moduleName;
    337     pointer		module;
    338     int			refCount;
    339     const OptionInfoRec * (*AvailableOptions)(void *unused);
    340     pointer		unused[8];	/* leave some space for more fields */
    341 } ModuleInfoRec, *ModuleInfoPtr;
    342 #endif
    343 
    344 /*
    345  * These are the private bus types.  New types can be added here.  Types
    346  * required for the public interface should be added to xf86str.h, with
    347  * function prototypes added to xf86.h.
    348  */
    349 
    350 /* Tolerate prior #include <linux/input.h> */
    351 #if defined(__linux__) && defined(_INPUT_H)
    352 #undef BUS_NONE
    353 #undef BUS_ISA
    354 #undef BUS_PCI
    355 #undef BUS_SBUS
    356 #undef BUS_last
    357 #endif
    358 
    359 typedef enum {
    360     BUS_NONE,
    361     BUS_ISA,
    362     BUS_PCI,
    363     BUS_SBUS,
    364     BUS_last    /* Keep last */
    365 } BusType;
    366 
    367 typedef struct {
    368     int		bus;
    369     int		device;
    370     int		func;
    371 } PciBusId;
    372 
    373 typedef struct {
    374     unsigned int dummy;
    375 } IsaBusId;
    376 
    377 typedef struct {
    378     int		fbNum;
    379 } SbusBusId;
    380 
    381 typedef struct _bus {
    382     BusType type;
    383     union {
    384 	IsaBusId isa;
    385 	PciBusId pci;
    386 	SbusBusId sbus;
    387     } id;
    388 } BusRec, *BusPtr;
    389 
    390 #define MAXCLOCKS   128
    391 typedef enum {
    392     DAC_BPP8 = 0,
    393     DAC_BPP16,
    394     DAC_BPP24,
    395     DAC_BPP32,
    396     MAXDACSPEEDS
    397 } DacSpeedIndex;
    398 
    399 typedef struct {
    400    char *			identifier;
    401    char *			vendor;
    402    char *			board;
    403    char *			chipset;
    404    char *			ramdac;
    405    char *			driver;
    406    struct _confscreenrec *	myScreenSection;
    407    Bool				claimed;
    408    int				dacSpeeds[MAXDACSPEEDS];
    409    int				numclocks;
    410    int				clock[MAXCLOCKS];
    411    char *			clockchip;
    412    char *			busID;
    413    Bool				active;
    414    Bool				inUse;
    415    int				videoRam;
    416    int				textClockFreq;
    417    unsigned long		BiosBase;	/* Base address of video BIOS */
    418    unsigned long		MemBase;	/* Frame buffer base address */
    419    unsigned long		IOBase;
    420    int				chipID;
    421    int				chipRev;
    422    pointer			options;
    423    int                          irq;
    424    int                          screen;         /* For multi-CRTC cards */
    425 } GDevRec, *GDevPtr;
    426 
    427 typedef int (*FindIsaDevProc)(GDevPtr dev);
    428 
    429 typedef struct {
    430    char *			identifier;
    431    char *			driver;
    432    pointer		 	commonOptions;
    433    pointer			extraOptions;
    434 } IDevRec, *IDevPtr;
    435 
    436 typedef struct {
    437     int			vendor;
    438     int			chipType;
    439     int			chipRev;
    440     int			subsysVendor;
    441     int			subsysCard;
    442     int			bus;
    443     int			device;
    444     int			func;
    445     int			class;
    446     int			subclass;
    447     int			interface;
    448     memType  	        memBase[6];
    449     memType  	        ioBase[6];
    450     int			size[6];
    451     unsigned char	type[6];
    452     memType   	        biosBase;
    453     int			biosSize;
    454     pointer		thisCard;
    455     Bool                validSize;
    456     Bool                validate;
    457     CARD32              listed_class;
    458 } pciVideoRec, *pciVideoPtr;
    459 
    460 typedef struct {
    461     int			frameX0;
    462     int			frameY0;
    463     int			virtualX;
    464     int			virtualY;
    465     int			depth;
    466     int			fbbpp;
    467     rgb			weight;
    468     rgb			blackColour;
    469     rgb			whiteColour;
    470     int			defaultVisual;
    471     char **		modes;
    472     pointer		options;
    473 } DispRec, *DispPtr;
    474 
    475 typedef struct _confxvportrec {
    476     char *		identifier;
    477     pointer		options;
    478 } confXvPortRec, *confXvPortPtr;
    479 
    480 typedef struct _confxvadaptrec {
    481     char *		identifier;
    482     int			numports;
    483     confXvPortPtr	ports;
    484     pointer		options;
    485 } confXvAdaptorRec, *confXvAdaptorPtr;
    486 
    487 typedef struct _confscreenrec {
    488     char *		id;
    489     int			screennum;
    490     int			defaultdepth;
    491     int			defaultbpp;
    492     int			defaultfbbpp;
    493     MonPtr		monitor;
    494     GDevPtr		device;
    495     int			numdisplays;
    496     DispPtr		displays;
    497     int			numxvadaptors;
    498     confXvAdaptorPtr	xvadaptors;
    499     pointer		options;
    500 } confScreenRec, *confScreenPtr;
    501 
    502 typedef enum {
    503     PosObsolete = -1,
    504     PosAbsolute = 0,
    505     PosRightOf,
    506     PosLeftOf,
    507     PosAbove,
    508     PosBelow,
    509     PosRelative
    510 } PositionType;
    511 
    512 typedef struct _screenlayoutrec {
    513     confScreenPtr	screen;
    514     char *		topname;
    515     confScreenPtr	top;
    516     char *		bottomname;
    517     confScreenPtr	bottom;
    518     char *		leftname;
    519     confScreenPtr	left;
    520     char *		rightname;
    521     confScreenPtr	right;
    522     PositionType	where;
    523     int			x;
    524     int			y;
    525     char *		refname;
    526     confScreenPtr	refscreen;
    527 } screenLayoutRec, *screenLayoutPtr;
    528 
    529 typedef struct _serverlayoutrec {
    530     char *		id;
    531     screenLayoutPtr	screens;
    532     GDevPtr		inactives;
    533     IDevPtr		inputs;
    534     pointer		options;
    535 } serverLayoutRec, *serverLayoutPtr;
    536 
    537 typedef struct _confdribufferrec {
    538     int                 count;
    539     int                 size;
    540     enum {
    541 	XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
    542     }                   flags;
    543 } confDRIBufferRec, *confDRIBufferPtr;
    544 
    545 typedef struct _confdrirec {
    546     int                 group;
    547     int                 mode;
    548     int                 bufs_count;
    549     confDRIBufferRec    *bufs;
    550 } confDRIRec, *confDRIPtr;
    551 
    552 /* These values should be adjusted when new fields are added to ScrnInfoRec */
    553 #define NUM_RESERVED_INTS		16
    554 #define NUM_RESERVED_POINTERS		15
    555 #define NUM_RESERVED_FUNCS		11
    556 
    557 typedef pointer (*funcPointer)(void);
    558 
    559 /* flags for depth 24 pixmap options */
    560 typedef enum {
    561     Pix24DontCare = 0,
    562     Pix24Use24,
    563     Pix24Use32
    564 } Pix24Flags;
    565 
    566 /* Power management events: so far we only support APM */
    567 
    568 typedef enum {
    569     XF86_APM_UNKNOWN = -1,
    570     XF86_APM_SYS_STANDBY,
    571     XF86_APM_SYS_SUSPEND,
    572     XF86_APM_CRITICAL_SUSPEND,
    573     XF86_APM_USER_STANDBY,
    574     XF86_APM_USER_SUSPEND,
    575     XF86_APM_STANDBY_RESUME,
    576     XF86_APM_NORMAL_RESUME,
    577     XF86_APM_CRITICAL_RESUME,
    578     XF86_APM_LOW_BATTERY,
    579     XF86_APM_POWER_STATUS_CHANGE,
    580     XF86_APM_UPDATE_TIME,
    581     XF86_APM_CAPABILITY_CHANGED,
    582     XF86_APM_STANDBY_FAILED,
    583     XF86_APM_SUSPEND_FAILED
    584 } pmEvent;
    585 
    586 typedef enum {
    587     PM_WAIT,
    588     PM_CONTINUE,
    589     PM_FAILED,
    590     PM_NONE
    591 } pmWait;
    592 
    593 /*
    594  * The IO access enabler struct. This contains the address for
    595  * the IOEnable/IODisable funcs for their specific bus along
    596  * with a pointer to data needed by them
    597  */
    598 typedef struct _AccessRec {
    599     void (*AccessDisable)(void *arg);
    600     void (*AccessEnable)(void *arg);
    601     void *arg;
    602 } xf86AccessRec, *xf86AccessPtr;
    603 
    604 typedef struct {
    605     xf86AccessPtr mem;
    606     xf86AccessPtr io;
    607     xf86AccessPtr io_mem;
    608 } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
    609 
    610 /*  bus-access-related types */
    611 typedef enum {
    612     NONE,
    613     IO,
    614     MEM_IO,
    615     MEM
    616 } resType;
    617 
    618 typedef struct _EntityAccessRec {
    619     xf86AccessPtr fallback;
    620     xf86AccessPtr pAccess;
    621     resType rt;
    622     pointer  busAcc;
    623     struct _EntityAccessRec *next;
    624 } EntityAccessRec, *EntityAccessPtr;
    625 
    626 typedef struct _CurrAccRec {
    627     EntityAccessPtr pMemAccess;
    628     EntityAccessPtr pIoAccess;
    629 } xf86CurrentAccessRec, *xf86CurrentAccessPtr;
    630 
    631 /* new RAC */
    632 
    633 /* Resource Type values */
    634 #define ResNone		((unsigned long)(-1))
    635 
    636 #define ResMem		0x0001
    637 #define ResIo		0x0002
    638 #define ResIrq		0x0003
    639 #define ResDma		0x0004
    640 #define ResPciCfg	0x000e	/* PCI Configuration space */
    641 #define ResPhysMask	0x000F
    642 
    643 #define ResExclusive	0x0010
    644 #define ResShared	0x0020
    645 #define ResAny		0x0040
    646 #define ResAccMask	0x0070
    647 #define ResUnused	0x0080
    648 
    649 #define ResUnusedOpr	0x0100
    650 #define ResDisableOpr	0x0200
    651 #define ResOprMask	0x0300
    652 
    653 #define ResBlock	0x0400
    654 #define ResSparse	0x0800
    655 #define ResExtMask	0x0C00
    656 
    657 #define ResEstimated	0x001000
    658 #define ResInit 	0x002000
    659 #define ResBios		0x004000
    660 #define ResMiscMask	0x00F000
    661 
    662 #define ResBus		0x010000
    663 #define ResOverlap	0x020000
    664 
    665 #if defined(__alpha__) && defined(__linux__)
    666 # define ResDomain	0x1ff000000ul
    667 #else
    668 # define ResDomain	0xff000000ul
    669 #endif
    670 #define ResTypeMask	(ResPhysMask | ResDomain)	/* For conflict check */
    671 
    672 #define ResEnd		ResNone
    673 
    674 #define ResExcMemBlock		(ResMem | ResExclusive | ResBlock)
    675 #define ResExcIoBlock		(ResIo | ResExclusive | ResBlock)
    676 #define ResShrMemBlock		(ResMem | ResShared | ResBlock)
    677 #define ResShrIoBlock		(ResIo | ResShared | ResBlock)
    678 #define ResExcUusdMemBlock	(ResMem | ResExclusive | ResUnused | ResBlock)
    679 #define ResExcUusdIoBlock	(ResIo | ResExclusive | ResUnused | ResBlock)
    680 #define ResShrUusdMemBlock	(ResMem | ResShared | ResUnused | ResBlock)
    681 #define ResShrUusdIoBlock	(ResIo | ResShared | ResUnused | ResBlock)
    682 #define ResExcUusdMemSparse	(ResMem | ResExclusive | ResUnused | ResSparse)
    683 #define ResExcUusdIoSparse	(ResIo | ResExclusive | ResUnused | ResSparse)
    684 #define ResShrUusdMemSparse	(ResMem | ResShared | ResUnused | ResSparse)
    685 #define ResShrUusdIoSparse	(ResIo | ResShared | ResUnused | ResSparse)
    686 
    687 #define ResExcMemSparse		(ResMem | ResExclusive | ResSparse)
    688 #define ResExcIoSparse		(ResIo | ResExclusive | ResSparse)
    689 #define ResShrMemSparse		(ResMem | ResShared | ResSparse)
    690 #define ResShrIoSparse		(ResIo | ResShared | ResSparse)
    691 #define ResUusdMemSparse	(ResMem | ResUnused | ResSparse)
    692 #define ResUusdIoSparse		(ResIo | ResUnused | ResSparse)
    693 
    694 #define ResIsMem(r)		(((r)->type & ResPhysMask) == ResMem)
    695 #define ResIsIo(r)		(((r)->type & ResPhysMask) == ResIo)
    696 #define ResIsExclusive(r)	(((r)->type & ResAccMask) == ResExclusive)
    697 #define ResIsShared(r)		(((r)->type & ResAccMask) == ResShared)
    698 #define ResIsUnused(r)		(((r)->type & ResAccMask) == ResUnused)
    699 #define ResIsBlock(r)		(((r)->type & ResExtMask) == ResBlock)
    700 #define ResIsSparse(r)		(((r)->type & ResExtMask) == ResSparse)
    701 #define ResIsEstimated(r)	(((r)->type & ResMiscMask) == ResEstimated)
    702 #define ResCanOverlap(r)	(ResIsEstimated(r) || ((r)->type & ResOverlap))
    703 
    704 typedef struct {
    705     unsigned long type;     /* shared, exclusive, unused etc. */
    706     memType a;
    707     memType b;
    708 } resRange, *resList;
    709 
    710 #define RANGE_TYPE(type, domain) \
    711                (((unsigned long)(domain) << 24) | ((type) & ~ResBus))
    712 #define RANGE(r,u,v,t) {\
    713                        (r).a = (u);\
    714                        (r).b = (v);\
    715                        (r).type = (t);\
    716                        }
    717 
    718 #define rBase a
    719 #define rMask b
    720 #define rBegin a
    721 #define rEnd b
    722 
    723 /* resource record */
    724 typedef struct _resRec *resPtr;
    725 typedef struct _resRec {
    726     resRange    val;
    727     int		entityIndex;	/* who owns the resource */
    728     resPtr	next;
    729 } resRec;
    730 
    731 #define sparse_base	val.rBase
    732 #define sparse_mask	val.rMask
    733 #define block_begin	val.rBegin
    734 #define block_end	val.rEnd
    735 #define res_type	val.type
    736 
    737 typedef struct {
    738     int numChipset;
    739     resRange *resList;
    740 } IsaChipsets;
    741 
    742 typedef struct {
    743     int numChipset;
    744     int PCIid;
    745     resRange *resList;
    746 } PciChipsets;
    747 
    748 /* Entity properties */
    749 typedef void (*EntityProc)(int entityIndex,pointer private);
    750 
    751 typedef struct _entityInfo {
    752     int index;
    753     BusRec location;
    754     int chipset;
    755     Bool active;
    756     resPtr resources;
    757     GDevPtr device;
    758     DriverPtr driver;
    759 } EntityInfoRec, *EntityInfoPtr;
    760 
    761 /* server states */
    762 
    763 typedef enum {
    764     SETUP,
    765     OPERATING
    766 } xf86State;
    767 
    768 typedef enum {
    769     NOTIFY_SETUP_TRANSITION,
    770     NOTIFY_SETUP,
    771     NOTIFY_OPERATING,
    772     NOTIFY_OPERATING_TRANSITION,
    773     NOTIFY_ENABLE,
    774     NOTIFY_ENTER,
    775     NOTIFY_LEAVE
    776 } xf86NotifyState;
    777 
    778 typedef void (*xf86StateChangeNotificationCallbackFunc)(xf86NotifyState state,pointer);
    779 
    780 /* DGA */
    781 
    782 typedef struct {
    783    int num;		/* A unique identifier for the mode (num > 0) */
    784    DisplayModePtr mode;
    785    int flags;		/* DGA_CONCURRENT_ACCESS, etc... */
    786    int imageWidth;	/* linear accessible portion (pixels) */
    787    int imageHeight;
    788    int pixmapWidth;	/* Xlib accessible portion (pixels) */
    789    int pixmapHeight;	/* both fields ignored if no concurrent access */
    790    int bytesPerScanline;
    791    int byteOrder;	/* MSBFirst, LSBFirst */
    792    int depth;
    793    int bitsPerPixel;
    794    unsigned long red_mask;
    795    unsigned long green_mask;
    796    unsigned long blue_mask;
    797    short visualClass;
    798    int viewportWidth;
    799    int viewportHeight;
    800    int xViewportStep;	/* viewport position granularity */
    801    int yViewportStep;
    802    int maxViewportX;	/* max viewport origin */
    803    int maxViewportY;
    804    int viewportFlags;	/* types of page flipping possible */
    805    int offset;		/* offset into physical memory */
    806    unsigned char *address;	/* server's mapped framebuffer */
    807    int reserved1;
    808    int reserved2;
    809 } DGAModeRec, *DGAModePtr;
    810 
    811 typedef struct {
    812    DGAModePtr mode;
    813    PixmapPtr pPix;
    814 } DGADeviceRec, *DGADevicePtr;
    815 
    816 /*
    817  * Flags for driver Probe() functions.
    818  */
    819 #define PROBE_DEFAULT	  0x00
    820 #define PROBE_DETECT	  0x01
    821 #define PROBE_TRYHARD	  0x02
    822 
    823 /*
    824  * Driver entry point types
    825  */
    826 
    827 typedef Bool xf86ProbeProc                (DriverPtr, int);
    828 typedef Bool xf86PreInitProc              (ScrnInfoPtr, int);
    829 typedef Bool xf86ScreenInitProc           (int, ScreenPtr, int, char**);
    830 typedef Bool xf86SwitchModeProc           (int, DisplayModePtr, int);
    831 typedef void xf86AdjustFrameProc          (int, int, int, int);
    832 typedef Bool xf86EnterVTProc              (int, int);
    833 typedef void xf86LeaveVTProc              (int, int);
    834 typedef void xf86FreeScreenProc           (int, int);
    835 typedef ModeStatus xf86ValidModeProc      (int, DisplayModePtr, Bool, int);
    836 typedef void xf86EnableDisableFBAccessProc(int, Bool);
    837 typedef int  xf86SetDGAModeProc           (int, int, DGADevicePtr);
    838 typedef int  xf86ChangeGammaProc          (int, Gamma);
    839 typedef void xf86PointerMovedProc         (int, int, int);
    840 typedef Bool xf86PMEventProc              (int, pmEvent, Bool);
    841 typedef int  xf86HandleMessageProc     (int, const char*, const char*, char**);
    842 typedef void xf86DPMSSetProc		  (ScrnInfoPtr, int, int);
    843 typedef void xf86LoadPaletteProc   (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
    844 typedef void xf86SetOverscanProc          (ScrnInfoPtr, int);
    845 
    846 
    847 /*
    848  * ScrnInfoRec
    849  *
    850  * There is one of these for each screen, and it holds all the screen-specific
    851  * information.
    852  *
    853  * Note: the size and layout must be kept the same across versions.  New
    854  * fields are to be added in place of the "reserved*" fields.  No fields
    855  * are to be dependent on compile-time defines.
    856  */
    857 
    858 
    859 typedef struct _ScrnInfoRec {
    860     int			driverVersion;
    861     char *		driverName;		/* canonical name used in */
    862 						/* the config file */
    863     ScreenPtr		pScreen;		/* Pointer to the ScreenRec */
    864     int			scrnIndex;		/* Number of this screen */
    865     Bool		configured;		/* Is this screen valid */
    866     int			origIndex;		/* initial number assigned to
    867 						 * this screen before
    868 						 * finalising the number of
    869 						 * available screens */
    870 
    871     /* Display-wide screenInfo values needed by this screen */
    872     int			imageByteOrder;
    873     int			bitmapScanlineUnit;
    874     int			bitmapScanlinePad;
    875     int			bitmapBitOrder;
    876     int			numFormats;
    877     PixmapFormatRec	formats[MAXFORMATS];
    878     PixmapFormatRec	fbFormat;
    879 
    880     int			bitsPerPixel;		/* fb bpp */
    881     Pix24Flags		pixmap24;		/* pixmap pref for depth 24 */
    882     int			depth;			/* depth of default visual */
    883     MessageType		depthFrom;		/* set from config? */
    884     MessageType		bitsPerPixelFrom;	/* set from config? */
    885     rgb			weight;			/* r/g/b weights */
    886     rgb			mask;			/* rgb masks */
    887     rgb			offset;			/* rgb offsets */
    888     int			rgbBits;		/* Number of bits in r/g/b */
    889     Gamma		gamma;			/* Gamma of the monitor */
    890     int			defaultVisual;		/* default visual class */
    891     int			maxHValue;		/* max horizontal timing */
    892     int			maxVValue;		/* max vertical timing value */
    893     int			virtualX;		/* Virtual width */
    894     int			virtualY; 		/* Virtual height */
    895     int			xInc;			/* Horizontal timing increment */
    896     MessageType		virtualFrom;		/* set from config? */
    897     int			displayWidth;		/* memory pitch */
    898     int			frameX0;		/* viewport position */
    899     int			frameY0;
    900     int			frameX1;
    901     int			frameY1;
    902     int			zoomLocked;		/* Disallow mode changes */
    903     DisplayModePtr	modePool;		/* list of compatible modes */
    904     DisplayModePtr	modes;			/* list of actual modes */
    905     DisplayModePtr	currentMode;		/* current mode
    906 						 * This was previously
    907 						 * overloaded with the modes
    908 						 * field, which is a pointer
    909 						 * into a circular list */
    910     confScreenPtr	confScreen;		/* Screen config info */
    911     MonPtr		monitor;		/* Monitor information */
    912     DispPtr		display;		/* Display information */
    913     int *		entityList;		/* List of device entities */
    914     int			numEntities;
    915     int			widthmm;		/* physical display dimensions
    916 						 * in mm */
    917     int			heightmm;
    918     int			xDpi;			/* width DPI */
    919     int			yDpi;			/* height DPI */
    920     char *		name;			/* Name to prefix messages */
    921     pointer		driverPrivate;		/* Driver private area */
    922     DevUnion *		privates;		/* Other privates can hook in
    923 						 * here */
    924     DriverPtr		drv;			/* xf86DriverList[] entry */
    925     pointer		module;			/* Pointer to module head */
    926     int			colorKey;
    927     int			overlayFlags;
    928 
    929     /* Some of these may be moved out of here into the driver private area */
    930 
    931     char *		chipset;		/* chipset name */
    932     char *		ramdac;			/* ramdac name */
    933     char *		clockchip;		/* clock name */
    934     Bool		progClock;		/* clock is programmable */
    935     int			numClocks;		/* number of clocks */
    936     int			clock[MAXCLOCKS];	/* list of clock frequencies */
    937     int			videoRam;		/* amount of video ram (kb) */
    938     unsigned long	biosBase;		/* Base address of video BIOS */
    939     unsigned long	memPhysBase;		/* Physical address of FB */
    940     unsigned long 	fbOffset;		/* Offset of FB in the above */
    941     IOADDRESS    	domainIOBase;		/* Domain I/O base address */
    942     int			memClk;			/* memory clock */
    943     int			textClockFreq;		/* clock of text mode */
    944     Bool		flipPixels;		/* swap default black/white */
    945     pointer		options;
    946 
    947     int			chipID;
    948     int			chipRev;
    949     int			racMemFlags;
    950     int			racIoFlags;
    951     pointer		access;
    952     xf86CurrentAccessPtr CurrentAccess;
    953     resType		resourceType;
    954     pointer		busAccess;
    955 
    956     /* Allow screens to be enabled/disabled individually */
    957     Bool		vtSema;
    958     DevUnion		pixmapPrivate;		/* saved devPrivate from pixmap */
    959 
    960     /* hw cursor moves at SIGIO time */
    961     Bool		silkenMouse;
    962 
    963     /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
    964     ClockRangesPtr	clockRanges;
    965     int			adjustFlags;
    966 
    967     /*
    968      * These can be used when the minor ABI version is incremented.
    969      * The NUM_* parameters must be reduced appropriately to keep the
    970      * structure size and alignment unchanged.
    971      */
    972     int			reservedInt[NUM_RESERVED_INTS];
    973 
    974     int *		entityInstanceList;
    975     pointer		reservedPtr[NUM_RESERVED_POINTERS];
    976 
    977     /*
    978      * Driver entry points.
    979      *
    980      */
    981 
    982     xf86ProbeProc			*Probe;
    983     xf86PreInitProc			*PreInit;
    984     xf86ScreenInitProc			*ScreenInit;
    985     xf86SwitchModeProc			*SwitchMode;
    986     xf86AdjustFrameProc			*AdjustFrame;
    987     xf86EnterVTProc			*EnterVT;
    988     xf86LeaveVTProc			*LeaveVT;
    989     xf86FreeScreenProc			*FreeScreen;
    990     xf86ValidModeProc			*ValidMode;
    991     xf86EnableDisableFBAccessProc	*EnableDisableFBAccess;
    992     xf86SetDGAModeProc			*SetDGAMode;
    993     xf86ChangeGammaProc			*ChangeGamma;
    994     xf86PointerMovedProc		*PointerMoved;
    995     xf86PMEventProc			*PMEvent;
    996     xf86HandleMessageProc		*HandleMessage;
    997     xf86DPMSSetProc			*DPMSSet;
    998     xf86LoadPaletteProc			*LoadPalette;
    999     xf86SetOverscanProc			*SetOverscan;
   1000     xorgDriverFuncProc			*DriverFunc;
   1001 
   1002     /*
   1003      * This can be used when the minor ABI version is incremented.
   1004      * The NUM_* parameter must be reduced appropriately to keep the
   1005      * structure size and alignment unchanged.
   1006      */
   1007     funcPointer		reservedFuncs[NUM_RESERVED_FUNCS];
   1008 
   1009 } ScrnInfoRec;
   1010 
   1011 
   1012 typedef struct {
   1013    Bool (*OpenFramebuffer)(
   1014 	ScrnInfoPtr pScrn,
   1015 	char **name,
   1016 	unsigned char **mem,
   1017 	int *size,
   1018 	int *offset,
   1019         int *extra
   1020    );
   1021    void	(*CloseFramebuffer)(ScrnInfoPtr pScrn);
   1022    Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
   1023    void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
   1024    int  (*GetViewport)(ScrnInfoPtr pScrn);
   1025    void (*Sync)(ScrnInfoPtr);
   1026    void (*FillRect)(
   1027 	ScrnInfoPtr pScrn,
   1028 	int x, int y, int w, int h,
   1029 	unsigned long color
   1030    );
   1031    void (*BlitRect)(
   1032 	ScrnInfoPtr pScrn,
   1033 	int srcx, int srcy,
   1034 	int w, int h,
   1035 	int dstx, int dsty
   1036    );
   1037    void (*BlitTransRect)(
   1038 	ScrnInfoPtr pScrn,
   1039 	int srcx, int srcy,
   1040 	int w, int h,
   1041 	int dstx, int dsty,
   1042 	unsigned long color
   1043    );
   1044 } DGAFunctionRec, *DGAFunctionPtr;
   1045 
   1046 typedef struct {
   1047     int			token;		/* id of the token */
   1048     const char *	name;		/* token name */
   1049 } SymTabRec, *SymTabPtr;
   1050 
   1051 /* flags for xf86LookupMode */
   1052 typedef enum {
   1053     LOOKUP_DEFAULT		= 0,	/* Use default mode lookup method */
   1054     LOOKUP_BEST_REFRESH,		/* Pick modes with best refresh */
   1055     LOOKUP_CLOSEST_CLOCK,		/* Pick modes with the closest clock */
   1056     LOOKUP_LIST_ORDER,			/* Pick first useful mode in list */
   1057     LOOKUP_CLKDIV2		= 0x0100, /* Allow half clocks */
   1058     LOOKUP_OPTIONAL_TOLERANCES	= 0x0200  /* Allow missing hsync/vrefresh */
   1059 } LookupModeFlags;
   1060 
   1061 #define NoDepth24Support	0x00
   1062 #define Support24bppFb		0x01	/* 24bpp framebuffer supported */
   1063 #define Support32bppFb		0x02	/* 32bpp framebuffer supported */
   1064 #define SupportConvert24to32	0x04	/* Can convert 24bpp pixmap to 32bpp */
   1065 #define SupportConvert32to24	0x08	/* Can convert 32bpp pixmap to 24bpp */
   1066 #define PreferConvert24to32	0x10	/* prefer 24bpp pixmap to 32bpp conv */
   1067 #define PreferConvert32to24	0x20	/* prefer 32bpp pixmap to 24bpp conv */
   1068 
   1069 
   1070 /* For DPMS */
   1071 typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
   1072 
   1073 /* Input handler proc */
   1074 typedef void (*InputHandlerProc)(int fd, pointer data);
   1075 
   1076 /* These are used by xf86GetClocks */
   1077 #define CLK_REG_SAVE		-1
   1078 #define CLK_REG_RESTORE		-2
   1079 
   1080 /* xf86Debug.c */
   1081 #ifdef BUILDDEBUG
   1082 typedef struct {
   1083     long sec;
   1084     long usec;
   1085 } xf86TsRec, *xf86TsPtr;
   1086 #endif
   1087 
   1088 /*
   1089  * misc constants
   1090  */
   1091 #define INTERLACE_REFRESH_WEIGHT	1.5
   1092 #define SYNC_TOLERANCE		0.01	/* 1 percent */
   1093 #define CLOCK_TOLERANCE		2000	/* Clock matching tolerance (2MHz) */
   1094 
   1095 
   1096 #define OVERLAY_8_32_DUALFB	0x00000001
   1097 #define OVERLAY_8_24_DUALFB	0x00000002
   1098 #define OVERLAY_8_16_DUALFB	0x00000004
   1099 #define OVERLAY_8_32_PLANAR	0x00000008
   1100 
   1101 #if 0
   1102 #define LD_RESOLV_IFDONE		0	/* only check if no more
   1103 						   delays pending */
   1104 #define LD_RESOLV_NOW			1	/* finish one delay step */
   1105 #define LD_RESOLV_FORCE			2	/* force checking... */
   1106 #endif
   1107 
   1108 /* Values of xf86Info.mouseFlags */
   1109 #define MF_CLEAR_DTR       1
   1110 #define MF_CLEAR_RTS       2
   1111 
   1112 /* Action Events */
   1113 typedef enum {
   1114     ACTION_TERMINATE		= 0,	/* Terminate Server */
   1115     ACTION_NEXT_MODE		= 10,	/* Switch to next video mode */
   1116     ACTION_PREV_MODE,
   1117     ACTION_DISABLEGRAB		= 20,	/* Cancel server/pointer/kbd grabs */
   1118     ACTION_CLOSECLIENT,			/* Kill client holding grab */
   1119     ACTION_SWITCHSCREEN		= 100,	/* VT switch */
   1120     ACTION_SWITCHSCREEN_NEXT,
   1121     ACTION_SWITCHSCREEN_PREV,
   1122     ACTION_MESSAGE		= 9999  /* Generic message passing */
   1123 } ActionEvent;
   1124 
   1125 /* xf86Versions.c */
   1126 /*
   1127  * Never change existing values, and always assign values explicitly.
   1128  * NUM_BUILTIN_IFS must always be the last entry.
   1129  */
   1130 typedef enum {
   1131     BUILTIN_IF_OSMOUSE = 0,
   1132     BUILTIN_IF_OSKBD = 1,
   1133     NUM_BUILTIN_IFS
   1134 } BuiltinInterface;
   1135 
   1136 /*
   1137  * These are intentionally the same as the module version macros.
   1138  * It is possible to register a module as providing a specific interface,
   1139  * in which case the module's version is used.  This feature isn't
   1140  * really ready for use yet though.
   1141  */
   1142 
   1143 #define BUILTIN_INTERFACE_VERSION_NUMERIC(maj, min, patch) \
   1144 	((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
   1145 #define GET_BUILTIN_INTERFACE_MAJOR_VERSION(vers)	(((vers) >> 24) & 0xFF)
   1146 #define GET_BUILTIN_INTERFACE_MINOR_VERSION(vers)	(((vers) >> 16) & 0xFF)
   1147 #define GET_BUILTIN_INTERFACE_PATCH_VERSION(vers)	((vers) & 0xFFFF)
   1148 
   1149 #endif /* _XF86STR_H */
   1150