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