1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
|
/*
* Copyright © 2000 Compaq Computer Corporation
* Copyright © 2002 Hewlett-Packard Company
* Copyright © 2006 Intel Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
* Author: Jim Gettys, Hewlett-Packard Company, Inc.
* Keith Packard, Intel Corporation
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _RANDRSTR_H_
#define _RANDRSTR_H_
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "resource.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "extnsionst.h"
#include "servermd.h"
#include <X11/extensions/randr.h>
#include <X11/extensions/randrproto.h>
#ifdef RENDER
#include <X11/extensions/render.h> /* we share subpixel order information */
#include "picturestr.h"
#endif
#include <X11/Xfuncproto.h>
/* required for ABI compatibility for now */
#define RANDR_10_INTERFACE 1
/* #define RANDR_12_INTERFACE 1 */
typedef XID RRMode;
typedef XID RROutput;
typedef XID RRCrtc;
extern int RREventBase, RRErrorBase;
extern int (*ProcRandrVector[RRNumberRequests])(ClientPtr);
extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr);
/*
* Modeline for a monitor. Name follows directly after this struct
*/
#define RRModeName(pMode) ((char *) (pMode + 1))
typedef struct _rrMode RRModeRec, *RRModePtr;
typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr;
typedef struct _rrOutput RROutputRec, *RROutputPtr;
struct _rrMode {
RRMode id;
int refcnt;
xRRModeInfo mode;
char *name;
};
struct _rrCrtc {
RRCrtc id;
ScreenPtr pScreen;
RRModePtr mode;
int x, y;
Rotation rotation;
Rotation rotations;
Bool changed;
int numOutputs;
RROutputPtr *outputs;
void *devPrivate;
};
struct _rrOutput {
RROutput id;
ScreenPtr pScreen;
char *name;
int nameLength;
CARD8 connection;
CARD8 subpixelOrder;
RRCrtcPtr crtc;
int numCrtcs;
RRCrtcPtr *crtcs;
int numClones;
RROutputPtr *clones;
int numModes;
RRModePtr *modes;
Bool changed;
void *devPrivate;
};
#if RANDR_12_INTERFACE
typedef Bool (*RRScreentSizeSetProcPtr) (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
CARD32 mmWidth,
CARD32 mmHeight);
typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen,
RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutputs,
RROutputPtr *outputs);
#endif
typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
/* These are for 1.0 compatibility */
typedef struct _rrRefresh {
CARD16 rate;
RRModePtr mode;
} RRScreenRate, *RRScreenRatePtr;
typedef struct _rrScreenSize {
int id;
short width, height;
short mmWidth, mmHeight;
int nRates;
RRScreenRatePtr pRates;
} RRScreenSize, *RRScreenSizePtr;
#ifdef RANDR_10_INTERFACE
typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize);
#endif
typedef struct _rrScrPriv {
/*
* 'public' part of the structure; DDXen fill this in
* as they initialize
*/
#if RANDR_10_INTERFACE
RRSetConfigProcPtr rrSetConfig;
#endif
RRGetInfoProcPtr rrGetInfo;
#if RANDR_12_INTERFACE
RRScreenSetSizeProcPtr rrScreenSizeSet;
RRCrtcSetProcPtr rrCrtcSet;
#endif
/*
* Private part of the structure; not considered part of the ABI
*/
TimeStamp lastSetTime; /* last changed by client */
TimeStamp lastConfigTime; /* possible configs changed */
RRCloseScreenProcPtr CloseScreen;
Bool changed;
CARD16 minWidth, minHeight;
CARD16 maxWidth, maxHeight;
CARD16 width, height; /* last known screen size */
/* modes, outputs and crtcs */
int numModes;
RRModePtr *modes;
int numOutputs;
RROutputPtr *outputs;
int numCrtcs;
RRCrtcPtr *crtcs;
#ifdef RANDR_10_INTERFACE
/*
* Configuration information
*/
Rotation rotations;
CARD16 reqWidth, reqHeight;
int nSizes;
RRScreenSizePtr pSizes;
Rotation rotation;
int rate;
int size;
#endif
} rrScrPrivRec, *rrScrPrivPtr;
extern int rrPrivIndex;
#define rrGetScrPriv(pScr) ((rrScrPrivPtr) (pScr)->devPrivates[rrPrivIndex].ptr)
#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p))
/*
* each window has a list of clients requesting
* RRNotify events. Each client has a resource
* for each window it selects RRNotify input for,
* this resource is used to delete the RRNotifyRec
* entry from the per-window queue.
*/
typedef struct _RREvent *RREventPtr;
typedef struct _RREvent {
RREventPtr next;
ClientPtr client;
WindowPtr window;
XID clientResource;
int mask;
} RREventRec;
typedef struct _RRTimes {
TimeStamp setTime;
TimeStamp configTime;
} RRTimesRec, *RRTimesPtr;
typedef struct _RRClient {
int major_version;
int minor_version;
/* RRTimesRec times[0]; */
} RRClientRec, *RRClientPtr;
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
extern int RRClientPrivateIndex;
extern RESTYPE RRCrtcType, RRModeType, RROutputType;
#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr)
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
/* Initialize the extension */
void
RRExtensionInit (void);
#ifdef RANDR_12_INTERFACE
/*
* Set the range of sizes for the screen
*/
void
RRScreenSetSizeRange (ScreenPtr pScreen,
CARD16 minWidth,
CARD16 minHeight,
CARD16 maxWidth,
CARD16 maxHeight);
#endif
/* rrscreen.c */
/*
* Notify the extension that the screen size has been changed.
* The driver is responsible for calling this whenever it has changed
* the size of the screen
*/
void
RRScreenSizeNotify (ScreenPtr pScreen);
/*
* Request that the screen be resized
*/
Bool
RRScreenSizeSet (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
CARD32 mmWidth,
CARD32 mmHeight);
/*
* Deliver a ScreenNotify event
*/
void
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
/* mirandr.c */
Bool
miRandRInit (ScreenPtr pScreen);
Bool
miRRGetInfo (ScreenPtr pScreen, Rotation *rotations);
Bool
miRRGetScreenInfo (ScreenPtr pScreen);
Bool
miRRCrtcSet (ScreenPtr pScreen,
RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutput,
RROutputPtr *outputs);
/* randr.c */
/*
* Send all pending events
*/
void
RRTellChanged (ScreenPtr pScreen);
/*
* Poll the driver for changed information
*/
Bool
RRGetInfo (ScreenPtr pScreen);
Bool RRScreenInit(ScreenPtr pScreen);
RROutputPtr
RRFirstOutput (ScreenPtr pScreen);
Rotation
RRGetRotation (ScreenPtr pScreen);
CARD16
RRVerticalRefresh (xRRModeInfo *mode);
#ifdef RANDR_10_INTERFACE
/*
* This is the old interface, deprecated but left
* around for compatibility
*/
/*
* Then, register the specific size with the screen
*/
RRScreenSizePtr
RRRegisterSize (ScreenPtr pScreen,
short width,
short height,
short mmWidth,
short mmHeight);
Bool RRRegisterRate (ScreenPtr pScreen,
RRScreenSizePtr pSize,
int rate);
/*
* Finally, set the current configuration of the screen
*/
void
RRSetCurrentConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize);
Bool RRScreenInit (ScreenPtr pScreen);
Rotation
RRGetRotation (ScreenPtr pScreen);
int
RRSetScreenConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize);
#endif
/* rrcrtc.c */
/*
* Create a CRTC
*/
RRCrtcPtr
RRCrtcCreate (ScreenPtr pScreen,
void *devPrivate);
/*
* Notify the extension that the Crtc has been reconfigured,
* the driver calls this whenever it has updated the mode
*/
Bool
RRCrtcNotify (RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutput,
RROutputPtr *outputs);
void
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
/*
* Request that the Crtc be reconfigured
*/
Bool
RRCrtcSet (RRCrtcPtr crtc,
RRModePtr mode,
int x,
int y,
Rotation rotation,
int numOutput,
RROutputPtr *outputs);
/*
* Destroy a Crtc at shutdown
*/
void
RRCrtcDestroy (RRCrtcPtr crtc);
/*
* Initialize crtc type
*/
Bool
RRCrtcInit (void);
/* rrdispatch.c */
Bool
RRClientKnowsRates (ClientPtr pClient);
/* rrmode.c */
/*
* Find, and if necessary, create a mode
*/
RRModePtr
RRModeGet (ScreenPtr pScreen,
xRRModeInfo *modeInfo,
char *name);
/*
* Destroy a mode.
*/
void
RRModeDestroy (RRModePtr mode);
/*
* Initialize mode type
*/
Bool
RRModeInit (void);
/* rroutput.c */
/*
* Create an output
*/
RROutputPtr
RROutputCreate (ScreenPtr pScreen,
char *name,
int nameLength,
void *devPrivate);
/*
* Notify extension that output parameters have been changed
*/
Bool
RROutputSetClones (RROutputPtr output,
RROutputPtr *clones,
int numClones);
Bool
RROutputSetModes (RROutputPtr output,
RRModePtr *modes,
int numModes);
Bool
RROutputSetCrtcs (RROutputPtr output,
RRCrtcPtr *crtcs,
int numCrtcs);
Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection);
void
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
void
RROutputDestroy (RROutputPtr output);
/*
* Initialize output type
*/
Bool
RROutputInit (void);
#endif /* _RANDRSTR_H_ */
|