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