This file is indexed.

/usr/include/xorg/xf86Crtc.h is in xserver-xorg-dev 2:1.19.6-1ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 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
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 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
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 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
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
/*
 * Copyright © 2006 Keith Packard
 * Copyright © 2011 Aaron Plattner
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of the copyright holders not be used in advertising or
 * publicity pertaining to distribution of the software without specific,
 * written prior permission.  The copyright holders make no representations
 * about the suitability of this software for any purpose.  It is provided "as
 * is" without express or implied warranty.
 *
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */
#ifndef _XF86CRTC_H_
#define _XF86CRTC_H_

#include <edid.h>
#include "randrstr.h"
#include "xf86Modes.h"
#include "xf86Cursor.h"
#include "xf86i2c.h"
#include "damage.h"
#include "picturestr.h"

/* Compat definitions for older X Servers. */
#ifndef M_T_PREFERRED
#define M_T_PREFERRED	0x08
#endif
#ifndef M_T_DRIVER
#define M_T_DRIVER	0x40
#endif
#ifndef M_T_USERPREF
#define M_T_USERPREF	0x80
#endif
#ifndef HARDWARE_CURSOR_ARGB
#define HARDWARE_CURSOR_ARGB				0x00004000
#endif

typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;

/* define a standard for connector types */
typedef enum _xf86ConnectorType {
    XF86ConnectorNone,
    XF86ConnectorVGA,
    XF86ConnectorDVI_I,
    XF86ConnectorDVI_D,
    XF86ConnectorDVI_A,
    XF86ConnectorComposite,
    XF86ConnectorSvideo,
    XF86ConnectorComponent,
    XF86ConnectorLFP,
    XF86ConnectorProprietary,
    XF86ConnectorHDMI,
    XF86ConnectorDisplayPort,
} xf86ConnectorType;

typedef enum _xf86OutputStatus {
    XF86OutputStatusConnected,
    XF86OutputStatusDisconnected,
    XF86OutputStatusUnknown
} xf86OutputStatus;

typedef enum _xf86DriverTransforms {
    XF86DriverTransformNone = 0,
    XF86DriverTransformOutput = 1 << 0,
    XF86DriverTransformCursorImage = 1 << 1,
    XF86DriverTransformCursorPosition = 1 << 2,
} xf86DriverTransforms;


struct xf86CrtcTileInfo {
    uint32_t group_id;
    uint32_t flags;
    uint32_t num_h_tile;
    uint32_t num_v_tile;
    uint32_t tile_h_loc;
    uint32_t tile_v_loc;
    uint32_t tile_h_size;
    uint32_t tile_v_size;
};

typedef struct _xf86CrtcFuncs {
   /**
    * Turns the crtc on/off, or sets intermediate power levels if available.
    *
    * Unsupported intermediate modes drop to the lower power setting.  If the
    * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
    * be safe to call mode_set.
    */
    void
     (*dpms) (xf86CrtcPtr crtc, int mode);

   /**
    * Saves the crtc's state for restoration on VT switch.
    */
    void
     (*save) (xf86CrtcPtr crtc);

   /**
    * Restore's the crtc's state at VT switch.
    */
    void
     (*restore) (xf86CrtcPtr crtc);

    /**
     * Lock CRTC prior to mode setting, mostly for DRI.
     * Returns whether unlock is needed
     */
    Bool
     (*lock) (xf86CrtcPtr crtc);

    /**
     * Unlock CRTC after mode setting, mostly for DRI
     */
    void
     (*unlock) (xf86CrtcPtr crtc);

    /**
     * Callback to adjust the mode to be set in the CRTC.
     *
     * This allows a CRTC to adjust the clock or even the entire set of
     * timings, which is used for panels with fixed timings or for
     * buses with clock limitations.
     */
    Bool
     (*mode_fixup) (xf86CrtcPtr crtc,
                    DisplayModePtr mode, DisplayModePtr adjusted_mode);

    /**
     * Prepare CRTC for an upcoming mode set.
     */
    void
     (*prepare) (xf86CrtcPtr crtc);

    /**
     * Callback for setting up a video mode after fixups have been made.
     */
    void
     (*mode_set) (xf86CrtcPtr crtc,
                  DisplayModePtr mode,
                  DisplayModePtr adjusted_mode, int x, int y);

    /**
     * Commit mode changes to a CRTC
     */
    void
     (*commit) (xf86CrtcPtr crtc);

    /* Set the color ramps for the CRTC to the given values. */
    void
     (*gamma_set) (xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
                   int size);

    /**
     * Allocate the shadow area, delay the pixmap creation until needed
     */
    void *(*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);

    /**
     * Create shadow pixmap for rotation support
     */
    PixmapPtr
     (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);

    /**
     * Destroy shadow pixmap
     */
    void
     (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);

    /**
     * Set cursor colors
     */
    void
     (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);

    /**
     * Set cursor position
     */
    void
     (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);

    /**
     * Show cursor
     */
    void
     (*show_cursor) (xf86CrtcPtr crtc);

    /**
     * Hide cursor
     */
    void
     (*hide_cursor) (xf86CrtcPtr crtc);

    /**
     * Load monochrome image
     */
    void
     (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
    Bool
     (*load_cursor_image_check) (xf86CrtcPtr crtc, CARD8 *image);

    /**
     * Load ARGB image
     */
    void
     (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
    Bool
     (*load_cursor_argb_check) (xf86CrtcPtr crtc, CARD32 *image);

    /**
     * Clean up driver-specific bits of the crtc
     */
    void
     (*destroy) (xf86CrtcPtr crtc);

    /**
     * Less fine-grained mode setting entry point for kernel modesetting
     */
    Bool
     (*set_mode_major) (xf86CrtcPtr crtc, DisplayModePtr mode,
                        Rotation rotation, int x, int y);

    /**
     * Callback for panning. Doesn't change the mode.
     * Added in ABI version 2
     */
    void
     (*set_origin) (xf86CrtcPtr crtc, int x, int y);

    /**
     */
    Bool
    (*set_scanout_pixmap)(xf86CrtcPtr crtc, PixmapPtr pixmap);

} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;

#define XF86_CRTC_VERSION 7

struct _xf86Crtc {
    /**
     * ABI versioning
     */
    int version;

    /**
     * Associated ScrnInfo
     */
    ScrnInfoPtr scrn;

    /**
     * Desired state of this CRTC
     *
     * Set when this CRTC should be driving one or more outputs
     */
    Bool enabled;

    /**
     * Active mode
     *
     * This reflects the mode as set in the CRTC currently
     * It will be cleared when the VT is not active or
     * during server startup
     */
    DisplayModeRec mode;
    Rotation rotation;
    PixmapPtr rotatedPixmap;
    void *rotatedData;

    /**
     * Position on screen
     *
     * Locates this CRTC within the frame buffer
     */
    int x, y;

    /**
     * Desired mode
     *
     * This is set to the requested mode, independent of
     * whether the VT is active. In particular, it receives
     * the startup configured mode and saves the active mode
     * on VT switch.
     */
    DisplayModeRec desiredMode;
    Rotation desiredRotation;
    int desiredX, desiredY;

    /** crtc-specific functions */
    const xf86CrtcFuncsRec *funcs;

    /**
     * Driver private
     *
     * Holds driver-private information
     */
    void *driver_private;

#ifdef RANDR_12_INTERFACE
    /**
     * RandR crtc
     *
     * When RandR 1.2 is available, this
     * points at the associated crtc object
     */
    RRCrtcPtr randr_crtc;
#else
    void *randr_crtc;
#endif

    /**
     * Current cursor is ARGB
     */
    Bool cursor_argb;
    /**
     * Track whether cursor is within CRTC range
     */
    Bool cursor_in_range;
    /**
     * Track state of cursor associated with this CRTC
     */
    Bool cursor_shown;

    /**
     * Current transformation matrix
     */
    PictTransform crtc_to_framebuffer;
    /* framebuffer_to_crtc was removed in ABI 2 */
    struct pict_f_transform f_crtc_to_framebuffer;      /* ABI 2 */
    struct pict_f_transform f_framebuffer_to_crtc;      /* ABI 2 */
    PictFilterPtr filter;       /* ABI 2 */
    xFixed *params;             /* ABI 2 */
    int nparams;                /* ABI 2 */
    int filter_width;           /* ABI 2 */
    int filter_height;          /* ABI 2 */
    Bool transform_in_use;
    RRTransformRec transform;   /* ABI 2 */
    Bool transformPresent;      /* ABI 2 */
    RRTransformRec desiredTransform;    /* ABI 2 */
    Bool desiredTransformPresent;       /* ABI 2 */
    /**
     * Bounding box in screen space
     */
    BoxRec bounds;
    /**
     * Panning:
     * TotalArea: total panning area, larger than CRTC's size
     * TrackingArea: Area of the pointer for which the CRTC is panned
     * border: Borders of the displayed CRTC area which induces panning if the pointer reaches them
     * Added in ABI version 2
     */
    BoxRec panningTotalArea;
    BoxRec panningTrackingArea;
    INT16 panningBorder[4];

    /**
     * Current gamma, especially useful after initial config.
     * Added in ABI version 3
     */
    CARD16 *gamma_red;
    CARD16 *gamma_green;
    CARD16 *gamma_blue;
    int gamma_size;

    /**
     * Actual state of this CRTC
     *
     * Set to TRUE after modesetting, set to FALSE if no outputs are connected
     * Added in ABI version 3
     */
    Bool active;
    /**
     * Clear the shadow
     */
    Bool shadowClear;

    /**
     * Indicates that the driver is handling some or all transforms:
     *
     * XF86DriverTransformOutput: The driver handles the output transform, so
     * the shadow surface should be disabled.  The driver writes this field
     * before calling xf86CrtcRotate to indicate that it is handling the
     * transform (including rotation and reflection).
     *
     * XF86DriverTransformCursorImage: Setting this flag causes the server to
     * pass the untransformed cursor image to the driver hook.
     *
     * XF86DriverTransformCursorPosition: Setting this flag causes the server
     * to pass the untransformed cursor position to the driver hook.
     *
     * Added in ABI version 4, changed to xf86DriverTransforms in ABI version 7
     */
    xf86DriverTransforms driverIsPerformingTransform;

    /* Added in ABI version 5
     */
    PixmapPtr current_scanout;

    /* Added in ABI version 6
     */
    PixmapPtr current_scanout_back;
};

typedef struct _xf86OutputFuncs {
    /**
     * Called to allow the output a chance to create properties after the
     * RandR objects have been created.
     */
    void
     (*create_resources) (xf86OutputPtr output);

    /**
     * Turns the output on/off, or sets intermediate power levels if available.
     *
     * Unsupported intermediate modes drop to the lower power setting.  If the
     * mode is DPMSModeOff, the output must be disabled, as the DPLL may be
     * disabled afterwards.
     */
    void
     (*dpms) (xf86OutputPtr output, int mode);

    /**
     * Saves the output's state for restoration on VT switch.
     */
    void
     (*save) (xf86OutputPtr output);

    /**
     * Restore's the output's state at VT switch.
     */
    void
     (*restore) (xf86OutputPtr output);

    /**
     * Callback for testing a video mode for a given output.
     *
     * This function should only check for cases where a mode can't be supported
     * on the output specifically, and not represent generic CRTC limitations.
     *
     * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
     */
    int
     (*mode_valid) (xf86OutputPtr output, DisplayModePtr pMode);

    /**
     * Callback to adjust the mode to be set in the CRTC.
     *
     * This allows an output to adjust the clock or even the entire set of
     * timings, which is used for panels with fixed timings or for
     * buses with clock limitations.
     */
    Bool
     (*mode_fixup) (xf86OutputPtr output,
                    DisplayModePtr mode, DisplayModePtr adjusted_mode);

    /**
     * Callback for preparing mode changes on an output
     */
    void
     (*prepare) (xf86OutputPtr output);

    /**
     * Callback for committing mode changes on an output
     */
    void
     (*commit) (xf86OutputPtr output);

    /**
     * Callback for setting up a video mode after fixups have been made.
     *
     * This is only called while the output is disabled.  The dpms callback
     * must be all that's necessary for the output, to turn the output on
     * after this function is called.
     */
    void
     (*mode_set) (xf86OutputPtr output,
                  DisplayModePtr mode, DisplayModePtr adjusted_mode);

    /**
     * Probe for a connected output, and return detect_status.
     */
     xf86OutputStatus(*detect) (xf86OutputPtr output);

    /**
     * Query the device for the modes it provides.
     *
     * This function may also update MonInfo, mm_width, and mm_height.
     *
     * \return singly-linked list of modes or NULL if no modes found.
     */
     DisplayModePtr(*get_modes) (xf86OutputPtr output);

#ifdef RANDR_12_INTERFACE
    /**
     * Callback when an output's property has changed.
     */
    Bool
     (*set_property) (xf86OutputPtr output,
                      Atom property, RRPropertyValuePtr value);
#endif
#ifdef RANDR_13_INTERFACE
    /**
     * Callback to get an updated property value
     */
    Bool
     (*get_property) (xf86OutputPtr output, Atom property);
#endif
#ifdef RANDR_GET_CRTC_INTERFACE
    /**
     * Callback to get current CRTC for a given output
     */
     xf86CrtcPtr(*get_crtc) (xf86OutputPtr output);
#endif
    /**
     * Clean up driver-specific bits of the output
     */
    void
     (*destroy) (xf86OutputPtr output);
} xf86OutputFuncsRec, *xf86OutputFuncsPtr;

#define XF86_OUTPUT_VERSION 3

struct _xf86Output {
    /**
     * ABI versioning
     */
    int version;

    /**
     * Associated ScrnInfo
     */
    ScrnInfoPtr scrn;

    /**
     * Currently connected crtc (if any)
     *
     * If this output is not in use, this field will be NULL.
     */
    xf86CrtcPtr crtc;

    /**
     * Possible CRTCs for this output as a mask of crtc indices
     */
    CARD32 possible_crtcs;

    /**
     * Possible outputs to share the same CRTC as a mask of output indices
     */
    CARD32 possible_clones;

    /**
     * Whether this output can support interlaced modes
     */
    Bool interlaceAllowed;

    /**
     * Whether this output can support double scan modes
     */
    Bool doubleScanAllowed;

    /**
     * List of available modes on this output.
     *
     * This should be the list from get_modes(), plus perhaps additional
     * compatible modes added later.
     */
    DisplayModePtr probed_modes;

    /**
     * Options parsed from the related monitor section
     */
    OptionInfoPtr options;

    /**
     * Configured monitor section
     */
    XF86ConfMonitorPtr conf_monitor;

    /**
     * Desired initial position
     */
    int initial_x, initial_y;

    /**
     * Desired initial rotation
     */
    Rotation initial_rotation;

    /**
     * Current connection status
     *
     * This indicates whether a monitor is known to be connected
     * to this output or not, or whether there is no way to tell
     */
    xf86OutputStatus status;

    /** EDID monitor information */
    xf86MonPtr MonInfo;

    /** subpixel order */
    int subpixel_order;

    /** Physical size of the currently attached output device. */
    int mm_width, mm_height;

    /** Output name */
    char *name;

    /** output-specific functions */
    const xf86OutputFuncsRec *funcs;

    /** driver private information */
    void *driver_private;

    /** Whether to use the old per-screen Monitor config section */
    Bool use_screen_monitor;

#ifdef RANDR_12_INTERFACE
    /**
     * RandR 1.2 output structure.
     *
     * When RandR 1.2 is available, this points at the associated
     * RandR output structure and is created when this output is created
     */
    RROutputPtr randr_output;
#else
    void *randr_output;
#endif
    /**
     * Desired initial panning
     * Added in ABI version 2
     */
    BoxRec initialTotalArea;
    BoxRec initialTrackingArea;
    INT16 initialBorder[4];

    struct xf86CrtcTileInfo tile_info;
};

typedef struct _xf86ProviderFuncs {
    /**
     * Called to allow the provider a chance to create properties after the
     * RandR objects have been created.
     */
    void
    (*create_resources) (ScrnInfoPtr scrn);

    /**
     * Callback when an provider's property has changed.
     */
    Bool
    (*set_property) (ScrnInfoPtr scrn,
                     Atom property, RRPropertyValuePtr value);

    /**
     * Callback to get an updated property value
     */
    Bool
    (*get_property) (ScrnInfoPtr provider, Atom property);

} xf86ProviderFuncsRec, *xf86ProviderFuncsPtr;

typedef struct _xf86CrtcConfigFuncs {
    /**
     * Requests that the driver resize the screen.
     *
     * The driver is responsible for updating scrn->virtualX and scrn->virtualY.
     * If the requested size cannot be set, the driver should leave those values
     * alone and return FALSE.
     *
     * A naive driver that cannot reallocate the screen may simply change
     * virtual[XY].  A more advanced driver will want to also change the
     * devPrivate.ptr and devKind of the screen pixmap, update any offscreen
     * pixmaps it may have moved, and change pScrn->displayWidth.
     */
    Bool
     (*resize) (ScrnInfoPtr scrn, int width, int height);
} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;

typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);

typedef struct _xf86CrtcConfig {
    int num_output;
    xf86OutputPtr *output;
    /**
     * compat_output is used whenever we deal
     * with legacy code that only understands a single
     * output. pScrn->modes will be loaded from this output,
     * adjust frame will whack this output, etc.
     */
    int compat_output;

    int num_crtc;
    xf86CrtcPtr *crtc;

    int minWidth, minHeight;
    int maxWidth, maxHeight;

    /* For crtc-based rotation */
    DamagePtr rotation_damage;
    Bool rotation_damage_registered;

    /* DGA */
    unsigned int dga_flags;
    unsigned long dga_address;
    DGAModePtr dga_modes;
    int dga_nmode;
    int dga_width, dga_height, dga_stride;
    DisplayModePtr dga_save_mode;

    const xf86CrtcConfigFuncsRec *funcs;

    CreateScreenResourcesProcPtr CreateScreenResources;

    CloseScreenProcPtr CloseScreen;

    /* Cursor information */
    xf86CursorInfoPtr cursor_info;
    CursorPtr cursor;
    CARD8 *cursor_image;
    Bool cursor_on;
    CARD32 cursor_fg, cursor_bg;

    /**
     * Options parsed from the related device section
     */
    OptionInfoPtr options;

    Bool debug_modes;

    /* wrap screen BlockHandler for rotation */
    ScreenBlockHandlerProcPtr BlockHandler;

    /* callback when crtc configuration changes */
    xf86_crtc_notify_proc_ptr xf86_crtc_notify;

    char *name;
    const xf86ProviderFuncsRec *provider_funcs;
#ifdef RANDR_12_INTERFACE
    RRProviderPtr randr_provider;
#else
    void *randr_provider;
#endif
} xf86CrtcConfigRec, *xf86CrtcConfigPtr;

extern _X_EXPORT int xf86CrtcConfigPrivateIndex;

#define XF86_CRTC_CONFIG_PTR(p)	((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))

static _X_INLINE xf86OutputPtr
xf86CompatOutput(ScrnInfoPtr pScrn)
{
    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);

    if (config->compat_output < 0)
        return NULL;
    return config->output[config->compat_output];
}

static _X_INLINE xf86CrtcPtr
xf86CompatCrtc(ScrnInfoPtr pScrn)
{
    xf86OutputPtr compat_output = xf86CompatOutput(pScrn);

    if (!compat_output)
        return NULL;
    return compat_output->crtc;
}

static _X_INLINE RRCrtcPtr
xf86CompatRRCrtc(ScrnInfoPtr pScrn)
{
    xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);

    if (!compat_crtc)
        return NULL;
    return compat_crtc->randr_crtc;
}

/*
 * Initialize xf86CrtcConfig structure
 */

extern _X_EXPORT void
 xf86CrtcConfigInit(ScrnInfoPtr scrn, const xf86CrtcConfigFuncsRec * funcs);

extern _X_EXPORT void

xf86CrtcSetSizeRange(ScrnInfoPtr scrn,
                     int minWidth, int minHeight, int maxWidth, int maxHeight);

/*
 * Crtc functions
 */
extern _X_EXPORT xf86CrtcPtr
xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs);

extern _X_EXPORT void
 xf86CrtcDestroy(xf86CrtcPtr crtc);

/**
 * Sets the given video mode on the given crtc
 */

extern _X_EXPORT Bool

xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode,
                         Rotation rotation, RRTransformPtr transform, int x,
                         int y);

extern _X_EXPORT Bool

xf86CrtcSetMode(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
                int x, int y);

extern _X_EXPORT void
 xf86CrtcSetOrigin(xf86CrtcPtr crtc, int x, int y);

/*
 * Assign crtc rotation during mode set
 */
extern _X_EXPORT Bool
 xf86CrtcRotate(xf86CrtcPtr crtc);

/*
 * Clean up any rotation data, used when a crtc is turned off
 * as well as when rotation is disabled.
 */
extern _X_EXPORT void
 xf86RotateDestroy(xf86CrtcPtr crtc);

/*
 * free shadow memory allocated for all crtcs
 */
extern _X_EXPORT void
 xf86RotateFreeShadow(ScrnInfoPtr pScrn);

/*
 * Clean up rotation during CloseScreen
 */
extern _X_EXPORT void
 xf86RotateCloseScreen(ScreenPtr pScreen);

/**
 * Return whether any output is assigned to the crtc
 */
extern _X_EXPORT Bool
 xf86CrtcInUse(xf86CrtcPtr crtc);

/*
 * Output functions
 */
extern _X_EXPORT xf86OutputPtr
xf86OutputCreate(ScrnInfoPtr scrn,
                 const xf86OutputFuncsRec * funcs, const char *name);

extern _X_EXPORT void
 xf86OutputUseScreenMonitor(xf86OutputPtr output, Bool use_screen_monitor);

extern _X_EXPORT Bool
 xf86OutputRename(xf86OutputPtr output, const char *name);

extern _X_EXPORT void
 xf86OutputDestroy(xf86OutputPtr output);

extern _X_EXPORT void
 xf86ProbeOutputModes(ScrnInfoPtr pScrn, int maxX, int maxY);

extern _X_EXPORT void
 xf86SetScrnInfoModes(ScrnInfoPtr pScrn);

#ifdef RANDR_13_INTERFACE
#define ScreenInitRetType	int
#else
#define ScreenInitRetType	Bool
#endif

extern _X_EXPORT ScreenInitRetType xf86CrtcScreenInit(ScreenPtr pScreen);

extern _X_EXPORT Bool
 xf86InitialConfiguration(ScrnInfoPtr pScrn, Bool canGrow);

extern _X_EXPORT void
 xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);

extern _X_EXPORT Bool
 xf86SaveScreen(ScreenPtr pScreen, int mode);

extern _X_EXPORT void
 xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);

extern _X_EXPORT DisplayModePtr
xf86OutputFindClosestMode(xf86OutputPtr output, DisplayModePtr desired);

extern _X_EXPORT Bool

xf86SetSingleMode(ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);

/**
 * Set the EDID information for the specified output
 */
extern _X_EXPORT void
 xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon);

/**
 * Set the TILE information for the specified output
 */
extern _X_EXPORT void
xf86OutputSetTile(xf86OutputPtr output, struct xf86CrtcTileInfo *tile_info);

extern _X_EXPORT Bool
xf86OutputParseKMSTile(const char *tile_data, int tile_length, struct xf86CrtcTileInfo *tile_info);

/**
 * Return the list of modes supported by the EDID information
 * stored in 'output'
 */
extern _X_EXPORT DisplayModePtr xf86OutputGetEDIDModes(xf86OutputPtr output);

extern _X_EXPORT xf86MonPtr
xf86OutputGetEDID(xf86OutputPtr output, I2CBusPtr pDDCBus);

/**
 * Initialize dga for this screen
 */

#ifdef XFreeXDGA
extern _X_EXPORT Bool
 xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address);

/* this is the real function, used only internally */
_X_INTERNAL Bool
 _xf86_di_dga_init_internal(ScreenPtr pScreen);

/**
 * Re-initialize dga for this screen (as when the set of modes changes)
 */

extern _X_EXPORT Bool
 xf86DiDGAReInit(ScreenPtr pScreen);
#endif

/* This is the real function, used only internally */
_X_INTERNAL Bool
 _xf86_di_dga_reinit_internal(ScreenPtr pScreen);

/*
 * Set the subpixel order reported for the screen using
 * the information from the outputs
 */

extern _X_EXPORT void
 xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen);

/*
 * Get a standard string name for a connector type
 */
extern _X_EXPORT const char *xf86ConnectorGetName(xf86ConnectorType connector);

/*
 * Using the desired mode information in each crtc, set
 * modes (used in EnterVT functions, or at server startup)
 */

extern _X_EXPORT Bool
 xf86SetDesiredModes(ScrnInfoPtr pScrn);

/**
 * Initialize the CRTC-based cursor code. CRTC function vectors must
 * contain relevant cursor setting functions.
 *
 * Driver should call this from ScreenInit function
 */
extern _X_EXPORT Bool
 xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags);

/**
 * Superseeded by xf86CursorResetCursor, which is getting called
 * automatically when necessary.
 */
static _X_INLINE _X_DEPRECATED void xf86_reload_cursors(ScreenPtr screen) {}

/**
 * Called from EnterVT to turn the cursors back on
 */
extern _X_EXPORT void
 xf86_show_cursors(ScrnInfoPtr scrn);

/**
 * Called by the driver to turn cursors off
 */
extern _X_EXPORT void
 xf86_hide_cursors(ScrnInfoPtr scrn);

/**
 * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
 */
extern _X_EXPORT void
 xf86_cursors_fini(ScreenPtr screen);

#ifdef XV
/*
 * For overlay video, compute the relevant CRTC and
 * clip video to that.
 * wraps xf86XVClipVideoHelper()
 */

extern _X_EXPORT Bool

xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
                            xf86CrtcPtr * crtc_ret,
                            xf86CrtcPtr desired_crtc,
                            BoxPtr dst,
                            INT32 *xa,
                            INT32 *xb,
                            INT32 *ya,
                            INT32 *yb,
                            RegionPtr reg, INT32 width, INT32 height);
#endif

extern _X_EXPORT xf86_crtc_notify_proc_ptr
xf86_wrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);

extern _X_EXPORT void
 xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old);

extern _X_EXPORT void
 xf86_crtc_notify(ScreenPtr pScreen);

/**
 * Gamma
 */

extern _X_EXPORT Bool
 xf86_crtc_supports_gamma(ScrnInfoPtr pScrn);

extern _X_EXPORT void
xf86ProviderSetup(ScrnInfoPtr scrn,
                  const xf86ProviderFuncsRec * funcs, const char *name);

extern _X_EXPORT void
xf86DetachAllCrtc(ScrnInfoPtr scrn);

#endif                          /* _XF86CRTC_H_ */