3b1e7e99555ac5656bc97ef32bdf780973629d5b
[framework/uifw/xorg/server/xorg-server.git] / hw / xfree86 / modes / xf86Crtc.h
1 /*
2  * Copyright © 2006 Keith Packard
3  * Copyright © 2011 Aaron Plattner
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and its
6  * documentation for any purpose is hereby granted without fee, provided that
7  * the above copyright notice appear in all copies and that both that copyright
8  * notice and this permission notice appear in supporting documentation, and
9  * that the name of the copyright holders not be used in advertising or
10  * publicity pertaining to distribution of the software without specific,
11  * written prior permission.  The copyright holders make no representations
12  * about the suitability of this software for any purpose.  It is provided "as
13  * is" without express or implied warranty.
14  *
15  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21  * OF THIS SOFTWARE.
22  */
23 #ifndef _XF86CRTC_H_
24 #define _XF86CRTC_H_
25
26 #include <edid.h>
27 #include "randrstr.h"
28 #include "xf86Modes.h"
29 #include "xf86Cursor.h"
30 #include "xf86i2c.h"
31 #include "damage.h"
32 #include "picturestr.h"
33
34 /* Compat definitions for older X Servers. */
35 #ifndef M_T_PREFERRED
36 #define M_T_PREFERRED   0x08
37 #endif
38 #ifndef M_T_DRIVER
39 #define M_T_DRIVER      0x40
40 #endif
41 #ifndef M_T_USERPREF
42 #define M_T_USERPREF    0x80
43 #endif
44 #ifndef HARDWARE_CURSOR_ARGB
45 #define HARDWARE_CURSOR_ARGB                            0x00004000
46 #endif
47
48 typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
49 typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
50
51 /* define a standard for connector types */
52 typedef enum _xf86ConnectorType {
53     XF86ConnectorNone,
54     XF86ConnectorVGA,
55     XF86ConnectorDVI_I,
56     XF86ConnectorDVI_D,
57     XF86ConnectorDVI_A,
58     XF86ConnectorComposite,
59     XF86ConnectorSvideo,
60     XF86ConnectorComponent,
61     XF86ConnectorLFP,
62     XF86ConnectorProprietary,
63     XF86ConnectorHDMI,
64     XF86ConnectorDisplayPort,
65 } xf86ConnectorType;
66
67 typedef enum _xf86OutputStatus {
68     XF86OutputStatusConnected,
69     XF86OutputStatusDisconnected,
70     XF86OutputStatusUnknown
71 } xf86OutputStatus;
72
73 typedef struct _xf86CrtcFuncs {
74    /**
75     * Turns the crtc on/off, or sets intermediate power levels if available.
76     *
77     * Unsupported intermediate modes drop to the lower power setting.  If the
78     * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
79     * be safe to call mode_set.
80     */
81     void
82      (*dpms) (xf86CrtcPtr crtc, int mode);
83
84    /**
85     * Saves the crtc's state for restoration on VT switch.
86     */
87     void
88      (*save) (xf86CrtcPtr crtc);
89
90    /**
91     * Restore's the crtc's state at VT switch.
92     */
93     void
94      (*restore) (xf86CrtcPtr crtc);
95
96     /**
97      * Lock CRTC prior to mode setting, mostly for DRI.
98      * Returns whether unlock is needed
99      */
100     Bool
101      (*lock) (xf86CrtcPtr crtc);
102
103     /**
104      * Unlock CRTC after mode setting, mostly for DRI
105      */
106     void
107      (*unlock) (xf86CrtcPtr crtc);
108
109     /**
110      * Callback to adjust the mode to be set in the CRTC.
111      *
112      * This allows a CRTC to adjust the clock or even the entire set of
113      * timings, which is used for panels with fixed timings or for
114      * buses with clock limitations.
115      */
116     Bool
117      (*mode_fixup) (xf86CrtcPtr crtc,
118                     DisplayModePtr mode, DisplayModePtr adjusted_mode);
119
120     /**
121      * Prepare CRTC for an upcoming mode set.
122      */
123     void
124      (*prepare) (xf86CrtcPtr crtc);
125
126     /**
127      * Callback for setting up a video mode after fixups have been made.
128      */
129     void
130      (*mode_set) (xf86CrtcPtr crtc,
131                   DisplayModePtr mode,
132                   DisplayModePtr adjusted_mode, int x, int y);
133
134     /**
135      * Commit mode changes to a CRTC
136      */
137     void
138      (*commit) (xf86CrtcPtr crtc);
139
140     /* Set the color ramps for the CRTC to the given values. */
141     void
142      (*gamma_set) (xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
143                    int size);
144
145     /**
146      * Allocate the shadow area, delay the pixmap creation until needed
147      */
148     void *(*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);
149
150     /**
151      * Create shadow pixmap for rotation support
152      */
153     PixmapPtr
154      (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);
155
156     /**
157      * Destroy shadow pixmap
158      */
159     void
160      (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
161
162     /**
163      * Set cursor colors
164      */
165     void
166      (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
167
168     /**
169      * Set cursor position
170      */
171     void
172      (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
173
174     /**
175      * Show cursor
176      */
177     void
178      (*show_cursor) (xf86CrtcPtr crtc);
179
180     /**
181      * Hide cursor
182      */
183     void
184      (*hide_cursor) (xf86CrtcPtr crtc);
185
186     /**
187      * Load monochrome image
188      */
189     void
190      (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
191     Bool
192      (*load_cursor_image_check) (xf86CrtcPtr crtc, CARD8 *image);
193
194     /**
195      * Load ARGB image
196      */
197     void
198      (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
199     Bool
200      (*load_cursor_argb_check) (xf86CrtcPtr crtc, CARD32 *image);
201
202     /**
203      * Clean up driver-specific bits of the crtc
204      */
205     void
206      (*destroy) (xf86CrtcPtr crtc);
207
208     /**
209      * Less fine-grained mode setting entry point for kernel modesetting
210      */
211     Bool
212      (*set_mode_major) (xf86CrtcPtr crtc, DisplayModePtr mode,
213                         Rotation rotation, int x, int y);
214
215     /**
216      * Callback for panning. Doesn't change the mode.
217      * Added in ABI version 2
218      */
219     void
220      (*set_origin) (xf86CrtcPtr crtc, int x, int y);
221
222     /**
223      */
224     Bool
225     (*set_scanout_pixmap)(xf86CrtcPtr crtc, PixmapPtr pixmap);
226
227 } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
228
229 #define XF86_CRTC_VERSION 5
230
231 struct _xf86Crtc {
232     /**
233      * ABI versioning
234      */
235     int version;
236
237     /**
238      * Associated ScrnInfo
239      */
240     ScrnInfoPtr scrn;
241
242     /**
243      * Desired state of this CRTC
244      *
245      * Set when this CRTC should be driving one or more outputs
246      */
247     Bool enabled;
248
249     /**
250      * Active mode
251      *
252      * This reflects the mode as set in the CRTC currently
253      * It will be cleared when the VT is not active or
254      * during server startup
255      */
256     DisplayModeRec mode;
257     Rotation rotation;
258     PixmapPtr rotatedPixmap;
259     void *rotatedData;
260
261     /**
262      * Position on screen
263      *
264      * Locates this CRTC within the frame buffer
265      */
266     int x, y;
267
268     /**
269      * Desired mode
270      *
271      * This is set to the requested mode, independent of
272      * whether the VT is active. In particular, it receives
273      * the startup configured mode and saves the active mode
274      * on VT switch.
275      */
276     DisplayModeRec desiredMode;
277     Rotation desiredRotation;
278     int desiredX, desiredY;
279
280     /** crtc-specific functions */
281     const xf86CrtcFuncsRec *funcs;
282
283     /**
284      * Driver private
285      *
286      * Holds driver-private information
287      */
288     void *driver_private;
289
290 #ifdef RANDR_12_INTERFACE
291     /**
292      * RandR crtc
293      *
294      * When RandR 1.2 is available, this
295      * points at the associated crtc object
296      */
297     RRCrtcPtr randr_crtc;
298 #else
299     void *randr_crtc;
300 #endif
301
302     /**
303      * Current cursor is ARGB
304      */
305     Bool cursor_argb;
306     /**
307      * Track whether cursor is within CRTC range
308      */
309     Bool cursor_in_range;
310     /**
311      * Track state of cursor associated with this CRTC
312      */
313     Bool cursor_shown;
314
315     /**
316      * Current transformation matrix
317      */
318     PictTransform crtc_to_framebuffer;
319     /* framebuffer_to_crtc was removed in ABI 2 */
320     struct pict_f_transform f_crtc_to_framebuffer;      /* ABI 2 */
321     struct pict_f_transform f_framebuffer_to_crtc;      /* ABI 2 */
322     PictFilterPtr filter;       /* ABI 2 */
323     xFixed *params;             /* ABI 2 */
324     int nparams;                /* ABI 2 */
325     int filter_width;           /* ABI 2 */
326     int filter_height;          /* ABI 2 */
327     Bool transform_in_use;
328     RRTransformRec transform;   /* ABI 2 */
329     Bool transformPresent;      /* ABI 2 */
330     RRTransformRec desiredTransform;    /* ABI 2 */
331     Bool desiredTransformPresent;       /* ABI 2 */
332     /**
333      * Bounding box in screen space
334      */
335     BoxRec bounds;
336     /**
337      * Panning:
338      * TotalArea: total panning area, larger than CRTC's size
339      * TrackingArea: Area of the pointer for which the CRTC is panned
340      * border: Borders of the displayed CRTC area which induces panning if the pointer reaches them
341      * Added in ABI version 2
342      */
343     BoxRec panningTotalArea;
344     BoxRec panningTrackingArea;
345     INT16 panningBorder[4];
346
347     /**
348      * Current gamma, especially useful after initial config.
349      * Added in ABI version 3
350      */
351     CARD16 *gamma_red;
352     CARD16 *gamma_green;
353     CARD16 *gamma_blue;
354     int gamma_size;
355
356     /**
357      * Actual state of this CRTC
358      *
359      * Set to TRUE after modesetting, set to FALSE if no outputs are connected
360      * Added in ABI version 3
361      */
362     Bool active;
363     /**
364      * Clear the shadow
365      */
366     Bool shadowClear;
367
368     /**
369      * Indicates that the driver is handling the transform, so the shadow
370      * surface should be disabled.  The driver writes this field before calling
371      * xf86CrtcRotate to indicate that it is handling the transform (including
372      * rotation and reflection).
373      *
374      * Setting this flag also causes the server to stop adjusting the cursor
375      * image and position.
376      *
377      * Added in ABI version 4
378      */
379     Bool driverIsPerformingTransform;
380
381     /* Added in ABI version 5
382      */
383     PixmapPtr current_scanout;
384 };
385
386 typedef struct _xf86OutputFuncs {
387     /**
388      * Called to allow the output a chance to create properties after the
389      * RandR objects have been created.
390      */
391     void
392      (*create_resources) (xf86OutputPtr output);
393
394     /**
395      * Turns the output on/off, or sets intermediate power levels if available.
396      *
397      * Unsupported intermediate modes drop to the lower power setting.  If the
398      * mode is DPMSModeOff, the output must be disabled, as the DPLL may be
399      * disabled afterwards.
400      */
401     void
402      (*dpms) (xf86OutputPtr output, int mode);
403
404     /**
405      * Saves the output's state for restoration on VT switch.
406      */
407     void
408      (*save) (xf86OutputPtr output);
409
410     /**
411      * Restore's the output's state at VT switch.
412      */
413     void
414      (*restore) (xf86OutputPtr output);
415
416     /**
417      * Callback for testing a video mode for a given output.
418      *
419      * This function should only check for cases where a mode can't be supported
420      * on the output specifically, and not represent generic CRTC limitations.
421      *
422      * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
423      */
424     int
425      (*mode_valid) (xf86OutputPtr output, DisplayModePtr pMode);
426
427     /**
428      * Callback to adjust the mode to be set in the CRTC.
429      *
430      * This allows an output to adjust the clock or even the entire set of
431      * timings, which is used for panels with fixed timings or for
432      * buses with clock limitations.
433      */
434     Bool
435      (*mode_fixup) (xf86OutputPtr output,
436                     DisplayModePtr mode, DisplayModePtr adjusted_mode);
437
438     /**
439      * Callback for preparing mode changes on an output
440      */
441     void
442      (*prepare) (xf86OutputPtr output);
443
444     /**
445      * Callback for committing mode changes on an output
446      */
447     void
448      (*commit) (xf86OutputPtr output);
449
450     /**
451      * Callback for setting up a video mode after fixups have been made.
452      *
453      * This is only called while the output is disabled.  The dpms callback
454      * must be all that's necessary for the output, to turn the output on
455      * after this function is called.
456      */
457     void
458      (*mode_set) (xf86OutputPtr output,
459                   DisplayModePtr mode, DisplayModePtr adjusted_mode);
460
461     /**
462      * Probe for a connected output, and return detect_status.
463      */
464      xf86OutputStatus(*detect) (xf86OutputPtr output);
465
466     /**
467      * Query the device for the modes it provides.
468      *
469      * This function may also update MonInfo, mm_width, and mm_height.
470      *
471      * \return singly-linked list of modes or NULL if no modes found.
472      */
473      DisplayModePtr(*get_modes) (xf86OutputPtr output);
474
475 #ifdef RANDR_12_INTERFACE
476     /**
477      * Callback when an output's property has changed.
478      */
479     Bool
480      (*set_property) (xf86OutputPtr output,
481                       Atom property, RRPropertyValuePtr value);
482 #endif
483 #ifdef RANDR_13_INTERFACE
484     /**
485      * Callback to get an updated property value
486      */
487     Bool
488      (*get_property) (xf86OutputPtr output, Atom property);
489 #endif
490 #ifdef RANDR_GET_CRTC_INTERFACE
491     /**
492      * Callback to get current CRTC for a given output
493      */
494      xf86CrtcPtr(*get_crtc) (xf86OutputPtr output);
495 #endif
496     /**
497      * Clean up driver-specific bits of the output
498      */
499     void
500      (*destroy) (xf86OutputPtr output);
501
502 //#ifdef _F_STEREOSCOPIC_SEND_FBSIZE_TO_WM_
503
504     /**
505     * Gets the expected width & height of framebuffer after stereo mode setting
506     **/
507      void (*get_stereo_buffer_size)(xf86OutputPtr output, int planeID,
508           short* width, short* height);
509
510     /**
511     * Gets the geometry of drawing rectangle after stereo mode setting
512     **/
513      void (*get_drawing_rect)(xf86OutputPtr output, int planeID,
514            DrawRect* rect[RECT_MAX]);
515 //#endif
516 } xf86OutputFuncsRec, *xf86OutputFuncsPtr;
517
518 #define XF86_OUTPUT_VERSION 2
519
520 struct _xf86Output {
521     /**
522      * ABI versioning
523      */
524     int version;
525
526     /**
527      * Associated ScrnInfo
528      */
529     ScrnInfoPtr scrn;
530
531     /**
532      * Currently connected crtc (if any)
533      *
534      * If this output is not in use, this field will be NULL.
535      */
536     xf86CrtcPtr crtc;
537
538     /**
539      * Possible CRTCs for this output as a mask of crtc indices
540      */
541     CARD32 possible_crtcs;
542
543     /**
544      * Possible outputs to share the same CRTC as a mask of output indices
545      */
546     CARD32 possible_clones;
547
548     /**
549      * Whether this output can support interlaced modes
550      */
551     Bool interlaceAllowed;
552
553     /**
554      * Whether this output can support double scan modes
555      */
556     Bool doubleScanAllowed;
557
558     /**
559      * List of available modes on this output.
560      *
561      * This should be the list from get_modes(), plus perhaps additional
562      * compatible modes added later.
563      */
564     DisplayModePtr probed_modes;
565
566     /**
567      * Options parsed from the related monitor section
568      */
569     OptionInfoPtr options;
570
571     /**
572      * Configured monitor section
573      */
574     XF86ConfMonitorPtr conf_monitor;
575
576     /**
577      * Desired initial position
578      */
579     int initial_x, initial_y;
580
581     /**
582      * Desired initial rotation
583      */
584     Rotation initial_rotation;
585
586     /**
587      * Current connection status
588      *
589      * This indicates whether a monitor is known to be connected
590      * to this output or not, or whether there is no way to tell
591      */
592     xf86OutputStatus status;
593
594     /** EDID monitor information */
595     xf86MonPtr MonInfo;
596
597     /** subpixel order */
598     int subpixel_order;
599
600     /** Physical size of the currently attached output device. */
601     int mm_width, mm_height;
602
603     /** Output name */
604     char *name;
605
606     /** output-specific functions */
607     const xf86OutputFuncsRec *funcs;
608
609     /** driver private information */
610     void *driver_private;
611
612     /** Whether to use the old per-screen Monitor config section */
613     Bool use_screen_monitor;
614
615 #ifdef RANDR_12_INTERFACE
616     /**
617      * RandR 1.2 output structure.
618      *
619      * When RandR 1.2 is available, this points at the associated
620      * RandR output structure and is created when this output is created
621      */
622     RROutputPtr randr_output;
623 #else
624     void *randr_output;
625 #endif
626     /**
627      * Desired initial panning
628      * Added in ABI version 2
629      */
630     BoxRec initialTotalArea;
631     BoxRec initialTrackingArea;
632     INT16 initialBorder[4];
633 };
634
635 typedef struct _xf86ProviderFuncs {
636     /**
637      * Called to allow the provider a chance to create properties after the
638      * RandR objects have been created.
639      */
640     void
641     (*create_resources) (ScrnInfoPtr scrn);
642
643     /**
644      * Callback when an provider's property has changed.
645      */
646     Bool
647     (*set_property) (ScrnInfoPtr scrn,
648                      Atom property, RRPropertyValuePtr value);
649
650     /**
651      * Callback to get an updated property value
652      */
653     Bool
654     (*get_property) (ScrnInfoPtr provider, Atom property);
655
656 } xf86ProviderFuncsRec, *xf86ProviderFuncsPtr;
657
658 typedef struct _xf86CrtcConfigFuncs {
659     /**
660      * Requests that the driver resize the screen.
661      *
662      * The driver is responsible for updating scrn->virtualX and scrn->virtualY.
663      * If the requested size cannot be set, the driver should leave those values
664      * alone and return FALSE.
665      *
666      * A naive driver that cannot reallocate the screen may simply change
667      * virtual[XY].  A more advanced driver will want to also change the
668      * devPrivate.ptr and devKind of the screen pixmap, update any offscreen
669      * pixmaps it may have moved, and change pScrn->displayWidth.
670      */
671     Bool
672      (*resize) (ScrnInfoPtr scrn, int width, int height);
673 } xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;
674
675 typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);
676
677 typedef struct _xf86CrtcConfig {
678     int num_output;
679     xf86OutputPtr *output;
680     /**
681      * compat_output is used whenever we deal
682      * with legacy code that only understands a single
683      * output. pScrn->modes will be loaded from this output,
684      * adjust frame will whack this output, etc.
685      */
686     int compat_output;
687
688     int num_crtc;
689     xf86CrtcPtr *crtc;
690
691     int minWidth, minHeight;
692     int maxWidth, maxHeight;
693
694     /* For crtc-based rotation */
695     DamagePtr rotation_damage;
696     Bool rotation_damage_registered;
697
698     /* DGA */
699     unsigned int dga_flags;
700     unsigned long dga_address;
701     DGAModePtr dga_modes;
702     int dga_nmode;
703     int dga_width, dga_height, dga_stride;
704     DisplayModePtr dga_save_mode;
705
706     const xf86CrtcConfigFuncsRec *funcs;
707
708     CreateScreenResourcesProcPtr CreateScreenResources;
709
710     CloseScreenProcPtr CloseScreen;
711
712     /* Cursor information */
713     xf86CursorInfoPtr cursor_info;
714     CursorPtr cursor;
715     CARD8 *cursor_image;
716     Bool cursor_on;
717     CARD32 cursor_fg, cursor_bg;
718
719     /**
720      * Options parsed from the related device section
721      */
722     OptionInfoPtr options;
723
724     Bool debug_modes;
725
726     /* wrap screen BlockHandler for rotation */
727     ScreenBlockHandlerProcPtr BlockHandler;
728
729     /* callback when crtc configuration changes */
730     xf86_crtc_notify_proc_ptr xf86_crtc_notify;
731
732     char *name;
733     const xf86ProviderFuncsRec *provider_funcs;
734 #ifdef RANDR_12_INTERFACE
735     RRProviderPtr randr_provider;
736 #else
737     void *randr_provider;
738 #endif
739 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
740
741 extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
742
743 #define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
744
745 static _X_INLINE xf86OutputPtr
746 xf86CompatOutput(ScrnInfoPtr pScrn)
747 {
748     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
749
750     return config->output[config->compat_output];
751 }
752
753 static _X_INLINE xf86CrtcPtr
754 xf86CompatCrtc(ScrnInfoPtr pScrn)
755 {
756     xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
757
758     if (!compat_output)
759         return NULL;
760     return compat_output->crtc;
761 }
762
763 static _X_INLINE RRCrtcPtr
764 xf86CompatRRCrtc(ScrnInfoPtr pScrn)
765 {
766     xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
767
768     if (!compat_crtc)
769         return NULL;
770     return compat_crtc->randr_crtc;
771 }
772
773 /*
774  * Initialize xf86CrtcConfig structure
775  */
776
777 extern _X_EXPORT void
778  xf86CrtcConfigInit(ScrnInfoPtr scrn, const xf86CrtcConfigFuncsRec * funcs);
779
780 extern _X_EXPORT void
781
782 xf86CrtcSetSizeRange(ScrnInfoPtr scrn,
783                      int minWidth, int minHeight, int maxWidth, int maxHeight);
784
785 /*
786  * Crtc functions
787  */
788 extern _X_EXPORT xf86CrtcPtr
789 xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs);
790
791 extern _X_EXPORT void
792  xf86CrtcDestroy(xf86CrtcPtr crtc);
793
794 /**
795  * Sets the given video mode on the given crtc
796  */
797
798 extern _X_EXPORT Bool
799
800 xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode,
801                          Rotation rotation, RRTransformPtr transform, int x,
802                          int y);
803
804 extern _X_EXPORT Bool
805
806 xf86CrtcSetMode(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
807                 int x, int y);
808
809 extern _X_EXPORT void
810  xf86CrtcSetOrigin(xf86CrtcPtr crtc, int x, int y);
811
812 /*
813  * Assign crtc rotation during mode set
814  */
815 extern _X_EXPORT Bool
816  xf86CrtcRotate(xf86CrtcPtr crtc);
817
818 /*
819  * Clean up any rotation data, used when a crtc is turned off
820  * as well as when rotation is disabled.
821  */
822 extern _X_EXPORT void
823  xf86RotateDestroy(xf86CrtcPtr crtc);
824
825 /*
826  * free shadow memory allocated for all crtcs
827  */
828 extern _X_EXPORT void
829  xf86RotateFreeShadow(ScrnInfoPtr pScrn);
830
831 /*
832  * Clean up rotation during CloseScreen
833  */
834 extern _X_EXPORT void
835  xf86RotateCloseScreen(ScreenPtr pScreen);
836
837 /**
838  * Return whether any output is assigned to the crtc
839  */
840 extern _X_EXPORT Bool
841  xf86CrtcInUse(xf86CrtcPtr crtc);
842
843 /*
844  * Output functions
845  */
846 extern _X_EXPORT xf86OutputPtr
847 xf86OutputCreate(ScrnInfoPtr scrn,
848                  const xf86OutputFuncsRec * funcs, const char *name);
849
850 extern _X_EXPORT void
851  xf86OutputUseScreenMonitor(xf86OutputPtr output, Bool use_screen_monitor);
852
853 extern _X_EXPORT Bool
854  xf86OutputRename(xf86OutputPtr output, const char *name);
855
856 extern _X_EXPORT void
857  xf86OutputDestroy(xf86OutputPtr output);
858
859 extern _X_EXPORT void
860  xf86ProbeOutputModes(ScrnInfoPtr pScrn, int maxX, int maxY);
861
862 extern _X_EXPORT void
863  xf86SetScrnInfoModes(ScrnInfoPtr pScrn);
864
865 #ifdef RANDR_13_INTERFACE
866 #define ScreenInitRetType       int
867 #else
868 #define ScreenInitRetType       Bool
869 #endif
870
871 extern _X_EXPORT ScreenInitRetType xf86CrtcScreenInit(ScreenPtr pScreen);
872
873 extern _X_EXPORT Bool
874  xf86InitialConfiguration(ScrnInfoPtr pScrn, Bool canGrow);
875
876 extern _X_EXPORT void
877  xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
878
879 extern _X_EXPORT Bool
880  xf86SaveScreen(ScreenPtr pScreen, int mode);
881
882 //#ifdef _F_XF86_DISABLE_UNUSED_FUNC_RESCHANGE_
883 extern _X_EXPORT void
884 xf86DisableUnusedFunctionsResChange(ScrnInfoPtr pScrn, Bool is_res_change);
885 //#endif
886
887 extern _X_EXPORT void
888  xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
889
890 extern _X_EXPORT DisplayModePtr
891 xf86OutputFindClosestMode(xf86OutputPtr output, DisplayModePtr desired);
892
893 extern _X_EXPORT Bool
894
895 xf86SetSingleMode(ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
896
897 /**
898  * Set the EDID information for the specified output
899  */
900 extern _X_EXPORT void
901  xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon);
902
903 /**
904  * Return the list of modes supported by the EDID information
905  * stored in 'output'
906  */
907 extern _X_EXPORT DisplayModePtr xf86OutputGetEDIDModes(xf86OutputPtr output);
908
909 extern _X_EXPORT xf86MonPtr
910 xf86OutputGetEDID(xf86OutputPtr output, I2CBusPtr pDDCBus);
911
912 /**
913  * Initialize dga for this screen
914  */
915
916 #ifdef XFreeXDGA
917 extern _X_EXPORT Bool
918  xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address);
919
920 /* this is the real function, used only internally */
921 _X_INTERNAL Bool
922  _xf86_di_dga_init_internal(ScreenPtr pScreen);
923
924 /**
925  * Re-initialize dga for this screen (as when the set of modes changes)
926  */
927
928 extern _X_EXPORT Bool
929  xf86DiDGAReInit(ScreenPtr pScreen);
930 #endif
931
932 /* This is the real function, used only internally */
933 _X_INTERNAL Bool
934  _xf86_di_dga_reinit_internal(ScreenPtr pScreen);
935
936 /*
937  * Set the subpixel order reported for the screen using
938  * the information from the outputs
939  */
940
941 extern _X_EXPORT void
942  xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen);
943
944 /*
945  * Get a standard string name for a connector type
946  */
947 extern _X_EXPORT const char *xf86ConnectorGetName(xf86ConnectorType connector);
948
949 /*
950  * Using the desired mode information in each crtc, set
951  * modes (used in EnterVT functions, or at server startup)
952  */
953
954 extern _X_EXPORT Bool
955  xf86SetDesiredModes(ScrnInfoPtr pScrn);
956
957 /**
958  * Initialize the CRTC-based cursor code. CRTC function vectors must
959  * contain relevant cursor setting functions.
960  *
961  * Driver should call this from ScreenInit function
962  */
963 extern _X_EXPORT Bool
964  xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags);
965
966 /**
967  * Called when anything on the screen is reconfigured.
968  *
969  * Reloads cursor images as needed, then adjusts cursor positions.
970  *
971  * Driver should call this from crtc commit function.
972  */
973 extern _X_EXPORT void
974  xf86_reload_cursors(ScreenPtr screen);
975
976 /**
977  * Called from EnterVT to turn the cursors back on
978  */
979 extern _X_EXPORT void
980  xf86_show_cursors(ScrnInfoPtr scrn);
981
982 /**
983  * Called by the driver to turn cursors off
984  */
985 extern _X_EXPORT void
986  xf86_hide_cursors(ScrnInfoPtr scrn);
987
988 /**
989  * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
990  */
991 extern _X_EXPORT void
992  xf86_cursors_fini(ScreenPtr screen);
993
994 /**
995  * Transform the cursor's coordinates based on the crtc transform.  Normally
996  * this is done by the server, but if crtc->driverIsPerformingTransform is TRUE,
997  * then the server does not transform the cursor position automatically.
998  */
999 extern _X_EXPORT void
1000  xf86CrtcTransformCursorPos(xf86CrtcPtr crtc, int *x, int *y);
1001
1002 #ifdef XV
1003 /*
1004  * For overlay video, compute the relevant CRTC and
1005  * clip video to that.
1006  * wraps xf86XVClipVideoHelper()
1007  */
1008
1009 extern _X_EXPORT Bool
1010
1011 xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
1012                             xf86CrtcPtr * crtc_ret,
1013                             xf86CrtcPtr desired_crtc,
1014                             BoxPtr dst,
1015                             INT32 *xa,
1016                             INT32 *xb,
1017                             INT32 *ya,
1018                             INT32 *yb,
1019                             RegionPtr reg, INT32 width, INT32 height);
1020 #endif
1021
1022 extern _X_EXPORT xf86_crtc_notify_proc_ptr
1023 xf86_wrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
1024
1025 extern _X_EXPORT void
1026  xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old);
1027
1028 extern _X_EXPORT void
1029  xf86_crtc_notify(ScreenPtr pScreen);
1030
1031 /**
1032  * Gamma
1033  */
1034
1035 extern _X_EXPORT Bool
1036  xf86_crtc_supports_gamma(ScrnInfoPtr pScrn);
1037
1038 extern _X_EXPORT void
1039 xf86ProviderSetup(ScrnInfoPtr scrn,
1040                   const xf86ProviderFuncsRec * funcs, const char *name);
1041
1042 extern _X_EXPORT void
1043 xf86DetachAllCrtc(ScrnInfoPtr scrn);
1044
1045 #endif                          /* _XF86CRTC_H_ */