1/*
2 * Copyright © 2000 Compaq Computer Corporation
3 * Copyright © 2002 Hewlett-Packard Company
4 * Copyright © 2006 Intel Corporation
5 * Copyright © 2008 Red Hat, Inc.
6 *
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that copyright
10 * notice and this permission notice appear in supporting documentation, and
11 * that the name of the copyright holders not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission.  The copyright holders make no representations
14 * about the suitability of this software for any purpose.  It is provided "as
15 * is" without express or implied warranty.
16 *
17 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 * OF THIS SOFTWARE.
24 *
25 * Author:  Jim Gettys, Hewlett-Packard Company, Inc.
26 *	    Keith Packard, Intel Corporation
27 */
28
29#ifdef HAVE_DIX_CONFIG_H
30#include <dix-config.h>
31#endif
32
33#ifndef _RANDRSTR_H_
34#define _RANDRSTR_H_
35
36#include <X11/X.h>
37#include <X11/Xproto.h>
38#include "misc.h"
39#include "os.h"
40#include "dixstruct.h"
41#include "resource.h"
42#include "scrnintstr.h"
43#include "windowstr.h"
44#include "pixmapstr.h"
45#include "extnsionst.h"
46#include "servermd.h"
47#include "rrtransform.h"
48#include <X11/extensions/randr.h>
49#include <X11/extensions/randrproto.h>
50#include <X11/extensions/render.h>      /* we share subpixel order information */
51#include "picturestr.h"
52#include <X11/Xfuncproto.h>
53
54/* required for ABI compatibility for now */
55#define RANDR_10_INTERFACE 1
56#define RANDR_12_INTERFACE 1
57#define RANDR_13_INTERFACE 1    /* requires RANDR_12_INTERFACE */
58#define RANDR_GET_CRTC_INTERFACE 1
59
60#define RANDR_INTERFACE_VERSION 0x0104
61
62/* All also defined in <X11/extensions/randrproto.h> */
63#ifndef RROutput
64#define RROutput CARD32
65#define RRMode CARD32
66#define RRCrtc CARD32
67#define RRProvider CARD32
68#define RRModeFlags CARD32
69#define RRLease CARD32
70#endif
71
72extern int RREventBase, RRErrorBase;
73
74extern int (*ProcRandrVector[RRNumberRequests]) (ClientPtr);
75extern int (*SProcRandrVector[RRNumberRequests]) (ClientPtr);
76
77/*
78 * Modeline for a monitor. Name follows directly after this struct
79 */
80
81#define RRModeName(pMode) ((char *) (pMode + 1))
82typedef struct _rrMode RRModeRec, *RRModePtr;
83typedef struct _rrPropertyValue RRPropertyValueRec, *RRPropertyValuePtr;
84typedef struct _rrProperty RRPropertyRec, *RRPropertyPtr;
85typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr;
86typedef struct _rrOutput RROutputRec, *RROutputPtr;
87typedef struct _rrProvider RRProviderRec, *RRProviderPtr;
88typedef struct _rrMonitor RRMonitorRec, *RRMonitorPtr;
89typedef struct _rrLease RRLeaseRec, *RRLeasePtr;
90
91struct _rrMode {
92    int refcnt;
93    xRRModeInfo mode;
94    char *name;
95    ScreenPtr userScreen;
96};
97
98struct _rrPropertyValue {
99    Atom type;                  /* ignored by server */
100    short format;               /* format of data for swapping - 8,16,32 */
101    long size;                  /* size of data in (format/8) bytes */
102    void *data;                 /* private to client */
103};
104
105struct _rrProperty {
106    RRPropertyPtr next;
107    ATOM propertyName;
108    Bool is_pending;
109    Bool range;
110    Bool immutable;
111    int num_valid;
112    INT32 *valid_values;
113    RRPropertyValueRec current, pending;
114};
115
116struct _rrCrtc {
117    RRCrtc id;
118    ScreenPtr pScreen;
119    RRModePtr mode;
120    int x, y;
121    Rotation rotation;
122    Rotation rotations;
123    Bool changed;
124    int numOutputs;
125    RROutputPtr *outputs;
126    int gammaSize;
127    CARD16 *gammaRed;
128    CARD16 *gammaBlue;
129    CARD16 *gammaGreen;
130    void *devPrivate;
131    Bool transforms;
132    RRTransformRec client_pending_transform;
133    RRTransformRec client_current_transform;
134    PictTransform transform;
135    struct pict_f_transform f_transform;
136    struct pict_f_transform f_inverse;
137
138    PixmapPtr scanout_pixmap;
139    PixmapPtr scanout_pixmap_back;
140};
141
142struct _rrOutput {
143    RROutput id;
144    ScreenPtr pScreen;
145    char *name;
146    int nameLength;
147    CARD8 connection;
148    CARD8 subpixelOrder;
149    int mmWidth;
150    int mmHeight;
151    RRCrtcPtr crtc;
152    int numCrtcs;
153    RRCrtcPtr *crtcs;
154    int numClones;
155    RROutputPtr *clones;
156    int numModes;
157    int numPreferred;
158    RRModePtr *modes;
159    int numUserModes;
160    RRModePtr *userModes;
161    Bool changed;
162    Bool nonDesktop;
163    RRPropertyPtr properties;
164    Bool pendingProperties;
165    void *devPrivate;
166};
167
168struct _rrProvider {
169    RRProvider id;
170    ScreenPtr pScreen;
171    uint32_t capabilities;
172    char *name;
173    int nameLength;
174    RRPropertyPtr properties;
175    Bool pendingProperties;
176    Bool changed;
177    struct _rrProvider *offload_sink;
178    struct _rrProvider *output_source;
179};
180
181typedef struct _rrMonitorGeometry {
182    BoxRec box;
183    CARD32 mmWidth;
184    CARD32 mmHeight;
185} RRMonitorGeometryRec, *RRMonitorGeometryPtr;
186
187struct _rrMonitor {
188    Atom name;
189    ScreenPtr pScreen;
190    int numOutputs;
191    RROutput *outputs;
192    Bool primary;
193    Bool automatic;
194    RRMonitorGeometryRec geometry;
195};
196
197typedef enum _rrLeaseState { RRLeaseCreating, RRLeaseRunning, RRLeaseTerminating } RRLeaseState;
198
199struct _rrLease {
200    struct xorg_list list;
201    ScreenPtr screen;
202    RRLease id;
203    RRLeaseState state;
204    void *devPrivate;
205    int numCrtcs;
206    RRCrtcPtr *crtcs;
207    int numOutputs;
208    RROutputPtr *outputs;
209};
210
211#if RANDR_12_INTERFACE
212typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen,
213                                        CARD16 width,
214                                        CARD16 height,
215                                        CARD32 mmWidth, CARD32 mmHeight);
216
217typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
218                                  RRCrtcPtr crtc,
219                                  RRModePtr mode,
220                                  int x,
221                                  int y,
222                                  Rotation rotation,
223                                  int numOutputs, RROutputPtr * outputs);
224
225typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc);
226
227typedef Bool (*RRCrtcGetGammaProcPtr) (ScreenPtr pScreen, RRCrtcPtr crtc);
228
229typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen,
230                                            RROutputPtr output,
231                                            Atom property,
232                                            RRPropertyValuePtr value);
233
234typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr pScreen,
235                                             RROutputPtr output,
236                                             RRModePtr mode);
237
238typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen, RRModePtr mode);
239
240#endif
241
242#if RANDR_13_INTERFACE
243typedef Bool (*RROutputGetPropertyProcPtr) (ScreenPtr pScreen,
244                                            RROutputPtr output, Atom property);
245typedef Bool (*RRGetPanningProcPtr) (ScreenPtr pScrn,
246                                     RRCrtcPtr crtc,
247                                     BoxPtr totalArea,
248                                     BoxPtr trackingArea, INT16 *border);
249typedef Bool (*RRSetPanningProcPtr) (ScreenPtr pScrn,
250                                     RRCrtcPtr crtc,
251                                     BoxPtr totalArea,
252                                     BoxPtr trackingArea, INT16 *border);
253
254#endif                          /* RANDR_13_INTERFACE */
255
256typedef Bool (*RRProviderGetPropertyProcPtr) (ScreenPtr pScreen,
257                                            RRProviderPtr provider, Atom property);
258typedef Bool (*RRProviderSetPropertyProcPtr) (ScreenPtr pScreen,
259                                              RRProviderPtr provider,
260                                              Atom property,
261                                              RRPropertyValuePtr value);
262
263typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations);
264typedef Bool (*RRCloseScreenProcPtr) (ScreenPtr pscreen);
265
266typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen,
267                                          RRProviderPtr provider,
268                                          RRProviderPtr output_source);
269
270typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen,
271                                         RRProviderPtr provider,
272                                         RRProviderPtr offload_sink);
273
274
275typedef void (*RRProviderDestroyProcPtr)(ScreenPtr pScreen,
276                                         RRProviderPtr provider);
277
278/* Additions for 1.6 */
279
280typedef int (*RRCreateLeaseProcPtr)(ScreenPtr screen,
281                                    RRLeasePtr lease,
282                                    int *fd);
283
284typedef void (*RRTerminateLeaseProcPtr)(ScreenPtr screen,
285                                        RRLeasePtr lease);
286
287/* These are for 1.0 compatibility */
288
289typedef struct _rrRefresh {
290    CARD16 rate;
291    RRModePtr mode;
292} RRScreenRate, *RRScreenRatePtr;
293
294typedef struct _rrScreenSize {
295    int id;
296    short width, height;
297    short mmWidth, mmHeight;
298    int nRates;
299    RRScreenRatePtr pRates;
300} RRScreenSize, *RRScreenSizePtr;
301
302#ifdef RANDR_10_INTERFACE
303
304typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
305                                    Rotation rotation,
306                                    int rate, RRScreenSizePtr pSize);
307
308#endif
309
310typedef Bool (*RRCrtcSetScanoutPixmapProcPtr)(RRCrtcPtr crtc, PixmapPtr pixmap);
311
312typedef Bool (*RRStartFlippingPixmapTrackingProcPtr)(RRCrtcPtr, DrawablePtr,
313                                                     PixmapPtr, PixmapPtr,
314                                                     int x, int y,
315                                                     int dst_x, int dst_y,
316                                                     Rotation rotation);
317
318typedef Bool (*RREnableSharedPixmapFlippingProcPtr)(RRCrtcPtr,
319                                                    PixmapPtr front,
320                                                    PixmapPtr back);
321
322typedef void (*RRDisableSharedPixmapFlippingProcPtr)(RRCrtcPtr);
323
324
325typedef struct _rrScrPriv {
326    /*
327     * 'public' part of the structure; DDXen fill this in
328     * as they initialize
329     */
330#if RANDR_10_INTERFACE
331    RRSetConfigProcPtr rrSetConfig;
332#endif
333    RRGetInfoProcPtr rrGetInfo;
334#if RANDR_12_INTERFACE
335    RRScreenSetSizeProcPtr rrScreenSetSize;
336    RRCrtcSetProcPtr rrCrtcSet;
337    RRCrtcSetGammaProcPtr rrCrtcSetGamma;
338    RRCrtcGetGammaProcPtr rrCrtcGetGamma;
339    RROutputSetPropertyProcPtr rrOutputSetProperty;
340    RROutputValidateModeProcPtr rrOutputValidateMode;
341    RRModeDestroyProcPtr rrModeDestroy;
342#endif
343#if RANDR_13_INTERFACE
344    RROutputGetPropertyProcPtr rrOutputGetProperty;
345    RRGetPanningProcPtr rrGetPanning;
346    RRSetPanningProcPtr rrSetPanning;
347#endif
348    /* TODO #if RANDR_15_INTERFACE */
349    RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap;
350
351    RRStartFlippingPixmapTrackingProcPtr rrStartFlippingPixmapTracking;
352    RREnableSharedPixmapFlippingProcPtr rrEnableSharedPixmapFlipping;
353    RRDisableSharedPixmapFlippingProcPtr rrDisableSharedPixmapFlipping;
354
355    RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource;
356    RRProviderSetOffloadSinkProcPtr rrProviderSetOffloadSink;
357    RRProviderGetPropertyProcPtr rrProviderGetProperty;
358    RRProviderSetPropertyProcPtr rrProviderSetProperty;
359
360    RRCreateLeaseProcPtr rrCreateLease;
361    RRTerminateLeaseProcPtr rrTerminateLease;
362
363    /*
364     * Private part of the structure; not considered part of the ABI
365     */
366    TimeStamp lastSetTime;      /* last changed by client */
367    TimeStamp lastConfigTime;   /* possible configs changed */
368    RRCloseScreenProcPtr CloseScreen;
369
370    Bool changed;               /* some config changed */
371    Bool configChanged;         /* configuration changed */
372    Bool layoutChanged;         /* screen layout changed */
373    Bool resourcesChanged;      /* screen resources change */
374    Bool leasesChanged;         /* leases change */
375
376    CARD16 minWidth, minHeight;
377    CARD16 maxWidth, maxHeight;
378    CARD16 width, height;       /* last known screen size */
379    CARD16 mmWidth, mmHeight;   /* last known screen size */
380
381    int numOutputs;
382    RROutputPtr *outputs;
383    RROutputPtr primaryOutput;
384
385    int numCrtcs;
386    RRCrtcPtr *crtcs;
387
388    /* Last known pointer position */
389    RRCrtcPtr pointerCrtc;
390
391#ifdef RANDR_10_INTERFACE
392    /*
393     * Configuration information
394     */
395    Rotation rotations;
396    CARD16 reqWidth, reqHeight;
397
398    int nSizes;
399    RRScreenSizePtr pSizes;
400
401    Rotation rotation;
402    int rate;
403    int size;
404#endif
405    Bool discontiguous;
406
407    RRProviderPtr provider;
408
409    RRProviderDestroyProcPtr rrProviderDestroy;
410
411    int numMonitors;
412    RRMonitorPtr *monitors;
413
414    struct xorg_list leases;
415} rrScrPrivRec, *rrScrPrivPtr;
416
417extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec;
418
419#define rrPrivKey (&rrPrivKeyRec)
420
421#define rrGetScrPriv(pScr)  ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey))
422#define rrScrPriv(pScr)	rrScrPrivPtr    pScrPriv = rrGetScrPriv(pScr)
423#define SetRRScreen(s,p) dixSetPrivate(&(s)->devPrivates, rrPrivKey, p)
424
425/*
426 * each window has a list of clients requesting
427 * RRNotify events.  Each client has a resource
428 * for each window it selects RRNotify input for,
429 * this resource is used to delete the RRNotifyRec
430 * entry from the per-window queue.
431 */
432
433typedef struct _RREvent *RREventPtr;
434
435typedef struct _RREvent {
436    RREventPtr next;
437    ClientPtr client;
438    WindowPtr window;
439    XID clientResource;
440    int mask;
441} RREventRec;
442
443typedef struct _RRTimes {
444    TimeStamp setTime;
445    TimeStamp configTime;
446} RRTimesRec, *RRTimesPtr;
447
448typedef struct _RRClient {
449    int major_version;
450    int minor_version;
451/*  RRTimesRec	times[0]; */
452} RRClientRec, *RRClientPtr;
453
454extern RESTYPE RRClientType, RREventType;     /* resource types for event masks */
455extern DevPrivateKeyRec RRClientPrivateKeyRec;
456
457#define RRClientPrivateKey (&RRClientPrivateKeyRec)
458extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType, RRProviderType, RRLeaseType;
459
460#define VERIFY_RR_OUTPUT(id, ptr, a)\
461    {\
462	int rc = dixLookupResourceByType((void **)&(ptr), id,\
463	                                 RROutputType, client, a);\
464	if (rc != Success) {\
465	    client->errorValue = id;\
466	    return rc;\
467	}\
468    }
469
470#define VERIFY_RR_CRTC(id, ptr, a)\
471    {\
472	int rc = dixLookupResourceByType((void **)&(ptr), id,\
473	                                 RRCrtcType, client, a);\
474	if (rc != Success) {\
475	    client->errorValue = id;\
476	    return rc;\
477	}\
478    }
479
480#define VERIFY_RR_MODE(id, ptr, a)\
481    {\
482	int rc = dixLookupResourceByType((void **)&(ptr), id,\
483	                                 RRModeType, client, a);\
484	if (rc != Success) {\
485	    client->errorValue = id;\
486	    return rc;\
487	}\
488    }
489
490#define VERIFY_RR_PROVIDER(id, ptr, a)\
491    {\
492        int rc = dixLookupResourceByType((void **)&(ptr), id,\
493                                         RRProviderType, client, a);\
494        if (rc != Success) {\
495            client->errorValue = id;\
496            return rc;\
497        }\
498    }
499
500#define VERIFY_RR_LEASE(id, ptr, a)\
501    {\
502        int rc = dixLookupResourceByType((void **)&(ptr), id,\
503                                         RRLeaseType, client, a);\
504        if (rc != Success) {\
505            client->errorValue = id;\
506            return rc;\
507        }\
508    }
509
510#define GetRRClient(pClient)    ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
511#define rrClientPriv(pClient)	RRClientPtr pRRClient = GetRRClient(pClient)
512
513#ifdef RANDR_12_INTERFACE
514/*
515 * Set the range of sizes for the screen
516 */
517extern _X_EXPORT void
518
519RRScreenSetSizeRange(ScreenPtr pScreen,
520                     CARD16 minWidth,
521                     CARD16 minHeight, CARD16 maxWidth, CARD16 maxHeight);
522#endif
523
524/* rrscreen.c */
525/*
526 * Notify the extension that the screen size has been changed.
527 * The driver is responsible for calling this whenever it has changed
528 * the size of the screen
529 */
530extern _X_EXPORT void
531 RRScreenSizeNotify(ScreenPtr pScreen);
532
533/*
534 * Request that the screen be resized
535 */
536extern _X_EXPORT Bool
537
538RRScreenSizeSet(ScreenPtr pScreen,
539                CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight);
540
541/*
542 * Send ConfigureNotify event to root window when 'something' happens
543 */
544extern _X_EXPORT void
545 RRSendConfigNotify(ScreenPtr pScreen);
546
547/*
548 * screen dispatch
549 */
550extern _X_EXPORT int
551 ProcRRGetScreenSizeRange(ClientPtr client);
552
553extern _X_EXPORT int
554 ProcRRSetScreenSize(ClientPtr client);
555
556extern _X_EXPORT int
557 ProcRRGetScreenResources(ClientPtr client);
558
559extern _X_EXPORT int
560 ProcRRGetScreenResourcesCurrent(ClientPtr client);
561
562extern _X_EXPORT int
563 ProcRRSetScreenConfig(ClientPtr client);
564
565extern _X_EXPORT int
566 ProcRRGetScreenInfo(ClientPtr client);
567
568/*
569 * Deliver a ScreenNotify event
570 */
571extern _X_EXPORT void
572 RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
573
574extern _X_EXPORT void
575 RRResourcesChanged(ScreenPtr pScreen);
576
577/* randr.c */
578/* set a screen change on the primary screen */
579extern _X_EXPORT void
580RRSetChanged(ScreenPtr pScreen);
581
582/*
583 * Send all pending events
584 */
585extern _X_EXPORT void
586 RRTellChanged(ScreenPtr pScreen);
587
588extern _X_EXPORT void
589RRSetChanged (ScreenPtr pScreen);
590
591/*
592 * Poll the driver for changed information
593 */
594extern _X_EXPORT Bool
595 RRGetInfo(ScreenPtr pScreen, Bool force_query);
596
597extern _X_EXPORT Bool RRInit(void);
598
599extern _X_EXPORT Bool RRScreenInit(ScreenPtr pScreen);
600
601extern _X_EXPORT RROutputPtr RRFirstOutput(ScreenPtr pScreen);
602
603extern _X_EXPORT RRCrtcPtr RRFirstEnabledCrtc(ScreenPtr pScreen);
604
605extern _X_EXPORT Bool RROutputSetNonDesktop(RROutputPtr output, Bool non_desktop);
606
607extern _X_EXPORT CARD16
608 RRVerticalRefresh(xRRModeInfo * mode);
609
610#ifdef RANDR_10_INTERFACE
611/*
612 * This is the old interface, deprecated but left
613 * around for compatibility
614 */
615
616/*
617 * Then, register the specific size with the screen
618 */
619
620extern _X_EXPORT RRScreenSizePtr
621RRRegisterSize(ScreenPtr pScreen,
622               short width, short height, short mmWidth, short mmHeight);
623
624extern _X_EXPORT Bool
625 RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate);
626
627/*
628 * Finally, set the current configuration of the screen
629 */
630
631extern _X_EXPORT void
632
633RRSetCurrentConfig(ScreenPtr pScreen,
634                   Rotation rotation, int rate, RRScreenSizePtr pSize);
635
636extern _X_EXPORT Rotation RRGetRotation(ScreenPtr pScreen);
637
638#endif
639
640/* rrcrtc.c */
641
642/*
643 * Notify the CRTC of some change; layoutChanged indicates that
644 * some position or size element changed
645 */
646extern _X_EXPORT void
647 RRCrtcChanged(RRCrtcPtr crtc, Bool layoutChanged);
648
649/*
650 * Create a CRTC
651 */
652extern _X_EXPORT RRCrtcPtr RRCrtcCreate(ScreenPtr pScreen, void *devPrivate);
653
654/*
655 * Tests if findCrtc belongs to pScreen or secondary screens
656 */
657extern _X_EXPORT Bool RRCrtcExists(ScreenPtr pScreen, RRCrtcPtr findCrtc);
658
659/*
660 * Set the allowed rotations on a CRTC
661 */
662extern _X_EXPORT void
663 RRCrtcSetRotations(RRCrtcPtr crtc, Rotation rotations);
664
665/*
666 * Set whether transforms are allowed on a CRTC
667 */
668extern _X_EXPORT void
669 RRCrtcSetTransformSupport(RRCrtcPtr crtc, Bool transforms);
670
671/*
672 * Notify the extension that the Crtc has been reconfigured,
673 * the driver calls this whenever it has updated the mode
674 */
675extern _X_EXPORT Bool
676
677RRCrtcNotify(RRCrtcPtr crtc,
678             RRModePtr mode,
679             int x,
680             int y,
681             Rotation rotation,
682             RRTransformPtr transform, int numOutputs, RROutputPtr * outputs);
683
684extern _X_EXPORT void
685 RRDeliverCrtcEvent(ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
686
687/*
688 * Request that the Crtc be reconfigured
689 */
690extern _X_EXPORT Bool
691
692RRCrtcSet(RRCrtcPtr crtc,
693          RRModePtr mode,
694          int x,
695          int y, Rotation rotation, int numOutput, RROutputPtr * outputs);
696
697/*
698 * Request that the Crtc gamma be changed
699 */
700
701extern _X_EXPORT Bool
702 RRCrtcGammaSet(RRCrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue);
703
704/*
705 * Request current gamma back from the DDX (if possible).
706 * This includes gamma size.
707 */
708
709extern _X_EXPORT Bool
710 RRCrtcGammaGet(RRCrtcPtr crtc);
711
712/*
713 * Notify the extension that the Crtc gamma has been changed
714 * The driver calls this whenever it has changed the gamma values
715 * in the RRCrtcRec
716 */
717
718extern _X_EXPORT Bool
719 RRCrtcGammaNotify(RRCrtcPtr crtc);
720
721/*
722 * Set the size of the gamma table at server startup time
723 */
724
725extern _X_EXPORT Bool
726 RRCrtcGammaSetSize(RRCrtcPtr crtc, int size);
727
728/*
729 * Return the area of the frame buffer scanned out by the crtc,
730 * taking into account the current mode and rotation
731 */
732
733extern _X_EXPORT void
734 RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height);
735
736/*
737 * Return crtc transform
738 */
739extern _X_EXPORT RRTransformPtr RRCrtcGetTransform(RRCrtcPtr crtc);
740
741/*
742 * Check whether the pending and current transforms are the same
743 */
744extern _X_EXPORT Bool
745 RRCrtcPendingTransform(RRCrtcPtr crtc);
746
747/*
748 * Destroy a Crtc at shutdown
749 */
750extern _X_EXPORT void
751 RRCrtcDestroy(RRCrtcPtr crtc);
752
753/*
754 * Set the pending CRTC transformation
755 */
756
757extern _X_EXPORT int
758
759RRCrtcTransformSet(RRCrtcPtr crtc,
760                   PictTransformPtr transform,
761                   struct pict_f_transform *f_transform,
762                   struct pict_f_transform *f_inverse,
763                   char *filter, int filter_len, xFixed * params, int nparams);
764
765/*
766 * Initialize crtc type
767 */
768extern _X_EXPORT Bool
769 RRCrtcInit(void);
770
771/*
772 * Initialize crtc type error value
773 */
774extern _X_EXPORT void
775 RRCrtcInitErrorValue(void);
776
777/*
778 * Detach and free a scanout pixmap
779 */
780extern _X_EXPORT void
781 RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc);
782
783extern _X_EXPORT Bool
784 RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable);
785
786/*
787 * Return if the screen has any scanout_pixmap's attached
788 */
789extern _X_EXPORT Bool
790 RRHasScanoutPixmap(ScreenPtr pScreen);
791
792/*
793 * Crtc dispatch
794 */
795
796extern _X_EXPORT int
797 ProcRRGetCrtcInfo(ClientPtr client);
798
799extern _X_EXPORT int
800 ProcRRSetCrtcConfig(ClientPtr client);
801
802extern _X_EXPORT int
803 ProcRRGetCrtcGammaSize(ClientPtr client);
804
805extern _X_EXPORT int
806 ProcRRGetCrtcGamma(ClientPtr client);
807
808extern _X_EXPORT int
809 ProcRRSetCrtcGamma(ClientPtr client);
810
811extern _X_EXPORT int
812 ProcRRSetCrtcTransform(ClientPtr client);
813
814extern _X_EXPORT int
815 ProcRRGetCrtcTransform(ClientPtr client);
816
817int
818 ProcRRGetPanning(ClientPtr client);
819
820int
821 ProcRRSetPanning(ClientPtr client);
822
823void
824 RRConstrainCursorHarder(DeviceIntPtr, ScreenPtr, int, int *, int *);
825
826/* rrdispatch.c */
827extern _X_EXPORT Bool
828 RRClientKnowsRates(ClientPtr pClient);
829
830/* rrlease.c */
831void
832RRDeliverLeaseEvent(ClientPtr client, WindowPtr window);
833
834extern _X_EXPORT void
835RRLeaseTerminated(RRLeasePtr lease);
836
837extern _X_EXPORT void
838RRLeaseFree(RRLeasePtr lease);
839
840extern _X_EXPORT Bool
841RRCrtcIsLeased(RRCrtcPtr crtc);
842
843extern _X_EXPORT Bool
844RROutputIsLeased(RROutputPtr output);
845
846void
847RRTerminateLease(RRLeasePtr lease);
848
849Bool
850RRLeaseInit(void);
851
852/* rrmode.c */
853/*
854 * Find, and if necessary, create a mode
855 */
856
857extern _X_EXPORT RRModePtr RRModeGet(xRRModeInfo * modeInfo, const char *name);
858
859/*
860 * Destroy a mode.
861 */
862
863extern _X_EXPORT void
864 RRModeDestroy(RRModePtr mode);
865
866/*
867 * Return a list of modes that are valid for some output in pScreen
868 */
869extern _X_EXPORT RRModePtr *RRModesForScreen(ScreenPtr pScreen, int *num_ret);
870
871/*
872 * Initialize mode type
873 */
874extern _X_EXPORT Bool
875 RRModeInit(void);
876
877/*
878 * Initialize mode type error value
879 */
880extern _X_EXPORT void
881 RRModeInitErrorValue(void);
882
883extern _X_EXPORT int
884 ProcRRCreateMode(ClientPtr client);
885
886extern _X_EXPORT int
887 ProcRRDestroyMode(ClientPtr client);
888
889extern _X_EXPORT int
890 ProcRRAddOutputMode(ClientPtr client);
891
892extern _X_EXPORT int
893 ProcRRDeleteOutputMode(ClientPtr client);
894
895/* rroutput.c */
896
897/*
898 * Notify the output of some change. configChanged indicates whether
899 * any external configuration (mode list, clones, connected status)
900 * has changed, or whether the change was strictly internal
901 * (which crtc is in use)
902 */
903extern _X_EXPORT void
904 RROutputChanged(RROutputPtr output, Bool configChanged);
905
906/*
907 * Create an output
908 */
909
910extern _X_EXPORT RROutputPtr
911RROutputCreate(ScreenPtr pScreen,
912               const char *name, int nameLength, void *devPrivate);
913
914/*
915 * Notify extension that output parameters have been changed
916 */
917extern _X_EXPORT Bool
918 RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones);
919
920extern _X_EXPORT Bool
921
922RROutputSetModes(RROutputPtr output,
923                 RRModePtr * modes, int numModes, int numPreferred);
924
925extern _X_EXPORT int
926 RROutputAddUserMode(RROutputPtr output, RRModePtr mode);
927
928extern _X_EXPORT int
929 RROutputDeleteUserMode(RROutputPtr output, RRModePtr mode);
930
931extern _X_EXPORT Bool
932 RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs);
933
934extern _X_EXPORT Bool
935 RROutputSetConnection(RROutputPtr output, CARD8 connection);
936
937extern _X_EXPORT Bool
938 RROutputSetSubpixelOrder(RROutputPtr output, int subpixelOrder);
939
940extern _X_EXPORT Bool
941 RROutputSetPhysicalSize(RROutputPtr output, int mmWidth, int mmHeight);
942
943extern _X_EXPORT void
944 RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
945
946extern _X_EXPORT void
947 RROutputDestroy(RROutputPtr output);
948
949extern _X_EXPORT int
950 ProcRRGetOutputInfo(ClientPtr client);
951
952extern _X_EXPORT int
953 ProcRRSetOutputPrimary(ClientPtr client);
954
955extern _X_EXPORT int
956 ProcRRGetOutputPrimary(ClientPtr client);
957
958/*
959 * Initialize output type
960 */
961extern _X_EXPORT Bool
962 RROutputInit(void);
963
964/*
965 * Initialize output type error value
966 */
967extern _X_EXPORT void
968 RROutputInitErrorValue(void);
969
970/* rrpointer.c */
971extern _X_EXPORT void
972 RRPointerMoved(ScreenPtr pScreen, int x, int y);
973
974extern _X_EXPORT void
975 RRPointerScreenConfigured(ScreenPtr pScreen);
976
977/* rrproperty.c */
978
979extern _X_EXPORT void
980 RRDeleteAllOutputProperties(RROutputPtr output);
981
982extern _X_EXPORT RRPropertyValuePtr
983RRGetOutputProperty(RROutputPtr output, Atom property, Bool pending);
984
985extern _X_EXPORT RRPropertyPtr
986RRQueryOutputProperty(RROutputPtr output, Atom property);
987
988extern _X_EXPORT void
989 RRDeleteOutputProperty(RROutputPtr output, Atom property);
990
991extern _X_EXPORT Bool
992 RRPostPendingProperties(RROutputPtr output);
993
994extern _X_EXPORT int
995
996RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
997                       int format, int mode, unsigned long len,
998                       const void *value, Bool sendevent, Bool pending);
999
1000extern _X_EXPORT int
1001
1002RRConfigureOutputProperty(RROutputPtr output, Atom property,
1003                          Bool pending, Bool range, Bool immutable,
1004                          int num_values, const INT32 *values);
1005extern _X_EXPORT int
1006 ProcRRChangeOutputProperty(ClientPtr client);
1007
1008extern _X_EXPORT int
1009 ProcRRGetOutputProperty(ClientPtr client);
1010
1011extern _X_EXPORT int
1012 ProcRRListOutputProperties(ClientPtr client);
1013
1014extern _X_EXPORT int
1015 ProcRRQueryOutputProperty(ClientPtr client);
1016
1017extern _X_EXPORT int
1018 ProcRRConfigureOutputProperty(ClientPtr client);
1019
1020extern _X_EXPORT int
1021 ProcRRDeleteOutputProperty(ClientPtr client);
1022
1023/* rrprovider.c */
1024#define PRIME_SYNC_PROP         "PRIME Synchronization"
1025extern _X_EXPORT void
1026RRProviderInitErrorValue(void);
1027
1028extern _X_EXPORT int
1029ProcRRGetProviders(ClientPtr client);
1030
1031extern _X_EXPORT int
1032ProcRRGetProviderInfo(ClientPtr client);
1033
1034extern _X_EXPORT int
1035ProcRRSetProviderOutputSource(ClientPtr client);
1036
1037extern _X_EXPORT int
1038ProcRRSetProviderOffloadSink(ClientPtr client);
1039
1040extern _X_EXPORT Bool
1041RRProviderInit(void);
1042
1043extern _X_EXPORT RRProviderPtr
1044RRProviderCreate(ScreenPtr pScreen, const char *name,
1045                 int nameLength);
1046
1047extern _X_EXPORT void
1048RRProviderDestroy (RRProviderPtr provider);
1049
1050extern _X_EXPORT void
1051RRProviderSetCapabilities(RRProviderPtr provider, uint32_t capabilities);
1052
1053extern _X_EXPORT Bool
1054RRProviderLookup(XID id, RRProviderPtr *provider_p);
1055
1056extern _X_EXPORT void
1057RRDeliverProviderEvent(ClientPtr client, WindowPtr pWin, RRProviderPtr provider);
1058
1059extern _X_EXPORT void
1060RRProviderAutoConfigGpuScreen(ScreenPtr pScreen, ScreenPtr primaryScreen);
1061
1062/* rrproviderproperty.c */
1063
1064extern _X_EXPORT void
1065 RRDeleteAllProviderProperties(RRProviderPtr provider);
1066
1067extern _X_EXPORT RRPropertyValuePtr
1068 RRGetProviderProperty(RRProviderPtr provider, Atom property, Bool pending);
1069
1070extern _X_EXPORT RRPropertyPtr
1071 RRQueryProviderProperty(RRProviderPtr provider, Atom property);
1072
1073extern _X_EXPORT void
1074 RRDeleteProviderProperty(RRProviderPtr provider, Atom property);
1075
1076extern _X_EXPORT int
1077RRChangeProviderProperty(RRProviderPtr provider, Atom property, Atom type,
1078                       int format, int mode, unsigned long len,
1079                       void *value, Bool sendevent, Bool pending);
1080
1081extern _X_EXPORT int
1082 RRConfigureProviderProperty(RRProviderPtr provider, Atom property,
1083                             Bool pending, Bool range, Bool immutable,
1084                             int num_values, INT32 *values);
1085
1086extern _X_EXPORT Bool
1087 RRPostProviderPendingProperties(RRProviderPtr provider);
1088
1089extern _X_EXPORT int
1090 ProcRRGetProviderProperty(ClientPtr client);
1091
1092extern _X_EXPORT int
1093 ProcRRListProviderProperties(ClientPtr client);
1094
1095extern _X_EXPORT int
1096 ProcRRQueryProviderProperty(ClientPtr client);
1097
1098extern _X_EXPORT int
1099ProcRRConfigureProviderProperty(ClientPtr client);
1100
1101extern _X_EXPORT int
1102ProcRRChangeProviderProperty(ClientPtr client);
1103
1104extern _X_EXPORT int
1105 ProcRRDeleteProviderProperty(ClientPtr client);
1106/* rrxinerama.c */
1107#ifdef XINERAMA
1108extern _X_EXPORT void
1109 RRXineramaExtensionInit(void);
1110#endif
1111
1112void
1113RRMonitorInit(ScreenPtr screen);
1114
1115Bool
1116RRMonitorMakeList(ScreenPtr screen, Bool get_active, RRMonitorPtr *monitors_ret, int *nmon_ret);
1117
1118int
1119RRMonitorCountList(ScreenPtr screen);
1120
1121void
1122RRMonitorFreeList(RRMonitorPtr monitors, int nmon);
1123
1124void
1125RRMonitorClose(ScreenPtr screen);
1126
1127RRMonitorPtr
1128RRMonitorAlloc(int noutput);
1129
1130int
1131RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor);
1132
1133void
1134RRMonitorFree(RRMonitorPtr monitor);
1135
1136int
1137ProcRRGetMonitors(ClientPtr client);
1138
1139int
1140ProcRRSetMonitor(ClientPtr client);
1141
1142int
1143ProcRRDeleteMonitor(ClientPtr client);
1144
1145int
1146ProcRRCreateLease(ClientPtr client);
1147
1148int
1149ProcRRFreeLease(ClientPtr client);
1150
1151#endif                          /* _RANDRSTR_H_ */
1152
1153/*
1154
1155randr extension implementation structure
1156
1157Query state:
1158    ProcRRGetScreenInfo/ProcRRGetScreenResources
1159	RRGetInfo
1160
1161	    • Request configuration from driver, either 1.0 or 1.2 style
1162	    • These functions only record state changes, all
1163	      other actions are pended until RRTellChanged is called
1164
1165	    ->rrGetInfo
1166	    1.0:
1167		RRRegisterSize
1168		RRRegisterRate
1169		RRSetCurrentConfig
1170	    1.2:
1171		RRScreenSetSizeRange
1172		RROutputSetCrtcs
1173		RRModeGet
1174		RROutputSetModes
1175		RROutputSetConnection
1176		RROutputSetSubpixelOrder
1177		RROutputSetClones
1178		RRCrtcNotify
1179
1180	• Must delay scanning configuration until after ->rrGetInfo returns
1181	  because some drivers will call SetCurrentConfig in the middle
1182	  of the ->rrGetInfo operation.
1183
1184	1.0:
1185
1186	    • Scan old configuration, mirror to new structures
1187
1188	    RRScanOldConfig
1189		RRCrtcCreate
1190		RROutputCreate
1191		RROutputSetCrtcs
1192		RROutputSetConnection
1193		RROutputSetSubpixelOrder
1194		RROldModeAdd	• This adds modes one-at-a-time
1195		    RRModeGet
1196		RRCrtcNotify
1197
1198	• send events, reset pointer if necessary
1199
1200	RRTellChanged
1201	    WalkTree (sending events)
1202
1203	    • when layout has changed:
1204		RRPointerScreenConfigured
1205		RRSendConfigNotify
1206
1207Asynchronous state setting (1.2 only)
1208    When setting state asynchronously, the driver invokes the
1209    ->rrGetInfo function and then calls RRTellChanged to flush
1210    the changes to the clients and reset pointer if necessary
1211
1212Set state
1213
1214    ProcRRSetScreenConfig
1215	RRCrtcSet
1216	    1.2:
1217		->rrCrtcSet
1218		    RRCrtcNotify
1219	    1.0:
1220		->rrSetConfig
1221		RRCrtcNotify
1222	    RRTellChanged
1223 */
1224