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