xf86str.h 23.3 KB
Newer Older
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1 2

/*
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
 *
 * 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, sublicense,
 * 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 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 NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
 *
 * Except as contained in this notice, the name of the copyright holder(s)
 * and author(s) shall not be used in advertising or otherwise to promote
 * the sale, use or other dealings in this Software without prior written
 * authorization from the copyright holder(s) and author(s).
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
27 28 29 30 31 32 33 34 35 36
 */

/*
 * This file contains definitions of the public XFree86 data structures/types.
 * Any data structures that video drivers need to access should go here.
 */

#ifndef _XF86STR_H
#define _XF86STR_H

37
#include "misc.h"
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
38 39 40
#include "input.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
41
#include "colormapst.h"
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
42 43
#include "xf86Module.h"
#include "xf86Opt.h"
44
#include "displaymode.h"
45

46 47 48 49 50
/**
 * Integer type that is of the size of the addressable memory (machine size).
 * On most platforms \c uintptr_t will suffice.  However, on some mixed
 * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this
 * must be 64-bits.
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
51
 */
52 53 54 55 56 57 58
#include <inttypes.h>
#if defined(__powerpc__)
typedef uint64_t memType;
#else
typedef uintptr_t memType;
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
59 60 61
/* Video mode flags */

typedef enum {
62 63 64 65 66 67 68 69 70 71 72 73 74 75
    V_PHSYNC = 0x0001,
    V_NHSYNC = 0x0002,
    V_PVSYNC = 0x0004,
    V_NVSYNC = 0x0008,
    V_INTERLACE = 0x0010,
    V_DBLSCAN = 0x0020,
    V_CSYNC = 0x0040,
    V_PCSYNC = 0x0080,
    V_NCSYNC = 0x0100,
    V_HSKEW = 0x0200,           /* hskew provided */
    V_BCAST = 0x0400,
    V_PIXMUX = 0x1000,
    V_DBLCLK = 0x2000,
    V_CLKDIV2 = 0x4000
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
76 77 78
} ModeFlags;

typedef enum {
79
    INTERLACE_HALVE_V = 0x0001  /* Halve V values for interlacing */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
80 81 82 83 84
} CrtcAdjustFlags;

/* Flags passed to ChipValidMode() */
typedef enum {
    MODECHECK_INITIAL = 0,
85
    MODECHECK_FINAL = 1
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
86 87
} ModeCheckFlags;

88 89 90 91
/*
 * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN.
 * Preferred will bubble a mode to the top within a set.
 */
92 93 94 95
#define M_T_BUILTIN 0x01        /* built-in mode */
#define M_T_CLOCK_C (0x02 | M_T_BUILTIN)        /* built-in mode - configure clock */
#define M_T_CRTC_C  (0x04 | M_T_BUILTIN)        /* built-in mode - configure CRTC  */
#define M_T_CLOCK_CRTC_C  (M_T_CLOCK_C | M_T_CRTC_C)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
96
                               /* built-in mode - configure CRTC and clock */
97 98 99 100 101
#define M_T_PREFERRED 0x08      /* preferred mode within a set */
#define M_T_DEFAULT 0x10        /* (VESA) default modes */
#define M_T_USERDEF 0x20        /* One of the modes from the config file */
#define M_T_DRIVER  0x40        /* Supplied by the driver (EDID, etc) */
#define M_T_USERPREF 0x80       /* mode preferred by the user config */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
102 103 104 105 106 107

/* The monitor description */

#define MAX_HSYNC 8
#define MAX_VREFRESH 8

108 109 110
typedef struct {
    float hi, lo;
} range;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
111

112 113 114
typedef struct {
    CARD32 red, green, blue;
} rgb;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
115

116 117 118
typedef struct {
    float red, green, blue;
} Gamma;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
119 120 121 122 123 124 125

/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
#define GAMMA_MAX	10.0
#define GAMMA_MIN	(1.0 / GAMMA_MAX)
#define GAMMA_ZERO	(GAMMA_MIN / 100.0)

typedef struct {
126 127 128
    const char *id;
    const char *vendor;
    const char *model;
129 130 131 132 133 134 135 136 137
    int nHsync;
    range hsync[MAX_HSYNC];
    int nVrefresh;
    range vrefresh[MAX_VREFRESH];
    DisplayModePtr Modes;       /* Start of the monitor's mode list */
    DisplayModePtr Last;        /* End of the monitor's mode list */
    Gamma gamma;                /* Gamma of the monitor */
    int widthmm;
    int heightmm;
138 139
    void *options;
    void *DDC;
140 141
    Bool reducedblanking;       /* Allow CVT reduced blanking modes? */
    int maxPixClock;            /* in kHz, like mode->Clock */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
142 143 144 145 146
} MonRec, *MonPtr;

/* the list of clock ranges */
typedef struct x_ClockRange {
    struct x_ClockRange *next;
147 148 149 150 151 152 153 154
    int minClock;               /* (kHz) */
    int maxClock;               /* (kHz) */
    int clockIndex;             /* -1 for programmable clocks */
    Bool interlaceAllowed;
    Bool doubleScanAllowed;
    int ClockMulFactor;
    int ClockDivFactor;
    int PrivFlags;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
155 156
} ClockRange, *ClockRangePtr;

157 158 159 160 161 162 163 164 165 166 167 168
/*
 * The driverFunc. xorgDriverFuncOp specifies the action driver should
 * perform. If requested option is not supported function should return
 * FALSE. pointer can be used to pass arguments to the function or
 * to return data to the caller.
 */
typedef struct _ScrnInfoRec *ScrnInfoPtr;

/* do not change order */
typedef enum {
    RR_GET_INFO,
    RR_SET_CONFIG,
169
    RR_GET_MODE_MM,
170 171
    GET_REQUIRED_HW_INTERFACES = 10,
    SUPPORTS_SERVER_FDS = 11,
172 173
} xorgDriverFuncOp;

174
typedef Bool xorgDriverFuncProc(ScrnInfoPtr, xorgDriverFuncOp, void *);
175 176 177 178 179 180 181 182 183 184 185 186 187 188

/* RR_GET_INFO, RR_SET_CONFIG */
typedef struct {
    int rotation;
    int rate;
    int width;
    int height;
} xorgRRConfig;

typedef union {
    short RRRotations;
    xorgRRConfig RRConfig;
} xorgRRRotation, *xorgRRRotationPtr;

189 190 191 192 193 194 195 196 197
/* RR_GET_MODE_MM */
typedef struct {
    DisplayModePtr mode;
    int virtX;
    int virtY;
    int mmWidth;
    int mmHeight;
} xorgRRModeMM, *xorgRRModeMMPtr;

198 199 200
/* GET_REQUIRED_HW_INTERFACES */
#define HW_IO 1
#define HW_MMIO 2
201
#define HW_SKIP_CONSOLE 4
202 203 204 205
#define NEED_IO_ENABLED(x) (x & HW_IO)

typedef CARD32 xorgHWFlags;

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
206 207 208 209
/*
 * The driver list struct.  This contains the information required for each
 * driver before a ScrnInfoRec has been allocated.
 */
210 211
struct _DriverRec;

212 213 214
struct _SymTabRec;
struct _PciChipsets;

215
struct pci_device;
216
struct xf86_platform_device;
217

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
218
typedef struct _DriverRec {
219
    int driverVersion;
220
    const char *driverName;
221 222 223
    void (*Identify) (int flags);
    Bool (*Probe) (struct _DriverRec * drv, int flags);
    const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype);
224
    void *module;
225 226 227 228 229 230
    int refCount;
    xorgDriverFuncProc *driverFunc;

    const struct pci_id_match *supported_devices;
    Bool (*PciProbe) (struct _DriverRec * drv, int entity_num,
                      struct pci_device * dev, intptr_t match_data);
231 232
    Bool (*platformProbe) (struct _DriverRec * drv, int entity_num, int flags,
                           struct xf86_platform_device * dev, intptr_t match_data);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
233 234
} DriverRec, *DriverPtr;

235 236 237
/*
 * platform probe flags
 */
238 239
#define PLATFORM_PROBE_GPU_SCREEN 1

240 241 242 243 244
/*
 *  AddDriver flags
 */
#define HaveDriverFuncs 1

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
245 246 247 248 249 250 251
/*
 * These are the private bus types.  New types can be added here.  Types
 * required for the public interface should be added to xf86str.h, with
 * function prototypes added to xf86.h.
 */

/* Tolerate prior #include <linux/input.h> */
252
#if defined(linux)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
253 254 255
#undef BUS_NONE
#undef BUS_PCI
#undef BUS_SBUS
256
#undef BUS_PLATFORM
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
257 258 259 260 261 262 263
#undef BUS_last
#endif

typedef enum {
    BUS_NONE,
    BUS_PCI,
    BUS_SBUS,
264
    BUS_PLATFORM,
265
    BUS_last                    /* Keep last */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
266 267 268
} BusType;

typedef struct {
269
    int fbNum;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
270 271 272 273 274
} SbusBusId;

typedef struct _bus {
    BusType type;
    union {
275 276
        struct pci_device *pci;
        SbusBusId sbus;
277
        struct xf86_platform_device *plat;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
278 279 280 281 282 283 284 285 286 287
    } id;
} BusRec, *BusPtr;

typedef enum {
    DAC_BPP8 = 0,
    DAC_BPP16,
    DAC_BPP24,
    DAC_BPP32,
    MAXDACSPEEDS
} DacSpeedIndex;
288

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
289
typedef struct {
290 291 292 293 294 295
    const char *identifier;
    const char *vendor;
    const char *board;
    const char *chipset;
    const char *ramdac;
    const char *driver;
296 297 298 299 300
    struct _confscreenrec *myScreenSection;
    Bool claimed;
    int dacSpeeds[MAXDACSPEEDS];
    int numclocks;
    int clock[MAXCLOCKS];
301 302
    const char *clockchip;
    const char *busID;
303 304 305 306 307 308 309
    Bool active;
    Bool inUse;
    int videoRam;
    unsigned long MemBase;      /* Frame buffer base address */
    unsigned long IOBase;
    int chipID;
    int chipRev;
310
    void *options;
311 312
    int irq;
    int screen;                 /* For multi-CRTC cards */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
313 314 315
} GDevRec, *GDevPtr;

typedef struct {
316 317 318 319 320 321 322 323 324 325
    int frameX0;
    int frameY0;
    int virtualX;
    int virtualY;
    int depth;
    int fbbpp;
    rgb weight;
    rgb blackColour;
    rgb whiteColour;
    int defaultVisual;
326
    const char **modes;
327
    void *options;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
328 329 330
} DispRec, *DispPtr;

typedef struct _confxvportrec {
331
    const char *identifier;
332
    void *options;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
333 334 335
} confXvPortRec, *confXvPortPtr;

typedef struct _confxvadaptrec {
336
    const char *identifier;
337 338
    int numports;
    confXvPortPtr ports;
339
    void *options;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
340 341
} confXvAdaptorRec, *confXvAdaptorPtr;

342
#define MAX_GPUDEVICES 4
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
343
typedef struct _confscreenrec {
344
    const char *id;
345 346 347 348 349 350 351 352 353 354
    int screennum;
    int defaultdepth;
    int defaultbpp;
    int defaultfbbpp;
    MonPtr monitor;
    GDevPtr device;
    int numdisplays;
    DispPtr displays;
    int numxvadaptors;
    confXvAdaptorPtr xvadaptors;
355
    void *options;
356 357 358

    int num_gpu_devices;
    GDevPtr gpu_devices[MAX_GPUDEVICES];
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
359 360 361 362 363 364 365 366 367 368 369 370 371
} confScreenRec, *confScreenPtr;

typedef enum {
    PosObsolete = -1,
    PosAbsolute = 0,
    PosRightOf,
    PosLeftOf,
    PosAbove,
    PosBelow,
    PosRelative
} PositionType;

typedef struct _screenlayoutrec {
372
    confScreenPtr screen;
373
    const char *topname;
374
    confScreenPtr top;
375
    const char *bottomname;
376
    confScreenPtr bottom;
377
    const char *leftname;
378
    confScreenPtr left;
379
    const char *rightname;
380 381 382 383
    confScreenPtr right;
    PositionType where;
    int x;
    int y;
384
    const char *refname;
385
    confScreenPtr refscreen;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
386 387
} screenLayoutRec, *screenLayoutPtr;

388 389
typedef struct _InputInfoRec InputInfoRec;

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
390
typedef struct _serverlayoutrec {
391
    const char *id;
392 393 394
    screenLayoutPtr screens;
    GDevPtr inactives;
    InputInfoRec **inputs;      /* NULL terminated */
395
    void *options;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
396 397 398
} serverLayoutRec, *serverLayoutPtr;

typedef struct _confdribufferrec {
399 400
    int count;
    int size;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
401
    enum {
402 403
        XF86DRI_WC_HINT = 0x0001        /* Placeholder: not implemented */
    } flags;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
404 405 406
} confDRIBufferRec, *confDRIBufferPtr;

typedef struct _confdrirec {
407 408 409 410
    int group;
    int mode;
    int bufs_count;
    confDRIBufferRec *bufs;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
411
} confDRIRec, *confDRIPtr;
412

413 414 415
#define NUM_RESERVED_INTS		4
#define NUM_RESERVED_POINTERS		4
#define NUM_RESERVED_FUNCS		4
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
416

417 418 419
/* let clients know they can use this */
#define XF86_SCRN_HAS_PREFER_CLONE 1

420
typedef void *(*funcPointer) (void);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448

/* Power management events: so far we only support APM */

typedef enum {
    XF86_APM_UNKNOWN = -1,
    XF86_APM_SYS_STANDBY,
    XF86_APM_SYS_SUSPEND,
    XF86_APM_CRITICAL_SUSPEND,
    XF86_APM_USER_STANDBY,
    XF86_APM_USER_SUSPEND,
    XF86_APM_STANDBY_RESUME,
    XF86_APM_NORMAL_RESUME,
    XF86_APM_CRITICAL_RESUME,
    XF86_APM_LOW_BATTERY,
    XF86_APM_POWER_STATUS_CHANGE,
    XF86_APM_UPDATE_TIME,
    XF86_APM_CAPABILITY_CHANGED,
    XF86_APM_STANDBY_FAILED,
    XF86_APM_SUSPEND_FAILED
} pmEvent;

typedef enum {
    PM_WAIT,
    PM_CONTINUE,
    PM_FAILED,
    PM_NONE
} pmWait;

449
typedef struct _PciChipsets {
450 451 452 453
    /**
     * Key used to match this device with its name in an array of
     * \c SymTabRec.
     */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
454
    int numChipset;
455 456 457 458 459 460 461 462 463 464 465 466 467 468

    /**
     * This value is quirky.  Depending on the driver, it can take on one of
     * three meanings.  In drivers that have exactly one vendor ID (e.g.,
     * radeon, mga, i810) the low 16-bits are the device ID.
     *
     * In drivers that can have multiple vendor IDs (e.g., the glint driver
     * can have either 3dlabs' ID or TI's ID, the i740 driver can have either
     * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and
     * the high 16-bits are the vendor ID.
     *
     * In drivers that don't have a specific vendor (e.g., vga) contains the
     * device ID for either the generic VGA or generic 8514 devices.  This
     * turns out to be the same as the subclass and programming interface
Peter Hutterer's avatar
Peter Hutterer committed
469
     * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or
470 471
     * 0x000101) and for 8514 is 0x030001).
     */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
472
    int PCIid;
473

474 475 476 477 478
/* dummy place holders for drivers to build against old/new servers */
#define RES_UNDEFINED NULL
#define RES_EXCLUSIVE_VGA NULL
#define RES_SHARED_VGA NULL
    void *dummy;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
479 480 481
} PciChipsets;

/* Entity properties */
482
typedef void (*EntityProc) (int entityIndex, void *private);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
483 484 485 486 487 488 489 490 491 492 493 494 495

typedef struct _entityInfo {
    int index;
    BusRec location;
    int chipset;
    Bool active;
    GDevPtr device;
    DriverPtr driver;
} EntityInfoRec, *EntityInfoPtr;

/* DGA */

typedef struct {
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
    int num;                    /* A unique identifier for the mode (num > 0) */
    DisplayModePtr mode;
    int flags;                  /* DGA_CONCURRENT_ACCESS, etc... */
    int imageWidth;             /* linear accessible portion (pixels) */
    int imageHeight;
    int pixmapWidth;            /* Xlib accessible portion (pixels) */
    int pixmapHeight;           /* both fields ignored if no concurrent access */
    int bytesPerScanline;
    int byteOrder;              /* MSBFirst, LSBFirst */
    int depth;
    int bitsPerPixel;
    unsigned long red_mask;
    unsigned long green_mask;
    unsigned long blue_mask;
    short visualClass;
    int viewportWidth;
    int viewportHeight;
    int xViewportStep;          /* viewport position granularity */
    int yViewportStep;
    int maxViewportX;           /* max viewport origin */
    int maxViewportY;
    int viewportFlags;          /* types of page flipping possible */
    int offset;                 /* offset into physical memory */
    unsigned char *address;     /* server's mapped framebuffer */
    int reserved1;
    int reserved2;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
522 523 524
} DGAModeRec, *DGAModePtr;

typedef struct {
525 526
    DGAModePtr mode;
    PixmapPtr pPix;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
527 528 529 530 531 532 533 534 535 536 537 538 539
} DGADeviceRec, *DGADevicePtr;

/*
 * Flags for driver Probe() functions.
 */
#define PROBE_DEFAULT	  0x00
#define PROBE_DETECT	  0x01
#define PROBE_TRYHARD	  0x02

/*
 * Driver entry point types
 */

540 541
typedef Bool xf86ProbeProc(DriverPtr, int);
typedef Bool xf86PreInitProc(ScrnInfoPtr, int);
542 543 544 545 546 547 548 549 550 551 552 553
typedef Bool xf86ScreenInitProc(ScreenPtr, int, char **);
typedef Bool xf86SwitchModeProc(ScrnInfoPtr, DisplayModePtr);
typedef void xf86AdjustFrameProc(ScrnInfoPtr, int, int);
typedef Bool xf86EnterVTProc(ScrnInfoPtr);
typedef void xf86LeaveVTProc(ScrnInfoPtr);
typedef void xf86FreeScreenProc(ScrnInfoPtr);
typedef ModeStatus xf86ValidModeProc(ScrnInfoPtr, DisplayModePtr, Bool, int);
typedef void xf86EnableDisableFBAccessProc(ScrnInfoPtr, Bool);
typedef int xf86SetDGAModeProc(ScrnInfoPtr, int, DGADevicePtr);
typedef int xf86ChangeGammaProc(ScrnInfoPtr, Gamma);
typedef void xf86PointerMovedProc(ScrnInfoPtr, int, int);
typedef Bool xf86PMEventProc(ScrnInfoPtr, pmEvent, Bool);
554 555 556 557
typedef void xf86DPMSSetProc(ScrnInfoPtr, int, int);
typedef void xf86LoadPaletteProc(ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
typedef void xf86SetOverscanProc(ScrnInfoPtr, int);
typedef void xf86ModeSetProc(ScrnInfoPtr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
558 559 560 561 562

/*
 * ScrnInfoRec
 *
 * There is one of these for each screen, and it holds all the screen-specific
563
 * information.  Note: No fields are to be dependent on compile-time defines.
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
564 565 566
 */

typedef struct _ScrnInfoRec {
567
    int driverVersion;
568
    const char *driverName;     /* canonical name used in */
569 570 571 572 573 574 575 576
    /* the config file */
    ScreenPtr pScreen;          /* Pointer to the ScreenRec */
    int scrnIndex;              /* Number of this screen */
    Bool configured;            /* Is this screen valid */
    int origIndex;              /* initial number assigned to
                                 * this screen before
                                 * finalising the number of
                                 * available screens */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
577 578

    /* Display-wide screenInfo values needed by this screen */
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
    int imageByteOrder;
    int bitmapScanlineUnit;
    int bitmapScanlinePad;
    int bitmapBitOrder;
    int numFormats;
    PixmapFormatRec formats[MAXFORMATS];
    PixmapFormatRec fbFormat;

    int bitsPerPixel;           /* fb bpp */
    int depth;                  /* depth of default visual */
    MessageType depthFrom;      /* set from config? */
    MessageType bitsPerPixelFrom;       /* set from config? */
    rgb weight;                 /* r/g/b weights */
    rgb mask;                   /* rgb masks */
    rgb offset;                 /* rgb offsets */
    int rgbBits;                /* Number of bits in r/g/b */
    Gamma gamma;                /* Gamma of the monitor */
    int defaultVisual;          /* default visual class */
    int virtualX;               /* Virtual width */
    int virtualY;               /* Virtual height */
    int xInc;                   /* Horizontal timing increment */
    int displayWidth;           /* memory pitch */
    int frameX0;                /* viewport position */
    int frameY0;
    int frameX1;
    int frameY1;
    int zoomLocked;             /* Disallow mode changes */
    DisplayModePtr modePool;    /* list of compatible modes */
    DisplayModePtr modes;       /* list of actual modes */
    DisplayModePtr currentMode; /* current mode
                                 * This was previously
                                 * overloaded with the modes
                                 * field, which is a pointer
                                 * into a circular list */
    confScreenPtr confScreen;   /* Screen config info */
    MonPtr monitor;             /* Monitor information */
    DispPtr display;            /* Display information */
    int *entityList;            /* List of device entities */
    int numEntities;
    int widthmm;                /* physical display dimensions
                                 * in mm */
    int heightmm;
    int xDpi;                   /* width DPI */
    int yDpi;                   /* height DPI */
623
    const char *name;           /* Name to prefix messages */
624
    void *driverPrivate;        /* Driver private area */
625 626 627
    DevUnion *privates;         /* Other privates can hook in
                                 * here */
    DriverPtr drv;              /* xf86DriverList[] entry */
628
    void *module;               /* Pointer to module head */
629 630
    int colorKey;
    int overlayFlags;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
631 632 633

    /* Some of these may be moved out of here into the driver private area */

634 635 636
    const char *chipset;        /* chipset name */
    const char *ramdac;         /* ramdac name */
    const char *clockchip;      /* clock name */
637 638 639 640 641 642 643
    Bool progClock;             /* clock is programmable */
    int numClocks;              /* number of clocks */
    int clock[MAXCLOCKS];       /* list of clock frequencies */
    int videoRam;               /* amount of video ram (kb) */
    unsigned long memPhysBase;  /* Physical address of FB */
    unsigned long fbOffset;     /* Offset of FB in the above */
    Bool flipPixels;            /* swap default black/white */
644
    void *options;
645

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
646
    /* Allow screens to be enabled/disabled individually */
647
    Bool vtSema;
648

649
    /* hw cursor moves from input thread */
650
    Bool silkenMouse;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
651 652

    /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
653 654
    ClockRangePtr clockRanges;
    int adjustFlags;
655

656 657 658
    /* initial rightof support disable */
    int                 preferClone;

659 660
    Bool is_gpu;
    uint32_t capabilities;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
661

662 663
    int *entityInstanceList;
    struct pci_device *vgaDev;
664

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
665 666 667 668 669
    /*
     * Driver entry points.
     *
     */

670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
    xf86ProbeProc *Probe;
    xf86PreInitProc *PreInit;
    xf86ScreenInitProc *ScreenInit;
    xf86SwitchModeProc *SwitchMode;
    xf86AdjustFrameProc *AdjustFrame;
    xf86EnterVTProc *EnterVT;
    xf86LeaveVTProc *LeaveVT;
    xf86FreeScreenProc *FreeScreen;
    xf86ValidModeProc *ValidMode;
    xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
    xf86SetDGAModeProc *SetDGAMode;
    xf86ChangeGammaProc *ChangeGamma;
    xf86PointerMovedProc *PointerMoved;
    xf86PMEventProc *PMEvent;
    xf86DPMSSetProc *DPMSSet;
    xf86LoadPaletteProc *LoadPalette;
    xf86SetOverscanProc *SetOverscan;
    xorgDriverFuncProc *DriverFunc;
    xf86ModeSetProc *ModeSet;
689

690 691
    int reservedInt[NUM_RESERVED_INTS];
    void *reservedPtr[NUM_RESERVED_POINTERS];
692
    funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
693 694 695
} ScrnInfoRec;

typedef struct {
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
    Bool (*OpenFramebuffer) (ScrnInfoPtr pScrn,
                             char **name,
                             unsigned char **mem,
                             int *size, int *offset, int *extra);
    void (*CloseFramebuffer) (ScrnInfoPtr pScrn);
    Bool (*SetMode) (ScrnInfoPtr pScrn, DGAModePtr pMode);
    void (*SetViewport) (ScrnInfoPtr pScrn, int x, int y, int flags);
    int (*GetViewport) (ScrnInfoPtr pScrn);
    void (*Sync) (ScrnInfoPtr);
    void (*FillRect) (ScrnInfoPtr pScrn,
                      int x, int y, int w, int h, unsigned long color);
    void (*BlitRect) (ScrnInfoPtr pScrn,
                      int srcx, int srcy, int w, int h, int dstx, int dsty);
    void (*BlitTransRect) (ScrnInfoPtr pScrn,
                           int srcx, int srcy,
                           int w, int h,
                           int dstx, int dsty, unsigned long color);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
713 714
} DGAFunctionRec, *DGAFunctionPtr;

715
typedef struct _SymTabRec {
716 717
    int token;                  /* id of the token */
    const char *name;           /* token name */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
718 719 720 721
} SymTabRec, *SymTabPtr;

/* flags for xf86LookupMode */
typedef enum {
722 723 724 725 726 727
    LOOKUP_DEFAULT = 0,         /* Use default mode lookup method */
    LOOKUP_BEST_REFRESH,        /* Pick modes with best refresh */
    LOOKUP_CLOSEST_CLOCK,       /* Pick modes with the closest clock */
    LOOKUP_LIST_ORDER,          /* Pick first useful mode in list */
    LOOKUP_CLKDIV2 = 0x0100,    /* Allow half clocks */
    LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
728 729 730
} LookupModeFlags;

#define NoDepth24Support	0x00
731 732 733 734 735 736
#define Support24bppFb		0x01    /* 24bpp framebuffer supported */
#define Support32bppFb		0x02    /* 32bpp framebuffer supported */
#define SupportConvert24to32	0x04    /* Can convert 24bpp pixmap to 32bpp */
#define SupportConvert32to24	0x08    /* Can convert 32bpp pixmap to 24bpp */
#define PreferConvert24to32	0x10    /* prefer 24bpp pixmap to 32bpp conv */
#define PreferConvert32to24	0x20    /* prefer 32bpp pixmap to 24bpp conv */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
737 738

/* For DPMS */
739
typedef void (*DPMSSetProcPtr) (ScrnInfoPtr, int, int);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
740 741

/* Input handler proc */
742
typedef void (*InputHandlerProc) (int fd, void *data);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
743 744 745 746 747 748 749 750 751

/* These are used by xf86GetClocks */
#define CLK_REG_SAVE		-1
#define CLK_REG_RESTORE		-2

/*
 * misc constants
 */
#define INTERLACE_REFRESH_WEIGHT	1.5
752 753
#define SYNC_TOLERANCE		0.01    /* 1 percent */
#define CLOCK_TOLERANCE		2000    /* Clock matching tolerance (2MHz) */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
754 755 756 757 758 759 760 761 762 763 764 765

#define OVERLAY_8_32_DUALFB	0x00000001
#define OVERLAY_8_24_DUALFB	0x00000002
#define OVERLAY_8_16_DUALFB	0x00000004
#define OVERLAY_8_32_PLANAR	0x00000008

/* Values of xf86Info.mouseFlags */
#define MF_CLEAR_DTR       1
#define MF_CLEAR_RTS       2

/* Action Events */
typedef enum {
766 767
    ACTION_TERMINATE = 0,       /* Terminate Server */
    ACTION_NEXT_MODE = 10,      /* Switch to next video mode */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
768
    ACTION_PREV_MODE,
769
    ACTION_SWITCHSCREEN = 100,  /* VT switch */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
770
    ACTION_SWITCHSCREEN_NEXT,
771
    ACTION_SWITCHSCREEN_PREV,
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
772 773
} ActionEvent;

774
#endif                          /* _XF86STR_H */