4 Copyright 1995 Kaleb S. KEITHLEY
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
21 OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Kaleb S. KEITHLEY
26 shall not be used in advertising or otherwise to promote the sale, use
27 or other dealings in this Software without prior written authorization
28 from Kaleb S. KEITHLEY
31 /* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
33 #ifdef HAVE_XORG_CONFIG_H
34 #include <xorg-config.h>
38 #include <X11/Xproto.h>
40 #include "dixstruct.h"
41 #include "extnsionst.h"
42 #include "xf86Extensions.h"
43 #include "scrnintstr.h"
45 #include <X11/extensions/xf86vmproto.h>
48 #include "vidmodeproc.h"
50 #include "protocol-versions.h"
52 #define DEFAULT_XF86VIDMODE_VERBOSITY 3
54 static int VidModeErrorBase
;
55 static DevPrivateKeyRec VidModeClientPrivateKeyRec
;
57 #define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
59 /* This holds the client's version information */
63 } VidModePrivRec
, *VidModePrivPtr
;
65 #define VM_GETPRIV(c) ((VidModePrivPtr) \
66 dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey))
67 #define VM_SETPRIV(c,p) \
68 dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p)
71 static unsigned char XF86VidModeReqCode
= 0;
74 /* The XF86VIDMODE_EVENTS code is far from complete */
76 #ifdef XF86VIDMODE_EVENTS
77 static int XF86VidModeEventBase
= 0;
79 static void SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent
* /* from */ , xXF86VidModeNotifyEvent
* /* to */
82 static RESTYPE EventType
; /* resource type for event masks */
84 typedef struct _XF86VidModeEvent
*XF86VidModeEventPtr
;
86 typedef struct _XF86VidModeEvent
{
87 XF86VidModeEventPtr next
;
92 } XF86VidModeEventRec
;
94 static int XF86VidModeFreeEvents();
96 typedef struct _XF86VidModeScreenPrivate
{
97 XF86VidModeEventPtr events
;
99 } XF86VidModeScreenPrivateRec
, *XF86VidModeScreenPrivatePtr
;
101 static DevPrivateKeyRec ScreenPrivateKeyRec
;
103 #define ScreenPrivateKey (&ScreenPrivateKeyRec)
105 #define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
106 dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
107 #define SetScreenPrivate(s,v) \
108 dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v)
109 #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
111 #define New(t) (malloc(sizeof (t)))
115 #define DEBUG_P(x) ErrorF(x"\n");
117 #define DEBUG_P(x) /**/
120 ClientMajorVersion(ClientPtr client
)
122 VidModePrivPtr pPriv
;
124 pPriv
= VM_GETPRIV(client
);
131 #ifdef XF86VIDMODE_EVENTS
133 CheckScreenPrivate(pScreen
)
137 SetupScreen(pScreen
);
141 if (!pPriv
->events
&& !pPriv
->hasWindow
) {
143 SetScreenPrivate(pScreen
, NULL
);
147 static XF86VidModeScreenPrivatePtr
148 MakeScreenPrivate(pScreen
)
152 SetupScreen(pScreen
);
156 pPriv
= New(XF86VidModeScreenPrivateRec
);
160 pPriv
->hasWindow
= FALSE
;
161 SetScreenPrivate(pScreen
, pPriv
);
166 getEventMask(ScreenPtr pScreen
, ClientPtr client
)
168 SetupScreen(pScreen
);
169 XF86VidModeEventPtr pEv
;
173 for (pEv
= pPriv
->events
; pEv
; pEv
= pEv
->next
)
174 if (pEv
->client
== client
)
180 setEventMask(ScreenPtr pScreen
, ClientPtr client
, unsigned long mask
)
182 SetupScreen(pScreen
);
183 XF86VidModeEventPtr pEv
, *pPrev
;
185 if (getEventMask(pScreen
, client
) == mask
)
188 pPriv
= MakeScreenPrivate(pScreen
);
192 for (pPrev
= &pPriv
->events
; pEv
= *pPrev
; pPrev
= &pEv
->next
)
193 if (pEv
->client
== client
)
198 CheckScreenPrivate(pScreen
);
202 pEv
= New(ScreenSaverEventRec
);
204 CheckScreenPrivate(pScreen
);
209 pEv
->client
= client
;
210 pEv
->screen
= pScreen
;
211 pEv
->resource
= FakeClientID(client
->index
);
219 XF86VidModeFreeEvents(pointer value
, XID id
)
221 XF86VidModeEventPtr pOld
= (XF86VidModeEventPtr
) value
;
222 ScreenPtr pScreen
= pOld
->screen
;
224 SetupScreen(pScreen
);
225 XF86VidModeEventPtr pEv
, *pPrev
;
229 for (pPrev
= &pPriv
->events
; pEv
= *pPrev
; pPrev
= &pEv
->next
)
236 CheckScreenPrivate(pScreen
);
241 SendXF86VidModeNotify(ScreenPtr pScreen
, int state
, Bool forced
)
243 XF86VidModeScreenPrivatePtr pPriv
;
245 xXF86VidModeNotifyEvent ev
;
248 UpdateCurrentTimeIf();
249 mask
= XF86VidModeNotifyMask
;
250 pScreen
= screenInfo
.screens
[pScreen
->myNum
];
251 pPriv
= GetScreenPrivate(pScreen
);
254 kind
= XF86VidModeModeChange
;
255 for (pEv
= pPriv
->events
; pEv
; pEv
= pEv
->next
) {
256 if (pEv
->mask
& mask
) {
257 XF86VidModeEventPtr pEv
= {
258 .type
= XF86VidModeNotify
+ XF86VidModeEventBase
,
260 .timestamp
= currentTime
.milliseconds
,
261 .root
= pScreen
->root
->drawable
.id
,
265 WriteEventsToClient(pEv
->client
, 1, (xEvent
*) &ev
);
271 SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent
* from
,
272 xXF86VidModeNotifyEvent
* to
)
274 to
->type
= from
->type
;
275 to
->state
= from
->state
;
276 cpswaps(from
->sequenceNumber
, to
->sequenceNumber
);
277 cpswapl(from
->timestamp
, to
->timestamp
);
278 cpswapl(from
->root
, to
->root
);
279 to
->kind
= from
->kind
;
280 to
->forced
= from
->forced
;
285 ProcXF86VidModeQueryVersion(ClientPtr client
)
287 xXF86VidModeQueryVersionReply rep
= {
289 .sequenceNumber
= client
->sequence
,
291 .majorVersion
= SERVER_XF86VIDMODE_MAJOR_VERSION
,
292 .minorVersion
= SERVER_XF86VIDMODE_MINOR_VERSION
295 DEBUG_P("XF86VidModeQueryVersion");
297 REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq
);
299 if (client
->swapped
) {
300 swaps(&rep
.sequenceNumber
);
302 swaps(&rep
.majorVersion
);
303 swaps(&rep
.minorVersion
);
305 WriteToClient(client
, sizeof(xXF86VidModeQueryVersionReply
), &rep
);
310 ProcXF86VidModeGetModeLine(ClientPtr client
)
312 REQUEST(xXF86VidModeGetModeLineReq
);
313 xXF86VidModeGetModeLineReply rep
= {
315 .sequenceNumber
= client
->sequence
321 DEBUG_P("XF86VidModeGetModeline");
323 ver
= ClientMajorVersion(client
);
324 REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq
);
327 rep
.length
= bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply
) -
328 SIZEOF(xGenericReply
));
331 rep
.length
= bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply
) -
332 SIZEOF(xGenericReply
));
335 if (stuff
->screen
>= screenInfo
.numScreens
)
338 if (!VidModeGetCurrentModeline(stuff
->screen
, &mode
, &dotClock
))
341 rep
.dotclock
= dotClock
;
342 rep
.hdisplay
= VidModeGetModeValue(mode
, VIDMODE_H_DISPLAY
);
343 rep
.hsyncstart
= VidModeGetModeValue(mode
, VIDMODE_H_SYNCSTART
);
344 rep
.hsyncend
= VidModeGetModeValue(mode
, VIDMODE_H_SYNCEND
);
345 rep
.htotal
= VidModeGetModeValue(mode
, VIDMODE_H_TOTAL
);
346 rep
.hskew
= VidModeGetModeValue(mode
, VIDMODE_H_SKEW
);
347 rep
.vdisplay
= VidModeGetModeValue(mode
, VIDMODE_V_DISPLAY
);
348 rep
.vsyncstart
= VidModeGetModeValue(mode
, VIDMODE_V_SYNCSTART
);
349 rep
.vsyncend
= VidModeGetModeValue(mode
, VIDMODE_V_SYNCEND
);
350 rep
.vtotal
= VidModeGetModeValue(mode
, VIDMODE_V_TOTAL
);
351 rep
.flags
= VidModeGetModeValue(mode
, VIDMODE_FLAGS
);
353 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
354 ErrorF("GetModeLine - scrn: %d clock: %ld\n",
355 stuff
->screen
, (unsigned long) rep
.dotclock
);
356 ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
357 rep
.hdisplay
, rep
.hsyncstart
, rep
.hsyncend
, rep
.htotal
);
358 ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
359 rep
.vdisplay
, rep
.vsyncstart
, rep
.vsyncend
,
360 rep
.vtotal
, (unsigned long) rep
.flags
);
364 * Older servers sometimes had server privates that the VidMode
365 * extention made available. So to be compatiable pretend that
366 * there are no server privates to pass to the client
370 if (client
->swapped
) {
371 swaps(&rep
.sequenceNumber
);
373 swapl(&rep
.dotclock
);
374 swaps(&rep
.hdisplay
);
375 swaps(&rep
.hsyncstart
);
376 swaps(&rep
.hsyncend
);
379 swaps(&rep
.vdisplay
);
380 swaps(&rep
.vsyncstart
);
381 swaps(&rep
.vsyncend
);
384 swapl(&rep
.privsize
);
387 xXF86OldVidModeGetModeLineReply oldrep
= {
389 .sequenceNumber
= rep
.sequenceNumber
,
390 .length
= rep
.length
,
391 .dotclock
= rep
.dotclock
,
392 .hdisplay
= rep
.hdisplay
,
393 .hsyncstart
= rep
.hsyncstart
,
394 .hsyncend
= rep
.hsyncend
,
395 .htotal
= rep
.htotal
,
396 .vdisplay
= rep
.vdisplay
,
397 .vsyncstart
= rep
.vsyncstart
,
398 .vsyncend
= rep
.vsyncend
,
399 .vtotal
= rep
.vtotal
,
401 .privsize
= rep
.privsize
403 WriteToClient(client
, sizeof(xXF86OldVidModeGetModeLineReply
), &oldrep
);
406 WriteToClient(client
, sizeof(xXF86VidModeGetModeLineReply
), &rep
);
412 ProcXF86VidModeGetAllModeLines(ClientPtr client
)
414 REQUEST(xXF86VidModeGetAllModeLinesReq
);
415 xXF86VidModeGetAllModeLinesReply rep
;
417 int modecount
, dotClock
;
420 DEBUG_P("XF86VidModeGetAllModelines");
422 REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq
);
424 if (stuff
->screen
>= screenInfo
.numScreens
)
427 ver
= ClientMajorVersion(client
);
429 modecount
= VidModeGetNumOfModes(stuff
->screen
);
431 return VidModeErrorBase
+ XF86VidModeExtensionDisabled
;
433 if (!VidModeGetFirstModeline(stuff
->screen
, &mode
, &dotClock
))
436 rep
= (xXF86VidModeGetAllModeLinesReply
) {
438 .length
= SIZEOF(xXF86VidModeGetAllModeLinesReply
) -
439 SIZEOF(xGenericReply
),
440 .sequenceNumber
= client
->sequence
,
441 .modecount
= modecount
444 rep
.length
+= modecount
* sizeof(xXF86OldVidModeModeInfo
);
446 rep
.length
+= modecount
* sizeof(xXF86VidModeModeInfo
);
448 if (client
->swapped
) {
449 swaps(&rep
.sequenceNumber
);
451 swapl(&rep
.modecount
);
453 WriteToClient(client
, sizeof(xXF86VidModeGetAllModeLinesReply
), &rep
);
456 xXF86VidModeModeInfo mdinf
= {
457 .dotclock
= dotClock
,
458 .hdisplay
= VidModeGetModeValue(mode
, VIDMODE_H_DISPLAY
),
459 .hsyncstart
= VidModeGetModeValue(mode
, VIDMODE_H_SYNCSTART
),
460 .hsyncend
= VidModeGetModeValue(mode
, VIDMODE_H_SYNCEND
),
461 .htotal
= VidModeGetModeValue(mode
, VIDMODE_H_TOTAL
),
462 .hskew
= VidModeGetModeValue(mode
, VIDMODE_H_SKEW
),
463 .vdisplay
= VidModeGetModeValue(mode
, VIDMODE_V_DISPLAY
),
464 .vsyncstart
= VidModeGetModeValue(mode
, VIDMODE_V_SYNCSTART
),
465 .vsyncend
= VidModeGetModeValue(mode
, VIDMODE_V_SYNCEND
),
466 .vtotal
= VidModeGetModeValue(mode
, VIDMODE_V_TOTAL
),
467 .flags
= VidModeGetModeValue(mode
, VIDMODE_FLAGS
),
470 if (client
->swapped
) {
471 swapl(&mdinf
.dotclock
);
472 swaps(&mdinf
.hdisplay
);
473 swaps(&mdinf
.hsyncstart
);
474 swaps(&mdinf
.hsyncend
);
475 swaps(&mdinf
.htotal
);
477 swaps(&mdinf
.vdisplay
);
478 swaps(&mdinf
.vsyncstart
);
479 swaps(&mdinf
.vsyncend
);
480 swaps(&mdinf
.vtotal
);
482 swapl(&mdinf
.privsize
);
485 xXF86OldVidModeModeInfo oldmdinf
= {
486 .dotclock
= mdinf
.dotclock
,
487 .hdisplay
= mdinf
.hdisplay
,
488 .hsyncstart
= mdinf
.hsyncstart
,
489 .hsyncend
= mdinf
.hsyncend
,
490 .htotal
= mdinf
.htotal
,
491 .vdisplay
= mdinf
.vdisplay
,
492 .vsyncstart
= mdinf
.vsyncstart
,
493 .vsyncend
= mdinf
.vsyncend
,
494 .vtotal
= mdinf
.vtotal
,
495 .flags
= mdinf
.flags
,
496 .privsize
= mdinf
.privsize
498 WriteToClient(client
, sizeof(xXF86OldVidModeModeInfo
), &oldmdinf
);
501 WriteToClient(client
, sizeof(xXF86VidModeModeInfo
), &mdinf
);
504 } while (VidModeGetNextModeline(stuff
->screen
, &mode
, &dotClock
));
509 #define MODEMATCH(mode,stuff) \
510 (VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay \
511 && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart \
512 && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND) == stuff->hsyncend \
513 && VidModeGetModeValue(mode, VIDMODE_H_TOTAL) == stuff->htotal \
514 && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY) == stuff->vdisplay \
515 && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART) == stuff->vsyncstart \
516 && VidModeGetModeValue(mode, VIDMODE_V_SYNCEND) == stuff->vsyncend \
517 && VidModeGetModeValue(mode, VIDMODE_V_TOTAL) == stuff->vtotal \
518 && VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags )
521 ProcXF86VidModeAddModeLine(ClientPtr client
)
523 REQUEST(xXF86VidModeAddModeLineReq
);
524 xXF86OldVidModeAddModeLineReq
*oldstuff
=
525 (xXF86OldVidModeAddModeLineReq
*) client
->requestBuffer
;
526 xXF86VidModeAddModeLineReq newstuff
;
532 DEBUG_P("XF86VidModeAddModeline");
534 ver
= ClientMajorVersion(client
);
536 /* convert from old format */
538 stuff
->length
= oldstuff
->length
;
539 stuff
->screen
= oldstuff
->screen
;
540 stuff
->dotclock
= oldstuff
->dotclock
;
541 stuff
->hdisplay
= oldstuff
->hdisplay
;
542 stuff
->hsyncstart
= oldstuff
->hsyncstart
;
543 stuff
->hsyncend
= oldstuff
->hsyncend
;
544 stuff
->htotal
= oldstuff
->htotal
;
546 stuff
->vdisplay
= oldstuff
->vdisplay
;
547 stuff
->vsyncstart
= oldstuff
->vsyncstart
;
548 stuff
->vsyncend
= oldstuff
->vsyncend
;
549 stuff
->vtotal
= oldstuff
->vtotal
;
550 stuff
->flags
= oldstuff
->flags
;
551 stuff
->privsize
= oldstuff
->privsize
;
552 stuff
->after_dotclock
= oldstuff
->after_dotclock
;
553 stuff
->after_hdisplay
= oldstuff
->after_hdisplay
;
554 stuff
->after_hsyncstart
= oldstuff
->after_hsyncstart
;
555 stuff
->after_hsyncend
= oldstuff
->after_hsyncend
;
556 stuff
->after_htotal
= oldstuff
->after_htotal
;
557 stuff
->after_hskew
= 0;
558 stuff
->after_vdisplay
= oldstuff
->after_vdisplay
;
559 stuff
->after_vsyncstart
= oldstuff
->after_vsyncstart
;
560 stuff
->after_vsyncend
= oldstuff
->after_vsyncend
;
561 stuff
->after_vtotal
= oldstuff
->after_vtotal
;
562 stuff
->after_flags
= oldstuff
->after_flags
;
564 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
565 ErrorF("AddModeLine - scrn: %d clock: %ld\n",
566 (int) stuff
->screen
, (unsigned long) stuff
->dotclock
);
567 ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
568 stuff
->hdisplay
, stuff
->hsyncstart
,
569 stuff
->hsyncend
, stuff
->htotal
);
570 ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
571 stuff
->vdisplay
, stuff
->vsyncstart
, stuff
->vsyncend
,
572 stuff
->vtotal
, (unsigned long) stuff
->flags
);
573 ErrorF(" after - scrn: %d clock: %ld\n",
574 (int) stuff
->screen
, (unsigned long) stuff
->after_dotclock
);
575 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
576 stuff
->after_hdisplay
, stuff
->after_hsyncstart
,
577 stuff
->after_hsyncend
, stuff
->after_htotal
);
578 ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
579 stuff
->after_vdisplay
, stuff
->after_vsyncstart
,
580 stuff
->after_vsyncend
, stuff
->after_vtotal
,
581 (unsigned long) stuff
->after_flags
);
585 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq
);
588 bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq
));
591 REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq
);
594 bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq
));
596 if (len
!= stuff
->privsize
)
599 if (stuff
->screen
>= screenInfo
.numScreens
)
602 if (stuff
->hsyncstart
< stuff
->hdisplay
||
603 stuff
->hsyncend
< stuff
->hsyncstart
||
604 stuff
->htotal
< stuff
->hsyncend
||
605 stuff
->vsyncstart
< stuff
->vdisplay
||
606 stuff
->vsyncend
< stuff
->vsyncstart
|| stuff
->vtotal
< stuff
->vsyncend
)
609 if (stuff
->after_hsyncstart
< stuff
->after_hdisplay
||
610 stuff
->after_hsyncend
< stuff
->after_hsyncstart
||
611 stuff
->after_htotal
< stuff
->after_hsyncend
||
612 stuff
->after_vsyncstart
< stuff
->after_vdisplay
||
613 stuff
->after_vsyncend
< stuff
->after_vsyncstart
||
614 stuff
->after_vtotal
< stuff
->after_vsyncend
)
617 if (stuff
->after_htotal
!= 0 || stuff
->after_vtotal
!= 0) {
620 if (VidModeGetFirstModeline(stuff
->screen
, &mode
, &dotClock
)) {
622 if ((VidModeGetDotClock(stuff
->screen
, stuff
->dotclock
)
623 == dotClock
) && MODEMATCH(mode
, stuff
)) {
627 } while (VidModeGetNextModeline(stuff
->screen
, &mode
, &dotClock
));
633 mode
= VidModeCreateMode();
637 VidModeSetModeValue(mode
, VIDMODE_CLOCK
, stuff
->dotclock
);
638 VidModeSetModeValue(mode
, VIDMODE_H_DISPLAY
, stuff
->hdisplay
);
639 VidModeSetModeValue(mode
, VIDMODE_H_SYNCSTART
, stuff
->hsyncstart
);
640 VidModeSetModeValue(mode
, VIDMODE_H_SYNCEND
, stuff
->hsyncend
);
641 VidModeSetModeValue(mode
, VIDMODE_H_TOTAL
, stuff
->htotal
);
642 VidModeSetModeValue(mode
, VIDMODE_H_SKEW
, stuff
->hskew
);
643 VidModeSetModeValue(mode
, VIDMODE_V_DISPLAY
, stuff
->vdisplay
);
644 VidModeSetModeValue(mode
, VIDMODE_V_SYNCSTART
, stuff
->vsyncstart
);
645 VidModeSetModeValue(mode
, VIDMODE_V_SYNCEND
, stuff
->vsyncend
);
646 VidModeSetModeValue(mode
, VIDMODE_V_TOTAL
, stuff
->vtotal
);
647 VidModeSetModeValue(mode
, VIDMODE_FLAGS
, stuff
->flags
);
650 ErrorF("AddModeLine - Privates in request have been ignored\n");
652 /* Check that the mode is consistent with the monitor specs */
653 switch (VidModeCheckModeForMonitor(stuff
->screen
, mode
)) {
659 return VidModeErrorBase
+ XF86VidModeBadHTimings
;
663 return VidModeErrorBase
+ XF86VidModeBadVTimings
;
666 return VidModeErrorBase
+ XF86VidModeModeUnsuitable
;
669 /* Check that the driver is happy with the mode */
670 if (VidModeCheckModeForDriver(stuff
->screen
, mode
) != MODE_OK
) {
672 return VidModeErrorBase
+ XF86VidModeModeUnsuitable
;
675 VidModeSetCrtcForMode(stuff
->screen
, mode
);
677 VidModeAddModeline(stuff
->screen
, mode
);
679 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
)
680 ErrorF("AddModeLine - Succeeded\n");
685 ProcXF86VidModeDeleteModeLine(ClientPtr client
)
687 REQUEST(xXF86VidModeDeleteModeLineReq
);
688 xXF86OldVidModeDeleteModeLineReq
*oldstuff
=
689 (xXF86OldVidModeDeleteModeLineReq
*) client
->requestBuffer
;
690 xXF86VidModeDeleteModeLineReq newstuff
;
695 DEBUG_P("XF86VidModeDeleteModeline");
697 ver
= ClientMajorVersion(client
);
699 /* convert from old format */
701 stuff
->length
= oldstuff
->length
;
702 stuff
->screen
= oldstuff
->screen
;
703 stuff
->dotclock
= oldstuff
->dotclock
;
704 stuff
->hdisplay
= oldstuff
->hdisplay
;
705 stuff
->hsyncstart
= oldstuff
->hsyncstart
;
706 stuff
->hsyncend
= oldstuff
->hsyncend
;
707 stuff
->htotal
= oldstuff
->htotal
;
709 stuff
->vdisplay
= oldstuff
->vdisplay
;
710 stuff
->vsyncstart
= oldstuff
->vsyncstart
;
711 stuff
->vsyncend
= oldstuff
->vsyncend
;
712 stuff
->vtotal
= oldstuff
->vtotal
;
713 stuff
->flags
= oldstuff
->flags
;
714 stuff
->privsize
= oldstuff
->privsize
;
716 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
717 ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
718 (int) stuff
->screen
, (unsigned long) stuff
->dotclock
);
719 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
720 stuff
->hdisplay
, stuff
->hsyncstart
,
721 stuff
->hsyncend
, stuff
->htotal
);
723 (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
724 stuff
->vdisplay
, stuff
->vsyncstart
, stuff
->vsyncend
, stuff
->vtotal
,
725 (unsigned long) stuff
->flags
);
729 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq
);
732 bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq
));
735 REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq
);
738 bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq
));
740 if (len
!= stuff
->privsize
) {
741 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
742 ErrorF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
743 "len = %d, length = %d\n",
744 (unsigned long) client
->req_len
,
745 (int) sizeof(xXF86VidModeDeleteModeLineReq
) >> 2,
746 (unsigned long) stuff
->privsize
, len
, stuff
->length
);
751 if (stuff
->screen
>= screenInfo
.numScreens
)
754 if (!VidModeGetCurrentModeline(stuff
->screen
, &mode
, &dotClock
))
757 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
758 ErrorF("Checking against clock: %d (%d)\n",
759 VidModeGetModeValue(mode
, VIDMODE_CLOCK
), dotClock
);
760 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
761 VidModeGetModeValue(mode
, VIDMODE_H_DISPLAY
),
762 VidModeGetModeValue(mode
, VIDMODE_H_SYNCSTART
),
763 VidModeGetModeValue(mode
, VIDMODE_H_SYNCEND
),
764 VidModeGetModeValue(mode
, VIDMODE_H_TOTAL
));
766 (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
767 VidModeGetModeValue(mode
, VIDMODE_V_DISPLAY
),
768 VidModeGetModeValue(mode
, VIDMODE_V_SYNCSTART
),
769 VidModeGetModeValue(mode
, VIDMODE_V_SYNCEND
),
770 VidModeGetModeValue(mode
, VIDMODE_V_TOTAL
),
771 VidModeGetModeValue(mode
, VIDMODE_FLAGS
));
773 if ((VidModeGetDotClock(stuff
->screen
, stuff
->dotclock
) == dotClock
) &&
774 MODEMATCH(mode
, stuff
))
777 if (!VidModeGetFirstModeline(stuff
->screen
, &mode
, &dotClock
))
781 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
782 ErrorF("Checking against clock: %d (%d)\n",
783 VidModeGetModeValue(mode
, VIDMODE_CLOCK
), dotClock
);
784 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
785 VidModeGetModeValue(mode
, VIDMODE_H_DISPLAY
),
786 VidModeGetModeValue(mode
, VIDMODE_H_SYNCSTART
),
787 VidModeGetModeValue(mode
, VIDMODE_H_SYNCEND
),
788 VidModeGetModeValue(mode
, VIDMODE_H_TOTAL
));
790 (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
791 VidModeGetModeValue(mode
, VIDMODE_V_DISPLAY
),
792 VidModeGetModeValue(mode
, VIDMODE_V_SYNCSTART
),
793 VidModeGetModeValue(mode
, VIDMODE_V_SYNCEND
),
794 VidModeGetModeValue(mode
, VIDMODE_V_TOTAL
),
795 VidModeGetModeValue(mode
, VIDMODE_FLAGS
));
797 if ((VidModeGetDotClock(stuff
->screen
, stuff
->dotclock
) == dotClock
) &&
798 MODEMATCH(mode
, stuff
)) {
799 VidModeDeleteModeline(stuff
->screen
, mode
);
800 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
)
801 ErrorF("DeleteModeLine - Succeeded\n");
804 } while (VidModeGetNextModeline(stuff
->screen
, &mode
, &dotClock
));
810 ProcXF86VidModeModModeLine(ClientPtr client
)
812 REQUEST(xXF86VidModeModModeLineReq
);
813 xXF86OldVidModeModModeLineReq
*oldstuff
=
814 (xXF86OldVidModeModModeLineReq
*) client
->requestBuffer
;
815 xXF86VidModeModModeLineReq newstuff
;
816 pointer mode
, modetmp
;
820 DEBUG_P("XF86VidModeModModeline");
822 ver
= ClientMajorVersion(client
);
824 /* convert from old format */
826 stuff
->length
= oldstuff
->length
;
827 stuff
->screen
= oldstuff
->screen
;
828 stuff
->hdisplay
= oldstuff
->hdisplay
;
829 stuff
->hsyncstart
= oldstuff
->hsyncstart
;
830 stuff
->hsyncend
= oldstuff
->hsyncend
;
831 stuff
->htotal
= oldstuff
->htotal
;
833 stuff
->vdisplay
= oldstuff
->vdisplay
;
834 stuff
->vsyncstart
= oldstuff
->vsyncstart
;
835 stuff
->vsyncend
= oldstuff
->vsyncend
;
836 stuff
->vtotal
= oldstuff
->vtotal
;
837 stuff
->flags
= oldstuff
->flags
;
838 stuff
->privsize
= oldstuff
->privsize
;
840 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
841 ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
842 (int) stuff
->screen
, stuff
->hdisplay
, stuff
->hsyncstart
,
843 stuff
->hsyncend
, stuff
->htotal
);
844 ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
845 stuff
->vdisplay
, stuff
->vsyncstart
, stuff
->vsyncend
,
846 stuff
->vtotal
, (unsigned long) stuff
->flags
);
850 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq
);
853 bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq
));
856 REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq
);
859 bytes_to_int32(sizeof(xXF86VidModeModModeLineReq
));
861 if (len
!= stuff
->privsize
)
864 if (stuff
->hsyncstart
< stuff
->hdisplay
||
865 stuff
->hsyncend
< stuff
->hsyncstart
||
866 stuff
->htotal
< stuff
->hsyncend
||
867 stuff
->vsyncstart
< stuff
->vdisplay
||
868 stuff
->vsyncend
< stuff
->vsyncstart
|| stuff
->vtotal
< stuff
->vsyncend
)
871 if (stuff
->screen
>= screenInfo
.numScreens
)
874 if (!VidModeGetCurrentModeline(stuff
->screen
, &mode
, &dotClock
))
877 modetmp
= VidModeCreateMode();
878 VidModeCopyMode(mode
, modetmp
);
880 VidModeSetModeValue(modetmp
, VIDMODE_H_DISPLAY
, stuff
->hdisplay
);
881 VidModeSetModeValue(modetmp
, VIDMODE_H_SYNCSTART
, stuff
->hsyncstart
);
882 VidModeSetModeValue(modetmp
, VIDMODE_H_SYNCEND
, stuff
->hsyncend
);
883 VidModeSetModeValue(modetmp
, VIDMODE_H_TOTAL
, stuff
->htotal
);
884 VidModeSetModeValue(modetmp
, VIDMODE_H_SKEW
, stuff
->hskew
);
885 VidModeSetModeValue(modetmp
, VIDMODE_V_DISPLAY
, stuff
->vdisplay
);
886 VidModeSetModeValue(modetmp
, VIDMODE_V_SYNCSTART
, stuff
->vsyncstart
);
887 VidModeSetModeValue(modetmp
, VIDMODE_V_SYNCEND
, stuff
->vsyncend
);
888 VidModeSetModeValue(modetmp
, VIDMODE_V_TOTAL
, stuff
->vtotal
);
889 VidModeSetModeValue(modetmp
, VIDMODE_FLAGS
, stuff
->flags
);
892 ErrorF("ModModeLine - Privates in request have been ignored\n");
894 /* Check that the mode is consistent with the monitor specs */
895 switch (VidModeCheckModeForMonitor(stuff
->screen
, modetmp
)) {
901 return VidModeErrorBase
+ XF86VidModeBadHTimings
;
905 return VidModeErrorBase
+ XF86VidModeBadVTimings
;
908 return VidModeErrorBase
+ XF86VidModeModeUnsuitable
;
911 /* Check that the driver is happy with the mode */
912 if (VidModeCheckModeForDriver(stuff
->screen
, modetmp
) != MODE_OK
) {
914 return VidModeErrorBase
+ XF86VidModeModeUnsuitable
;
918 VidModeSetModeValue(mode
, VIDMODE_H_DISPLAY
, stuff
->hdisplay
);
919 VidModeSetModeValue(mode
, VIDMODE_H_SYNCSTART
, stuff
->hsyncstart
);
920 VidModeSetModeValue(mode
, VIDMODE_H_SYNCEND
, stuff
->hsyncend
);
921 VidModeSetModeValue(mode
, VIDMODE_H_TOTAL
, stuff
->htotal
);
922 VidModeSetModeValue(mode
, VIDMODE_H_SKEW
, stuff
->hskew
);
923 VidModeSetModeValue(mode
, VIDMODE_V_DISPLAY
, stuff
->vdisplay
);
924 VidModeSetModeValue(mode
, VIDMODE_V_SYNCSTART
, stuff
->vsyncstart
);
925 VidModeSetModeValue(mode
, VIDMODE_V_SYNCEND
, stuff
->vsyncend
);
926 VidModeSetModeValue(mode
, VIDMODE_V_TOTAL
, stuff
->vtotal
);
927 VidModeSetModeValue(mode
, VIDMODE_FLAGS
, stuff
->flags
);
929 VidModeSetCrtcForMode(stuff
->screen
, mode
);
930 VidModeSwitchMode(stuff
->screen
, mode
);
932 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
)
933 ErrorF("ModModeLine - Succeeded\n");
938 ProcXF86VidModeValidateModeLine(ClientPtr client
)
940 REQUEST(xXF86VidModeValidateModeLineReq
);
941 xXF86OldVidModeValidateModeLineReq
*oldstuff
=
942 (xXF86OldVidModeValidateModeLineReq
*) client
->requestBuffer
;
943 xXF86VidModeValidateModeLineReq newstuff
;
944 xXF86VidModeValidateModeLineReply rep
;
945 pointer mode
, modetmp
= NULL
;
946 int len
, status
, dotClock
;
949 DEBUG_P("XF86VidModeValidateModeline");
951 ver
= ClientMajorVersion(client
);
953 /* convert from old format */
955 stuff
->length
= oldstuff
->length
;
956 stuff
->screen
= oldstuff
->screen
;
957 stuff
->dotclock
= oldstuff
->dotclock
;
958 stuff
->hdisplay
= oldstuff
->hdisplay
;
959 stuff
->hsyncstart
= oldstuff
->hsyncstart
;
960 stuff
->hsyncend
= oldstuff
->hsyncend
;
961 stuff
->htotal
= oldstuff
->htotal
;
963 stuff
->vdisplay
= oldstuff
->vdisplay
;
964 stuff
->vsyncstart
= oldstuff
->vsyncstart
;
965 stuff
->vsyncend
= oldstuff
->vsyncend
;
966 stuff
->vtotal
= oldstuff
->vtotal
;
967 stuff
->flags
= oldstuff
->flags
;
968 stuff
->privsize
= oldstuff
->privsize
;
970 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
971 ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
972 (int) stuff
->screen
, (unsigned long) stuff
->dotclock
);
973 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
974 stuff
->hdisplay
, stuff
->hsyncstart
,
975 stuff
->hsyncend
, stuff
->htotal
);
977 (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
978 stuff
->vdisplay
, stuff
->vsyncstart
, stuff
->vsyncend
, stuff
->vtotal
,
979 (unsigned long) stuff
->flags
);
983 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq
);
984 len
= client
->req_len
-
985 bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq
));
988 REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq
);
991 bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq
));
993 if (len
!= stuff
->privsize
)
996 if (stuff
->screen
>= screenInfo
.numScreens
)
1001 if (stuff
->hsyncstart
< stuff
->hdisplay
||
1002 stuff
->hsyncend
< stuff
->hsyncstart
||
1003 stuff
->htotal
< stuff
->hsyncend
||
1004 stuff
->vsyncstart
< stuff
->vdisplay
||
1005 stuff
->vsyncend
< stuff
->vsyncstart
||
1006 stuff
->vtotal
< stuff
->vsyncend
) {
1011 if (!VidModeGetCurrentModeline(stuff
->screen
, &mode
, &dotClock
))
1014 modetmp
= VidModeCreateMode();
1015 VidModeCopyMode(mode
, modetmp
);
1017 VidModeSetModeValue(modetmp
, VIDMODE_H_DISPLAY
, stuff
->hdisplay
);
1018 VidModeSetModeValue(modetmp
, VIDMODE_H_SYNCSTART
, stuff
->hsyncstart
);
1019 VidModeSetModeValue(modetmp
, VIDMODE_H_SYNCEND
, stuff
->hsyncend
);
1020 VidModeSetModeValue(modetmp
, VIDMODE_H_TOTAL
, stuff
->htotal
);
1021 VidModeSetModeValue(modetmp
, VIDMODE_H_SKEW
, stuff
->hskew
);
1022 VidModeSetModeValue(modetmp
, VIDMODE_V_DISPLAY
, stuff
->vdisplay
);
1023 VidModeSetModeValue(modetmp
, VIDMODE_V_SYNCSTART
, stuff
->vsyncstart
);
1024 VidModeSetModeValue(modetmp
, VIDMODE_V_SYNCEND
, stuff
->vsyncend
);
1025 VidModeSetModeValue(modetmp
, VIDMODE_V_TOTAL
, stuff
->vtotal
);
1026 VidModeSetModeValue(modetmp
, VIDMODE_FLAGS
, stuff
->flags
);
1027 if (stuff
->privsize
)
1028 ErrorF("ValidateModeLine - Privates in request have been ignored\n");
1030 /* Check that the mode is consistent with the monitor specs */
1032 VidModeCheckModeForMonitor(stuff
->screen
, modetmp
)) != MODE_OK
)
1035 /* Check that the driver is happy with the mode */
1036 status
= VidModeCheckModeForDriver(stuff
->screen
, modetmp
);
1041 rep
= (xXF86VidModeValidateModeLineReply
) {
1043 .sequenceNumber
= client
->sequence
,
1044 .length
= bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply
)
1045 - SIZEOF(xGenericReply
)),
1048 if (client
->swapped
) {
1049 swaps(&rep
.sequenceNumber
);
1053 WriteToClient(client
, sizeof(xXF86VidModeValidateModeLineReply
), &rep
);
1054 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
)
1055 ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status
);
1060 ProcXF86VidModeSwitchMode(ClientPtr client
)
1062 REQUEST(xXF86VidModeSwitchModeReq
);
1064 DEBUG_P("XF86VidModeSwitchMode");
1066 REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq
);
1068 if (stuff
->screen
>= screenInfo
.numScreens
)
1071 VidModeZoomViewport(stuff
->screen
, (short) stuff
->zoom
);
1077 ProcXF86VidModeSwitchToMode(ClientPtr client
)
1079 REQUEST(xXF86VidModeSwitchToModeReq
);
1080 xXF86OldVidModeSwitchToModeReq
*oldstuff
=
1081 (xXF86OldVidModeSwitchToModeReq
*) client
->requestBuffer
;
1082 xXF86VidModeSwitchToModeReq newstuff
;
1087 DEBUG_P("XF86VidModeSwitchToMode");
1089 ver
= ClientMajorVersion(client
);
1091 /* convert from old format */
1093 stuff
->length
= oldstuff
->length
;
1094 stuff
->screen
= oldstuff
->screen
;
1095 stuff
->dotclock
= oldstuff
->dotclock
;
1096 stuff
->hdisplay
= oldstuff
->hdisplay
;
1097 stuff
->hsyncstart
= oldstuff
->hsyncstart
;
1098 stuff
->hsyncend
= oldstuff
->hsyncend
;
1099 stuff
->htotal
= oldstuff
->htotal
;
1101 stuff
->vdisplay
= oldstuff
->vdisplay
;
1102 stuff
->vsyncstart
= oldstuff
->vsyncstart
;
1103 stuff
->vsyncend
= oldstuff
->vsyncend
;
1104 stuff
->vtotal
= oldstuff
->vtotal
;
1105 stuff
->flags
= oldstuff
->flags
;
1106 stuff
->privsize
= oldstuff
->privsize
;
1108 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
1109 ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
1110 (int) stuff
->screen
, (unsigned long) stuff
->dotclock
);
1111 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
1112 stuff
->hdisplay
, stuff
->hsyncstart
,
1113 stuff
->hsyncend
, stuff
->htotal
);
1115 (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
1116 stuff
->vdisplay
, stuff
->vsyncstart
, stuff
->vsyncend
, stuff
->vtotal
,
1117 (unsigned long) stuff
->flags
);
1121 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq
);
1124 bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq
));
1127 REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq
);
1130 bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq
));
1132 if (len
!= stuff
->privsize
)
1135 if (stuff
->screen
>= screenInfo
.numScreens
)
1138 if (!VidModeGetCurrentModeline(stuff
->screen
, &mode
, &dotClock
))
1141 if ((VidModeGetDotClock(stuff
->screen
, stuff
->dotclock
) == dotClock
)
1142 && MODEMATCH(mode
, stuff
))
1145 if (!VidModeGetFirstModeline(stuff
->screen
, &mode
, &dotClock
))
1149 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
) {
1150 ErrorF("Checking against clock: %d (%d)\n",
1151 VidModeGetModeValue(mode
, VIDMODE_CLOCK
), dotClock
);
1152 ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
1153 VidModeGetModeValue(mode
, VIDMODE_H_DISPLAY
),
1154 VidModeGetModeValue(mode
, VIDMODE_H_SYNCSTART
),
1155 VidModeGetModeValue(mode
, VIDMODE_H_SYNCEND
),
1156 VidModeGetModeValue(mode
, VIDMODE_H_TOTAL
));
1158 (" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
1159 VidModeGetModeValue(mode
, VIDMODE_V_DISPLAY
),
1160 VidModeGetModeValue(mode
, VIDMODE_V_SYNCSTART
),
1161 VidModeGetModeValue(mode
, VIDMODE_V_SYNCEND
),
1162 VidModeGetModeValue(mode
, VIDMODE_V_TOTAL
),
1163 VidModeGetModeValue(mode
, VIDMODE_FLAGS
));
1165 if ((VidModeGetDotClock(stuff
->screen
, stuff
->dotclock
) == dotClock
) &&
1166 MODEMATCH(mode
, stuff
)) {
1168 if (!VidModeSwitchMode(stuff
->screen
, mode
))
1171 if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY
)
1172 ErrorF("SwitchToMode - Succeeded\n");
1175 } while (VidModeGetNextModeline(stuff
->screen
, &mode
, &dotClock
));
1181 ProcXF86VidModeLockModeSwitch(ClientPtr client
)
1183 REQUEST(xXF86VidModeLockModeSwitchReq
);
1185 REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq
);
1187 DEBUG_P("XF86VidModeLockModeSwitch");
1189 if (stuff
->screen
>= screenInfo
.numScreens
)
1192 if (!VidModeLockZoom(stuff
->screen
, (short) stuff
->lock
))
1193 return VidModeErrorBase
+ XF86VidModeZoomLocked
;
1199 ProcXF86VidModeGetMonitor(ClientPtr client
)
1201 REQUEST(xXF86VidModeGetMonitorReq
);
1202 xXF86VidModeGetMonitorReply rep
= {
1204 .sequenceNumber
= client
->sequence
1206 CARD32
*hsyncdata
, *vsyncdata
;
1207 int i
, nHsync
, nVrefresh
;
1210 DEBUG_P("XF86VidModeGetMonitor");
1212 REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq
);
1214 if (stuff
->screen
>= screenInfo
.numScreens
)
1217 if (!VidModeGetMonitor(stuff
->screen
, &monitor
))
1220 nHsync
= VidModeGetMonitorValue(monitor
, VIDMODE_MON_NHSYNC
, 0).i
;
1221 nVrefresh
= VidModeGetMonitorValue(monitor
, VIDMODE_MON_NVREFRESH
, 0).i
;
1223 if ((char *) (VidModeGetMonitorValue(monitor
, VIDMODE_MON_VENDOR
, 0)).ptr
)
1224 rep
.vendorLength
= strlen((char *) (VidModeGetMonitorValue(monitor
,
1228 rep
.vendorLength
= 0;
1229 if ((char *) (VidModeGetMonitorValue(monitor
, VIDMODE_MON_MODEL
, 0)).ptr
)
1230 rep
.modelLength
= strlen((char *) (VidModeGetMonitorValue(monitor
,
1234 rep
.modelLength
= 0;
1236 bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply
) -
1237 SIZEOF(xGenericReply
) + (nHsync
+
1238 nVrefresh
) * sizeof(CARD32
) +
1239 pad_to_int32(rep
.vendorLength
) +
1240 pad_to_int32(rep
.modelLength
));
1241 rep
.nhsync
= nHsync
;
1242 rep
.nvsync
= nVrefresh
;
1243 hsyncdata
= malloc(nHsync
* sizeof(CARD32
));
1247 vsyncdata
= malloc(nVrefresh
* sizeof(CARD32
));
1254 for (i
= 0; i
< nHsync
; i
++) {
1255 hsyncdata
[i
] = (unsigned short) (VidModeGetMonitorValue(monitor
,
1256 VIDMODE_MON_HSYNC_LO
,
1259 short) (VidModeGetMonitorValue(monitor
, VIDMODE_MON_HSYNC_HI
,
1262 for (i
= 0; i
< nVrefresh
; i
++) {
1263 vsyncdata
[i
] = (unsigned short) (VidModeGetMonitorValue(monitor
,
1264 VIDMODE_MON_VREFRESH_LO
,
1267 short) (VidModeGetMonitorValue(monitor
, VIDMODE_MON_VREFRESH_HI
,
1271 if (client
->swapped
) {
1272 swaps(&rep
.sequenceNumber
);
1275 WriteToClient(client
, SIZEOF(xXF86VidModeGetMonitorReply
), &rep
);
1276 client
->pSwapReplyFunc
= (ReplySwapPtr
) Swap32Write
;
1277 WriteSwappedDataToClient(client
, nHsync
* sizeof(CARD32
), hsyncdata
);
1278 WriteSwappedDataToClient(client
, nVrefresh
* sizeof(CARD32
), vsyncdata
);
1279 if (rep
.vendorLength
)
1280 WriteToClient(client
, rep
.vendorLength
,
1281 (VidModeGetMonitorValue(monitor
, VIDMODE_MON_VENDOR
, 0)).ptr
);
1282 if (rep
.modelLength
)
1283 WriteToClient(client
, rep
.modelLength
,
1284 (VidModeGetMonitorValue(monitor
, VIDMODE_MON_MODEL
, 0)).ptr
);
1293 ProcXF86VidModeGetViewPort(ClientPtr client
)
1295 REQUEST(xXF86VidModeGetViewPortReq
);
1296 xXF86VidModeGetViewPortReply rep
;
1299 DEBUG_P("XF86VidModeGetViewPort");
1301 REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq
);
1303 if (stuff
->screen
>= screenInfo
.numScreens
)
1306 VidModeGetViewPort(stuff
->screen
, &x
, &y
);
1308 rep
= (xXF86VidModeGetViewPortReply
) {
1310 .sequenceNumber
= client
->sequence
,
1316 if (client
->swapped
) {
1317 swaps(&rep
.sequenceNumber
);
1322 WriteToClient(client
, SIZEOF(xXF86VidModeGetViewPortReply
), &rep
);
1327 ProcXF86VidModeSetViewPort(ClientPtr client
)
1329 REQUEST(xXF86VidModeSetViewPortReq
);
1331 DEBUG_P("XF86VidModeSetViewPort");
1333 REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq
);
1335 if (stuff
->screen
>= screenInfo
.numScreens
)
1338 if (!VidModeSetViewPort(stuff
->screen
, stuff
->x
, stuff
->y
))
1345 ProcXF86VidModeGetDotClocks(ClientPtr client
)
1347 REQUEST(xXF86VidModeGetDotClocksReq
);
1348 xXF86VidModeGetDotClocksReply rep
;
1355 DEBUG_P("XF86VidModeGetDotClocks");
1357 REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq
);
1359 if (stuff
->screen
>= screenInfo
.numScreens
)
1362 numClocks
= VidModeGetNumOfClocks(stuff
->screen
, &ClockProg
);
1364 rep
= (xXF86VidModeGetDotClocksReply
) {
1366 .sequenceNumber
= client
->sequence
,
1367 .length
= bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply
)
1368 - SIZEOF(xGenericReply
) + numClocks
),
1369 .clocks
= numClocks
,
1370 .maxclocks
= MAXCLOCKS
,
1375 Clocks
= calloc(numClocks
, sizeof(int));
1378 if (!VidModeGetClocks(stuff
->screen
, Clocks
)) {
1384 rep
.flags
|= CLKFLAG_PROGRAMABLE
;
1386 if (client
->swapped
) {
1387 swaps(&rep
.sequenceNumber
);
1390 swapl(&rep
.maxclocks
);
1393 WriteToClient(client
, sizeof(xXF86VidModeGetDotClocksReply
), &rep
);
1395 for (n
= 0; n
< numClocks
; n
++) {
1396 dotclock
= *Clocks
++;
1397 if (client
->swapped
) {
1398 WriteSwappedDataToClient(client
, 4, (char *) &dotclock
);
1401 WriteToClient(client
, 4, &dotclock
);
1411 ProcXF86VidModeSetGamma(ClientPtr client
)
1413 REQUEST(xXF86VidModeSetGammaReq
);
1415 DEBUG_P("XF86VidModeSetGamma");
1417 REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq
);
1419 if (stuff
->screen
>= screenInfo
.numScreens
)
1422 if (!VidModeSetGamma(stuff
->screen
, ((float) stuff
->red
) / 10000.,
1423 ((float) stuff
->green
) / 10000.,
1424 ((float) stuff
->blue
) / 10000.))
1431 ProcXF86VidModeGetGamma(ClientPtr client
)
1433 REQUEST(xXF86VidModeGetGammaReq
);
1434 xXF86VidModeGetGammaReply rep
;
1435 float red
, green
, blue
;
1437 DEBUG_P("XF86VidModeGetGamma");
1439 REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq
);
1441 if (stuff
->screen
>= screenInfo
.numScreens
)
1444 if (!VidModeGetGamma(stuff
->screen
, &red
, &green
, &blue
))
1446 rep
= (xXF86VidModeGetGammaReply
) {
1448 .sequenceNumber
= client
->sequence
,
1450 .red
= (CARD32
) (red
* 10000.),
1451 .green
= (CARD32
) (green
* 10000.),
1452 .blue
= (CARD32
) (blue
* 10000.)
1454 if (client
->swapped
) {
1455 swaps(&rep
.sequenceNumber
);
1461 WriteToClient(client
, sizeof(xXF86VidModeGetGammaReply
), &rep
);
1467 ProcXF86VidModeSetGammaRamp(ClientPtr client
)
1472 REQUEST(xXF86VidModeSetGammaRampReq
);
1474 if (stuff
->screen
>= screenInfo
.numScreens
)
1477 if (stuff
->size
!= VidModeGetGammaRampSize(stuff
->screen
))
1480 length
= (stuff
->size
+ 1) & ~1;
1482 REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq
, length
* 6);
1484 r
= (CARD16
*) &stuff
[1];
1488 if (!VidModeSetGammaRamp(stuff
->screen
, stuff
->size
, r
, g
, b
))
1495 ProcXF86VidModeGetGammaRamp(ClientPtr client
)
1497 CARD16
*ramp
= NULL
;
1500 xXF86VidModeGetGammaRampReply rep
;
1502 REQUEST(xXF86VidModeGetGammaRampReq
);
1504 REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq
);
1506 if (stuff
->screen
>= screenInfo
.numScreens
)
1509 if (stuff
->size
!= VidModeGetGammaRampSize(stuff
->screen
))
1512 length
= (stuff
->size
+ 1) & ~1;
1515 ramplen
= length
* 3 * sizeof(CARD16
);
1516 if (!(ramp
= malloc(ramplen
)))
1519 if (!VidModeGetGammaRamp(stuff
->screen
, stuff
->size
,
1520 ramp
, ramp
+ length
, ramp
+ (length
* 2))) {
1525 rep
= (xXF86VidModeGetGammaRampReply
) {
1527 .sequenceNumber
= client
->sequence
,
1528 .length
= (length
>> 1) * 3,
1531 if (client
->swapped
) {
1532 swaps(&rep
.sequenceNumber
);
1535 SwapShorts((short *) ramp
, length
* 3);
1537 WriteToClient(client
, sizeof(xXF86VidModeGetGammaRampReply
), &rep
);
1540 WriteToClient(client
, ramplen
, ramp
);
1548 ProcXF86VidModeGetGammaRampSize(ClientPtr client
)
1550 xXF86VidModeGetGammaRampSizeReply rep
;
1552 REQUEST(xXF86VidModeGetGammaRampSizeReq
);
1554 REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq
);
1556 if (stuff
->screen
>= screenInfo
.numScreens
)
1559 rep
= (xXF86VidModeGetGammaRampSizeReply
) {
1561 .sequenceNumber
= client
->sequence
,
1563 .size
= VidModeGetGammaRampSize(stuff
->screen
)
1565 if (client
->swapped
) {
1566 swaps(&rep
.sequenceNumber
);
1570 WriteToClient(client
, sizeof(xXF86VidModeGetGammaRampSizeReply
), &rep
);
1576 ProcXF86VidModeGetPermissions(ClientPtr client
)
1578 xXF86VidModeGetPermissionsReply rep
= {
1580 .sequenceNumber
= client
->sequence
,
1582 .permissions
= XF86VM_READ_PERMISSION
1585 REQUEST(xXF86VidModeGetPermissionsReq
);
1587 REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq
);
1589 if (stuff
->screen
>= screenInfo
.numScreens
)
1592 if (xf86GetVidModeEnabled() &&
1593 (xf86GetVidModeAllowNonLocal() || client
->local
)) {
1594 rep
.permissions
|= XF86VM_WRITE_PERMISSION
;
1596 if (client
->swapped
) {
1597 swaps(&rep
.sequenceNumber
);
1599 swapl(&rep
.permissions
);
1601 WriteToClient(client
, sizeof(xXF86VidModeGetPermissionsReply
), &rep
);
1607 ProcXF86VidModeSetClientVersion(ClientPtr client
)
1609 REQUEST(xXF86VidModeSetClientVersionReq
);
1611 VidModePrivPtr pPriv
;
1613 DEBUG_P("XF86VidModeSetClientVersion");
1615 REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq
);
1617 if ((pPriv
= VM_GETPRIV(client
)) == NULL
) {
1618 pPriv
= malloc(sizeof(VidModePrivRec
));
1621 VM_SETPRIV(client
, pPriv
);
1623 pPriv
->major
= stuff
->major
;
1625 pPriv
->minor
= stuff
->minor
;
1631 ProcXF86VidModeDispatch(ClientPtr client
)
1634 switch (stuff
->data
) {
1635 case X_XF86VidModeQueryVersion
:
1636 return ProcXF86VidModeQueryVersion(client
);
1637 case X_XF86VidModeGetModeLine
:
1638 return ProcXF86VidModeGetModeLine(client
);
1639 case X_XF86VidModeGetMonitor
:
1640 return ProcXF86VidModeGetMonitor(client
);
1641 case X_XF86VidModeGetAllModeLines
:
1642 return ProcXF86VidModeGetAllModeLines(client
);
1643 case X_XF86VidModeValidateModeLine
:
1644 return ProcXF86VidModeValidateModeLine(client
);
1645 case X_XF86VidModeGetViewPort
:
1646 return ProcXF86VidModeGetViewPort(client
);
1647 case X_XF86VidModeGetDotClocks
:
1648 return ProcXF86VidModeGetDotClocks(client
);
1649 case X_XF86VidModeSetClientVersion
:
1650 return ProcXF86VidModeSetClientVersion(client
);
1651 case X_XF86VidModeGetGamma
:
1652 return ProcXF86VidModeGetGamma(client
);
1653 case X_XF86VidModeGetGammaRamp
:
1654 return ProcXF86VidModeGetGammaRamp(client
);
1655 case X_XF86VidModeGetGammaRampSize
:
1656 return ProcXF86VidModeGetGammaRampSize(client
);
1657 case X_XF86VidModeGetPermissions
:
1658 return ProcXF86VidModeGetPermissions(client
);
1660 if (!xf86GetVidModeEnabled())
1661 return VidModeErrorBase
+ XF86VidModeExtensionDisabled
;
1662 if (xf86GetVidModeAllowNonLocal() || client
->local
) {
1663 switch (stuff
->data
) {
1664 case X_XF86VidModeAddModeLine
:
1665 return ProcXF86VidModeAddModeLine(client
);
1666 case X_XF86VidModeDeleteModeLine
:
1667 return ProcXF86VidModeDeleteModeLine(client
);
1668 case X_XF86VidModeModModeLine
:
1669 return ProcXF86VidModeModModeLine(client
);
1670 case X_XF86VidModeSwitchMode
:
1671 return ProcXF86VidModeSwitchMode(client
);
1672 case X_XF86VidModeSwitchToMode
:
1673 return ProcXF86VidModeSwitchToMode(client
);
1674 case X_XF86VidModeLockModeSwitch
:
1675 return ProcXF86VidModeLockModeSwitch(client
);
1676 case X_XF86VidModeSetViewPort
:
1677 return ProcXF86VidModeSetViewPort(client
);
1678 case X_XF86VidModeSetGamma
:
1679 return ProcXF86VidModeSetGamma(client
);
1680 case X_XF86VidModeSetGammaRamp
:
1681 return ProcXF86VidModeSetGammaRamp(client
);
1687 return VidModeErrorBase
+ XF86VidModeClientNotLocal
;
1692 SProcXF86VidModeQueryVersion(ClientPtr client
)
1694 REQUEST(xXF86VidModeQueryVersionReq
);
1695 swaps(&stuff
->length
);
1696 return ProcXF86VidModeQueryVersion(client
);
1700 SProcXF86VidModeGetModeLine(ClientPtr client
)
1702 REQUEST(xXF86VidModeGetModeLineReq
);
1703 swaps(&stuff
->length
);
1704 REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq
);
1705 swaps(&stuff
->screen
);
1706 return ProcXF86VidModeGetModeLine(client
);
1710 SProcXF86VidModeGetAllModeLines(ClientPtr client
)
1712 REQUEST(xXF86VidModeGetAllModeLinesReq
);
1713 swaps(&stuff
->length
);
1714 REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq
);
1715 swaps(&stuff
->screen
);
1716 return ProcXF86VidModeGetAllModeLines(client
);
1720 SProcXF86VidModeAddModeLine(ClientPtr client
)
1722 xXF86OldVidModeAddModeLineReq
*oldstuff
=
1723 (xXF86OldVidModeAddModeLineReq
*) client
->requestBuffer
;
1726 REQUEST(xXF86VidModeAddModeLineReq
);
1727 ver
= ClientMajorVersion(client
);
1729 swaps(&oldstuff
->length
);
1730 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq
);
1731 swapl(&oldstuff
->screen
);
1732 swaps(&oldstuff
->hdisplay
);
1733 swaps(&oldstuff
->hsyncstart
);
1734 swaps(&oldstuff
->hsyncend
);
1735 swaps(&oldstuff
->htotal
);
1736 swaps(&oldstuff
->vdisplay
);
1737 swaps(&oldstuff
->vsyncstart
);
1738 swaps(&oldstuff
->vsyncend
);
1739 swaps(&oldstuff
->vtotal
);
1740 swapl(&oldstuff
->flags
);
1741 swapl(&oldstuff
->privsize
);
1742 SwapRestL(oldstuff
);
1745 swaps(&stuff
->length
);
1746 REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq
);
1747 swapl(&stuff
->screen
);
1748 swaps(&stuff
->hdisplay
);
1749 swaps(&stuff
->hsyncstart
);
1750 swaps(&stuff
->hsyncend
);
1751 swaps(&stuff
->htotal
);
1752 swaps(&stuff
->hskew
);
1753 swaps(&stuff
->vdisplay
);
1754 swaps(&stuff
->vsyncstart
);
1755 swaps(&stuff
->vsyncend
);
1756 swaps(&stuff
->vtotal
);
1757 swapl(&stuff
->flags
);
1758 swapl(&stuff
->privsize
);
1761 return ProcXF86VidModeAddModeLine(client
);
1765 SProcXF86VidModeDeleteModeLine(ClientPtr client
)
1767 xXF86OldVidModeDeleteModeLineReq
*oldstuff
=
1768 (xXF86OldVidModeDeleteModeLineReq
*) client
->requestBuffer
;
1771 REQUEST(xXF86VidModeDeleteModeLineReq
);
1772 ver
= ClientMajorVersion(client
);
1774 swaps(&oldstuff
->length
);
1775 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq
);
1776 swapl(&oldstuff
->screen
);
1777 swaps(&oldstuff
->hdisplay
);
1778 swaps(&oldstuff
->hsyncstart
);
1779 swaps(&oldstuff
->hsyncend
);
1780 swaps(&oldstuff
->htotal
);
1781 swaps(&oldstuff
->vdisplay
);
1782 swaps(&oldstuff
->vsyncstart
);
1783 swaps(&oldstuff
->vsyncend
);
1784 swaps(&oldstuff
->vtotal
);
1785 swapl(&oldstuff
->flags
);
1786 swapl(&oldstuff
->privsize
);
1787 SwapRestL(oldstuff
);
1790 swaps(&stuff
->length
);
1791 REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq
);
1792 swapl(&stuff
->screen
);
1793 swaps(&stuff
->hdisplay
);
1794 swaps(&stuff
->hsyncstart
);
1795 swaps(&stuff
->hsyncend
);
1796 swaps(&stuff
->htotal
);
1797 swaps(&stuff
->hskew
);
1798 swaps(&stuff
->vdisplay
);
1799 swaps(&stuff
->vsyncstart
);
1800 swaps(&stuff
->vsyncend
);
1801 swaps(&stuff
->vtotal
);
1802 swapl(&stuff
->flags
);
1803 swapl(&stuff
->privsize
);
1806 return ProcXF86VidModeDeleteModeLine(client
);
1810 SProcXF86VidModeModModeLine(ClientPtr client
)
1812 xXF86OldVidModeModModeLineReq
*oldstuff
=
1813 (xXF86OldVidModeModModeLineReq
*) client
->requestBuffer
;
1816 REQUEST(xXF86VidModeModModeLineReq
);
1817 ver
= ClientMajorVersion(client
);
1819 swaps(&oldstuff
->length
);
1820 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq
);
1821 swapl(&oldstuff
->screen
);
1822 swaps(&oldstuff
->hdisplay
);
1823 swaps(&oldstuff
->hsyncstart
);
1824 swaps(&oldstuff
->hsyncend
);
1825 swaps(&oldstuff
->htotal
);
1826 swaps(&oldstuff
->vdisplay
);
1827 swaps(&oldstuff
->vsyncstart
);
1828 swaps(&oldstuff
->vsyncend
);
1829 swaps(&oldstuff
->vtotal
);
1830 swapl(&oldstuff
->flags
);
1831 swapl(&oldstuff
->privsize
);
1832 SwapRestL(oldstuff
);
1835 swaps(&stuff
->length
);
1836 REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq
);
1837 swapl(&stuff
->screen
);
1838 swaps(&stuff
->hdisplay
);
1839 swaps(&stuff
->hsyncstart
);
1840 swaps(&stuff
->hsyncend
);
1841 swaps(&stuff
->htotal
);
1842 swaps(&stuff
->hskew
);
1843 swaps(&stuff
->vdisplay
);
1844 swaps(&stuff
->vsyncstart
);
1845 swaps(&stuff
->vsyncend
);
1846 swaps(&stuff
->vtotal
);
1847 swapl(&stuff
->flags
);
1848 swapl(&stuff
->privsize
);
1851 return ProcXF86VidModeModModeLine(client
);
1855 SProcXF86VidModeValidateModeLine(ClientPtr client
)
1857 xXF86OldVidModeValidateModeLineReq
*oldstuff
=
1858 (xXF86OldVidModeValidateModeLineReq
*) client
->requestBuffer
;
1861 REQUEST(xXF86VidModeValidateModeLineReq
);
1862 ver
= ClientMajorVersion(client
);
1864 swaps(&oldstuff
->length
);
1865 REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq
);
1866 swapl(&oldstuff
->screen
);
1867 swaps(&oldstuff
->hdisplay
);
1868 swaps(&oldstuff
->hsyncstart
);
1869 swaps(&oldstuff
->hsyncend
);
1870 swaps(&oldstuff
->htotal
);
1871 swaps(&oldstuff
->vdisplay
);
1872 swaps(&oldstuff
->vsyncstart
);
1873 swaps(&oldstuff
->vsyncend
);
1874 swaps(&oldstuff
->vtotal
);
1875 swapl(&oldstuff
->flags
);
1876 swapl(&oldstuff
->privsize
);
1877 SwapRestL(oldstuff
);
1880 swaps(&stuff
->length
);
1881 REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq
);
1882 swapl(&stuff
->screen
);
1883 swaps(&stuff
->hdisplay
);
1884 swaps(&stuff
->hsyncstart
);
1885 swaps(&stuff
->hsyncend
);
1886 swaps(&stuff
->htotal
);
1887 swaps(&stuff
->hskew
);
1888 swaps(&stuff
->vdisplay
);
1889 swaps(&stuff
->vsyncstart
);
1890 swaps(&stuff
->vsyncend
);
1891 swaps(&stuff
->vtotal
);
1892 swapl(&stuff
->flags
);
1893 swapl(&stuff
->privsize
);
1896 return ProcXF86VidModeValidateModeLine(client
);
1900 SProcXF86VidModeSwitchMode(ClientPtr client
)
1902 REQUEST(xXF86VidModeSwitchModeReq
);
1903 swaps(&stuff
->length
);
1904 REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq
);
1905 swaps(&stuff
->screen
);
1906 swaps(&stuff
->zoom
);
1907 return ProcXF86VidModeSwitchMode(client
);
1911 SProcXF86VidModeSwitchToMode(ClientPtr client
)
1913 REQUEST(xXF86VidModeSwitchToModeReq
);
1914 swaps(&stuff
->length
);
1915 REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq
);
1916 swapl(&stuff
->screen
);
1917 return ProcXF86VidModeSwitchToMode(client
);
1921 SProcXF86VidModeLockModeSwitch(ClientPtr client
)
1923 REQUEST(xXF86VidModeLockModeSwitchReq
);
1924 swaps(&stuff
->length
);
1925 REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq
);
1926 swaps(&stuff
->screen
);
1927 swaps(&stuff
->lock
);
1928 return ProcXF86VidModeLockModeSwitch(client
);
1932 SProcXF86VidModeGetMonitor(ClientPtr client
)
1934 REQUEST(xXF86VidModeGetMonitorReq
);
1935 swaps(&stuff
->length
);
1936 REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq
);
1937 swaps(&stuff
->screen
);
1938 return ProcXF86VidModeGetMonitor(client
);
1942 SProcXF86VidModeGetViewPort(ClientPtr client
)
1944 REQUEST(xXF86VidModeGetViewPortReq
);
1945 swaps(&stuff
->length
);
1946 REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq
);
1947 swaps(&stuff
->screen
);
1948 return ProcXF86VidModeGetViewPort(client
);
1952 SProcXF86VidModeSetViewPort(ClientPtr client
)
1954 REQUEST(xXF86VidModeSetViewPortReq
);
1955 swaps(&stuff
->length
);
1956 REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq
);
1957 swaps(&stuff
->screen
);
1960 return ProcXF86VidModeSetViewPort(client
);
1964 SProcXF86VidModeGetDotClocks(ClientPtr client
)
1966 REQUEST(xXF86VidModeGetDotClocksReq
);
1967 swaps(&stuff
->length
);
1968 REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq
);
1969 swaps(&stuff
->screen
);
1970 return ProcXF86VidModeGetDotClocks(client
);
1974 SProcXF86VidModeSetClientVersion(ClientPtr client
)
1976 REQUEST(xXF86VidModeSetClientVersionReq
);
1977 swaps(&stuff
->length
);
1978 REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq
);
1979 swaps(&stuff
->major
);
1980 swaps(&stuff
->minor
);
1981 return ProcXF86VidModeSetClientVersion(client
);
1985 SProcXF86VidModeSetGamma(ClientPtr client
)
1987 REQUEST(xXF86VidModeSetGammaReq
);
1988 swaps(&stuff
->length
);
1989 REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq
);
1990 swaps(&stuff
->screen
);
1992 swapl(&stuff
->green
);
1993 swapl(&stuff
->blue
);
1994 return ProcXF86VidModeSetGamma(client
);
1998 SProcXF86VidModeGetGamma(ClientPtr client
)
2000 REQUEST(xXF86VidModeGetGammaReq
);
2001 swaps(&stuff
->length
);
2002 REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq
);
2003 swaps(&stuff
->screen
);
2004 return ProcXF86VidModeGetGamma(client
);
2008 SProcXF86VidModeSetGammaRamp(ClientPtr client
)
2012 REQUEST(xXF86VidModeSetGammaRampReq
);
2013 swaps(&stuff
->length
);
2014 REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq
);
2015 swaps(&stuff
->size
);
2016 swaps(&stuff
->screen
);
2017 length
= ((stuff
->size
+ 1) & ~1) * 6;
2018 REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq
, length
);
2020 return ProcXF86VidModeSetGammaRamp(client
);
2024 SProcXF86VidModeGetGammaRamp(ClientPtr client
)
2026 REQUEST(xXF86VidModeGetGammaRampReq
);
2027 swaps(&stuff
->length
);
2028 REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq
);
2029 swaps(&stuff
->size
);
2030 swaps(&stuff
->screen
);
2031 return ProcXF86VidModeGetGammaRamp(client
);
2035 SProcXF86VidModeGetGammaRampSize(ClientPtr client
)
2037 REQUEST(xXF86VidModeGetGammaRampSizeReq
);
2038 swaps(&stuff
->length
);
2039 REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq
);
2040 swaps(&stuff
->screen
);
2041 return ProcXF86VidModeGetGammaRampSize(client
);
2045 SProcXF86VidModeGetPermissions(ClientPtr client
)
2047 REQUEST(xXF86VidModeGetPermissionsReq
);
2048 swaps(&stuff
->length
);
2049 REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq
);
2050 swaps(&stuff
->screen
);
2051 return ProcXF86VidModeGetPermissions(client
);
2055 SProcXF86VidModeDispatch(ClientPtr client
)
2058 switch (stuff
->data
) {
2059 case X_XF86VidModeQueryVersion
:
2060 return SProcXF86VidModeQueryVersion(client
);
2061 case X_XF86VidModeGetModeLine
:
2062 return SProcXF86VidModeGetModeLine(client
);
2063 case X_XF86VidModeGetMonitor
:
2064 return SProcXF86VidModeGetMonitor(client
);
2065 case X_XF86VidModeGetAllModeLines
:
2066 return SProcXF86VidModeGetAllModeLines(client
);
2067 case X_XF86VidModeGetViewPort
:
2068 return SProcXF86VidModeGetViewPort(client
);
2069 case X_XF86VidModeValidateModeLine
:
2070 return SProcXF86VidModeValidateModeLine(client
);
2071 case X_XF86VidModeGetDotClocks
:
2072 return SProcXF86VidModeGetDotClocks(client
);
2073 case X_XF86VidModeSetClientVersion
:
2074 return SProcXF86VidModeSetClientVersion(client
);
2075 case X_XF86VidModeGetGamma
:
2076 return SProcXF86VidModeGetGamma(client
);
2077 case X_XF86VidModeGetGammaRamp
:
2078 return SProcXF86VidModeGetGammaRamp(client
);
2079 case X_XF86VidModeGetGammaRampSize
:
2080 return SProcXF86VidModeGetGammaRampSize(client
);
2081 case X_XF86VidModeGetPermissions
:
2082 return SProcXF86VidModeGetPermissions(client
);
2084 if (!xf86GetVidModeEnabled())
2085 return VidModeErrorBase
+ XF86VidModeExtensionDisabled
;
2086 if (xf86GetVidModeAllowNonLocal() || client
->local
) {
2087 switch (stuff
->data
) {
2088 case X_XF86VidModeAddModeLine
:
2089 return SProcXF86VidModeAddModeLine(client
);
2090 case X_XF86VidModeDeleteModeLine
:
2091 return SProcXF86VidModeDeleteModeLine(client
);
2092 case X_XF86VidModeModModeLine
:
2093 return SProcXF86VidModeModModeLine(client
);
2094 case X_XF86VidModeSwitchMode
:
2095 return SProcXF86VidModeSwitchMode(client
);
2096 case X_XF86VidModeSwitchToMode
:
2097 return SProcXF86VidModeSwitchToMode(client
);
2098 case X_XF86VidModeLockModeSwitch
:
2099 return SProcXF86VidModeLockModeSwitch(client
);
2100 case X_XF86VidModeSetViewPort
:
2101 return SProcXF86VidModeSetViewPort(client
);
2102 case X_XF86VidModeSetGamma
:
2103 return SProcXF86VidModeSetGamma(client
);
2104 case X_XF86VidModeSetGammaRamp
:
2105 return SProcXF86VidModeSetGammaRamp(client
);
2111 return VidModeErrorBase
+ XF86VidModeClientNotLocal
;
2116 XFree86VidModeExtensionInit(void)
2118 ExtensionEntry
*extEntry
;
2121 Bool enabled
= FALSE
;
2123 DEBUG_P("XFree86VidModeExtensionInit");
2125 if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec
, PRIVATE_CLIENT
, 0))
2127 #ifdef XF86VIDMODE_EVENTS
2128 if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec
, PRIVATE_SCREEN
, 0))
2132 #ifdef XF86VIDMODE_EVENTS
2133 EventType
= CreateNewResourceType(XF86VidModeFreeEvents
, "VidModeEvent");
2136 for (i
= 0; i
< screenInfo
.numScreens
; i
++) {
2137 pScreen
= screenInfo
.screens
[i
];
2138 if (VidModeExtensionInit(pScreen
))
2141 /* This means that the DDX doesn't want the vidmode extension enabled */
2146 #ifdef XF86VIDMODE_EVENTS
2149 (extEntry
= AddExtension(XF86VIDMODENAME
,
2150 XF86VidModeNumberEvents
,
2151 XF86VidModeNumberErrors
,
2152 ProcXF86VidModeDispatch
,
2153 SProcXF86VidModeDispatch
,
2154 NULL
, StandardMinorOpcode
))) {
2156 XF86VidModeReqCode
= (unsigned char) extEntry
->base
;
2158 VidModeErrorBase
= extEntry
->errorBase
;
2159 #ifdef XF86VIDMODE_EVENTS
2160 XF86VidModeEventBase
= extEntry
->eventBase
;
2161 EventSwapVector
[XF86VidModeEventBase
] =
2162 (EventSwapPtr
) SXF86VidModeNotifyEvent
;