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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
|
/* $XFree86: xc/programs/Xserver/Xext/xf86vmode.c,v 3.25 1996/10/16 14:37:58 dawes Exp $ */
/*
Copyright 1995 Kaleb S. KEITHLEY
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Kaleb S. KEITHLEY
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
from Kaleb S. KEITHLEY
*/
/* $Xorg: xf86vmode.c,v 1.3 2000/08/17 19:47:59 cpqbld Exp $ */
/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
#define NEED_REPLIES
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "misc.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "scrnintstr.h"
#include "servermd.h"
#define _XF86VIDMODE_SERVER_
#include "xf86vmstr.h"
#include "Xfuncproto.h"
#include "../hw/xfree86/common/xf86.h"
#include "../hw/xfree86/common/xf86Priv.h"
extern int xf86ScreenIndex;
extern Bool xf86VidModeEnabled;
extern Bool xf86VidModeAllowNonLocal;
static int vidmodeErrorBase;
static int ProcXF86VidModeDispatch(
#if NeedFunctionPrototypes
ClientPtr /* client */
#endif
);
static int SProcXF86VidModeDispatch(
#if NeedFunctionPrototypes
ClientPtr /* client */
#endif
);
static void XF86VidModeResetProc(
#if NeedFunctionPrototypes
ExtensionEntry* /* extEntry */
#endif
);
extern void Swap32Write(); /* XXX should be in header file */
static unsigned char XF86VidModeReqCode = 0;
/* The XF86VIDMODE_EVENTS code is far from complete */
#ifdef XF86VIDMODE_EVENTS
static int XF86VidModeEventBase = 0;
static void SXF86VidModeNotifyEvent();
#if NeedFunctionPrototypes
xXF86VidModeNotifyEvent * /* from */,
xXF86VidModeNotifyEvent * /* to */
#endif
);
extern WindowPtr *WindowTable;
static RESTYPE EventType; /* resource type for event masks */
typedef struct _XF86VidModeEvent *XF86VidModeEventPtr;
typedef struct _XF86VidModeEvent {
XF86VidModeEventPtr next;
ClientPtr client;
ScreenPtr screen;
XID resource;
CARD32 mask;
} XF86VidModeEventRec;
static int XF86VidModeFreeEvents();
typedef struct _XF86VidModeScreenPrivate {
XF86VidModeEventPtr events;
Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
static int ScreenPrivateIndex;
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
#define New(t) ((t *) xalloc (sizeof (t)))
#endif
void
XFree86VidModeExtensionInit()
{
ExtensionEntry* extEntry;
#ifdef XF86VIDMODE_EVENTS
int i;
ScreenPtr pScreen;
EventType = CreateNewResourceType(XF86VidModeFreeEvents);
ScreenPrivateIndex = AllocateScreenPrivateIndex ();
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
SetScreenPrivate (pScreen, NULL);
}
#endif
if (
#ifdef XF86VIDMODE_EVENTS
EventType && ScreenPrivateIndex != -1 &&
#endif
(extEntry = AddExtension(XF86VIDMODENAME,
XF86VidModeNumberEvents,
XF86VidModeNumberErrors,
ProcXF86VidModeDispatch,
SProcXF86VidModeDispatch,
XF86VidModeResetProc,
StandardMinorOpcode))) {
XF86VidModeReqCode = (unsigned char)extEntry->base;
vidmodeErrorBase = extEntry->errorBase;
#ifdef XF86VIDMODE_EVENTS
XF86VidModeEventBase = extEntry->eventBase;
EventSwapVector[XF86VidModeEventBase] = SXF86VidModeNotifyEvent;
#endif
}
}
/*ARGSUSED*/
static void
XF86VidModeResetProc (extEntry)
ExtensionEntry* extEntry;
{
}
#ifdef XF86VIDMODE_EVENTS
static void
CheckScreenPrivate (pScreen)
ScreenPtr pScreen;
{
SetupScreen (pScreen);
if (!pPriv)
return;
if (!pPriv->events && !pPriv->hasWindow) {
xfree (pPriv);
SetScreenPrivate (pScreen, NULL);
}
}
static XF86VidModeScreenPrivatePtr
MakeScreenPrivate (pScreen)
ScreenPtr pScreen;
{
SetupScreen (pScreen);
if (pPriv)
return pPriv;
pPriv = New (XF86VidModeScreenPrivateRec);
if (!pPriv)
return 0;
pPriv->events = 0;
pPriv->hasWindow = FALSE;
SetScreenPrivate (pScreen, pPriv);
return pPriv;
}
static unsigned long
getEventMask (pScreen, client)
ScreenPtr pScreen;
ClientPtr client;
{
SetupScreen(pScreen);
XF86VidModeEventPtr pEv;
if (!pPriv)
return 0;
for (pEv = pPriv->events; pEv; pEv = pEv->next)
if (pEv->client == client)
return pEv->mask;
return 0;
}
static Bool
setEventMask (pScreen, client, mask)
ScreenPtr pScreen;
ClientPtr client;
unsigned long mask;
{
SetupScreen(pScreen);
XF86VidModeEventPtr pEv, *pPrev;
if (getEventMask (pScreen, client) == mask)
return TRUE;
if (!pPriv) {
pPriv = MakeScreenPrivate (pScreen);
if (!pPriv)
return FALSE;
}
for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
if (pEv->client == client)
break;
if (mask == 0) {
*pPrev = pEv->next;
xfree (pEv);
CheckScreenPrivate (pScreen);
} else {
if (!pEv) {
pEv = New (ScreenSaverEventRec);
if (!pEv) {
CheckScreenPrivate (pScreen);
return FALSE;
}
*pPrev = pEv;
pEv->next = NULL;
pEv->client = client;
pEv->screen = pScreen;
pEv->resource = FakeClientID (client->index);
}
pEv->mask = mask;
}
return TRUE;
}
static int
XF86VidModeFreeEvents (value, id)
pointer value;
XID id;
{
XF86VidModeEventPtr pOld = (XF86VidModeEventPtr)value;
ScreenPtr pScreen = pOld->screen;
SetupScreen (pScreen);
XF86VidModeEventPtr pEv, *pPrev;
if (!pPriv)
return TRUE;
for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
if (pEv == pOld)
break;
if (!pEv)
return TRUE;
*pPrev = pEv->next;
xfree (pEv);
CheckScreenPrivate (pScreen);
return TRUE;
}
static void
SendXF86VidModeNotify (pScreen, state, forced)
ScreenPtr pScreen;
int state;
Bool forced;
{
XF86VidModeScreenPrivatePtr pPriv;
XF86VidModeEventPtr pEv;
unsigned long mask;
xXF86VidModeNotifyEvent ev;
ClientPtr client;
int kind;
UpdateCurrentTimeIf ();
mask = XF86VidModeNotifyMask;
pScreen = screenInfo.screens[pScreen->myNum];
pPriv = GetScreenPrivate(pScreen);
if (!pPriv)
return;
kind = XF86VidModeModeChange;
for (pEv = pPriv->events; pEv; pEv = pEv->next)
{
client = pEv->client;
if (client->clientGone)
continue;
if (!(pEv->mask & mask))
continue;
ev.type = XF86VidModeNotify + XF86VidModeEventBase;
ev.state = state;
ev.sequenceNumber = client->sequence;
ev.timestamp = currentTime.milliseconds;
ev.root = WindowTable[pScreen->myNum]->drawable.id;
ev.kind = kind;
ev.forced = forced;
WriteEventsToClient (client, 1, (xEvent *) &ev);
}
}
static void
SXF86VidModeNotifyEvent (from, to)
xXF86VidModeNotifyEvent *from, *to;
{
to->type = from->type;
to->state = from->state;
cpswaps (from->sequenceNumber, to->sequenceNumber);
cpswapl (from->timestamp, to->timestamp);
cpswapl (from->root, to->root);
to->kind = from->kind;
to->forced = from->forced;
}
#endif
static int
ProcXF86VidModeQueryVersion(client)
register ClientPtr client;
{
xXF86VidModeQueryVersionReply rep;
register int n;
REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.majorVersion = XF86VIDMODE_MAJOR_VERSION;
rep.minorVersion = XF86VIDMODE_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.majorVersion, n);
swaps(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *)&rep);
return (client->noClientException);
}
static int
ProcXF86VidModeGetModeLine(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeGetModeLineReq);
xXF86VidModeGetModeLineReply rep;
register int n;
ScrnInfoPtr vptr;
DisplayModePtr mptr;
int privsize;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
mptr = vptr->modes;
if (!mptr->Private)
privsize = 0;
else
privsize = mptr->PrivSize;
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
rep.type = X_Reply;
rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xGenericReply) +
privsize * sizeof(INT32)) >> 2;
rep.sequenceNumber = client->sequence;
rep.dotclock = vptr->clock[mptr->Clock];
rep.hdisplay = mptr->HDisplay;
rep.hsyncstart = mptr->HSyncStart;
rep.hsyncend = mptr->HSyncEnd;
rep.htotal = mptr->HTotal;
rep.vdisplay = mptr->VDisplay;
rep.vsyncstart = mptr->VSyncStart;
rep.vsyncend = mptr->VSyncEnd;
rep.vtotal = mptr->VTotal;
rep.flags = mptr->Flags;
rep.privsize = privsize;
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.dotclock, n);
swaps(&rep.hdisplay, n);
swaps(&rep.hsyncstart, n);
swaps(&rep.hsyncend, n);
swaps(&rep.htotal, n);
swaps(&rep.vdisplay, n);
swaps(&rep.vsyncstart, n);
swaps(&rep.vsyncend, n);
swaps(&rep.vtotal, n);
swapl(&rep.flags, n);
swapl(&rep.privsize, n);
}
WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), (char *)&rep);
if (privsize) {
client->pSwapReplyFunc = Swap32Write;
WriteSwappedDataToClient(client, privsize * sizeof(INT32),
mptr->Private);
}
return (client->noClientException);
}
static int
ProcXF86VidModeGetAllModeLines(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeGetAllModeLinesReq);
xXF86VidModeGetAllModeLinesReply rep;
xXF86VidModeModeInfo mdinf;
register int n;
ScrnInfoPtr vptr;
DisplayModePtr mptr, curmptr;
int privsize, modecount=1;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
curmptr = mptr = vptr->modes;
while (mptr->next != curmptr) {
++modecount;
mptr = mptr->next;
}
REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
rep.type = X_Reply;
rep.length = (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xGenericReply) +
modecount * sizeof(xXF86VidModeModeInfo)) >> 2;
rep.sequenceNumber = client->sequence;
rep.modecount = modecount;
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.modecount, n);
}
WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep);
mptr = curmptr;
do {
if (!mptr->Private)
privsize = 0;
else
privsize = mptr->PrivSize;
mdinf.dotclock = vptr->clock[mptr->Clock];
mdinf.hdisplay = mptr->HDisplay;
mdinf.hsyncstart = mptr->HSyncStart;
mdinf.hsyncend = mptr->HSyncEnd;
mdinf.htotal = mptr->HTotal;
mdinf.vdisplay = mptr->VDisplay;
mdinf.vsyncstart = mptr->VSyncStart;
mdinf.vsyncend = mptr->VSyncEnd;
mdinf.vtotal = mptr->VTotal;
mdinf.flags = mptr->Flags;
mdinf.privsize = privsize;
if (client->swapped) {
swapl(&mdinf.dotclock, n);
swaps(&mdinf.hdisplay, n);
swaps(&mdinf.hsyncstart, n);
swaps(&mdinf.hsyncend, n);
swaps(&mdinf.htotal, n);
swaps(&mdinf.vdisplay, n);
swaps(&mdinf.vsyncstart, n);
swaps(&mdinf.vsyncend, n);
swaps(&mdinf.vtotal, n);
swapl(&mdinf.flags, n);
swapl(&mdinf.privsize, n);
}
WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf);
mptr = mptr->next;
} while (mptr != curmptr);
return (client->noClientException);
}
#define CLOCKSPD(clk,scrp) ((clk>MAXCLOCKS)? clk: scrp->clock[clk])
#define MODEMATCH(mptr,stuff,scrp) \
(CLOCKSPD(mptr->Clock,scrp) == CLOCKSPD(stuff->dotclock,scrp) \
&& mptr->HDisplay == stuff->hdisplay \
&& mptr->HSyncStart== stuff->hsyncstart \
&& mptr->HSyncEnd == stuff->hsyncend \
&& mptr->HTotal == stuff->htotal \
&& mptr->VDisplay == stuff->vdisplay \
&& mptr->VSyncStart== stuff->vsyncstart \
&& mptr->VSyncEnd == stuff->vsyncend \
&& mptr->VTotal == stuff->vtotal \
&& mptr->Flags == stuff->flags )
static int
ProcXF86VidModeAddModeLine(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeAddModeLineReq);
ScrnInfoPtr vptr;
DisplayModePtr curmptr, mptr, newmptr;
DisplayModeRec modetmp;
int len;
if (xf86Verbose) {
ErrorF("AddModeLine - scrn: %d clock: %d\n",
stuff->screen, stuff->dotclock);
ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->hdisplay, stuff->hsyncstart,
stuff->hsyncend, stuff->htotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
ErrorF(" after - scrn: %d clock: %d\n",
stuff->screen, stuff->after_dotclock);
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->after_hdisplay, stuff->after_hsyncstart,
stuff->after_hsyncend, stuff->after_htotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
stuff->after_vdisplay, stuff->after_vsyncstart,
stuff->after_vsyncend, stuff->after_vtotal, stuff->after_flags);
}
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
curmptr = mptr = vptr->modes;
REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2);
if (len != stuff->privsize)
return BadLength;
if (stuff->hsyncstart < stuff->hdisplay ||
stuff->hsyncend < stuff->hsyncstart ||
stuff->htotal < stuff->hsyncend ||
stuff->vsyncstart < stuff->vdisplay ||
stuff->vsyncend < stuff->vsyncstart ||
stuff->vtotal < stuff->vsyncend)
return BadValue;
if (stuff->after_hsyncstart < stuff->after_hdisplay ||
stuff->after_hsyncend < stuff->after_hsyncstart ||
stuff->after_htotal < stuff->after_hsyncend ||
stuff->after_vsyncstart < stuff->after_vdisplay ||
stuff->after_vsyncend < stuff->after_vsyncstart ||
stuff->after_vtotal < stuff->after_vsyncend)
return BadValue;
if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
Bool found = FALSE;
do {
if (MODEMATCH(mptr, stuff, vptr)) {
found = TRUE;
break;
}
} while ((mptr = mptr->next) != curmptr);
if (!found)
return BadValue;
}
newmptr = (DisplayModePtr) xalloc(sizeof(DisplayModeRec));
newmptr->Clock = stuff->dotclock;
newmptr->CrtcHDisplay = newmptr->HDisplay = stuff->hdisplay;
newmptr->CrtcHSyncStart= newmptr->HSyncStart = stuff->hsyncstart;
newmptr->CrtcHSyncEnd = newmptr->HSyncEnd = stuff->hsyncend;
newmptr->CrtcHTotal = newmptr->HTotal = stuff->htotal;
newmptr->CrtcVDisplay = newmptr->VDisplay = stuff->vdisplay;
newmptr->CrtcVSyncStart= newmptr->VSyncStart = stuff->vsyncstart;
newmptr->CrtcVSyncEnd = newmptr->VSyncEnd = stuff->vsyncend;
newmptr->CrtcVTotal = newmptr->VTotal = stuff->vtotal;
newmptr->Flags = stuff->flags;
#if 0
newmptr->CrtcHSkew = newmptr->HSkew = stuff->hskew;
#endif
newmptr->CrtcHAdjusted = FALSE;
newmptr->CrtcVAdjusted = FALSE;
newmptr->name = "";
newmptr->Private = NULL;
if (stuff->privsize) {
if (xf86Verbose)
ErrorF("AddModeLine - Request includes privates\n");
newmptr->Private =
(INT32 *) ALLOCATE_LOCAL(stuff->privsize * sizeof(INT32));
memcpy(newmptr->Private, &stuff[1], stuff->privsize*sizeof(INT32));
}
/* Check that the mode is consistent with the monitor specs */
switch (xf86CheckMode(vptr, newmptr, vptr->monitor, FALSE)) {
case MODE_HSYNC:
xfree(newmptr->Private);
xfree(newmptr);
return vidmodeErrorBase + XF86VidModeBadHTimings;
case MODE_VSYNC:
xfree(newmptr->Private);
xfree(newmptr);
return vidmodeErrorBase + XF86VidModeBadVTimings;
}
/* Check that the driver is happy with the mode */
if (vptr->ValidMode(newmptr, xf86Verbose, MODE_VID) != MODE_OK) {
xfree(newmptr->Private);
xfree(newmptr);
return vidmodeErrorBase + XF86VidModeModeUnsuitable;
}
if (newmptr->Flags & V_DBLSCAN)
{
newmptr->CrtcVDisplay *= 2;
newmptr->CrtcVSyncStart *= 2;
newmptr->CrtcVSyncEnd *= 2;
newmptr->CrtcVTotal *= 2;
newmptr->CrtcVAdjusted = TRUE;
}
newmptr->next = mptr->next;
newmptr->prev = mptr;
mptr->next = newmptr;
newmptr->next->prev = newmptr;
#if 0 /* Do we want this? */
(vptr->SwitchMode)(newmptr);
#endif
if (xf86Verbose)
ErrorF("AddModeLine - Succeeded\n");
return(client->noClientException);
}
static int
ProcXF86VidModeDeleteModeLine(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeDeleteModeLineReq);
ScrnInfoPtr vptr;
DisplayModePtr curmptr, mptr;
DisplayModeRec modetmp;
int len;
if (xf86Verbose) {
ErrorF("DeleteModeLine - scrn: %d clock: %d\n",
stuff->screen, stuff->dotclock, stuff->dotclock);
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->hdisplay, stuff->hsyncstart,
stuff->hsyncend, stuff->htotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
}
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
curmptr = mptr = vptr->modes;
REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2);
if (len != stuff->privsize) {
ErrorF("req_len = %d, sizeof(Req) = %d, privsize = %d, len = %d, length = %d\n",
client->req_len, sizeof(xXF86VidModeDeleteModeLineReq)>>2, stuff->privsize, len, stuff->length);
return BadLength;
}
ErrorF("Checking against clock: %d (%d)\n",
mptr->Clock, CLOCKSPD(mptr->Clock, vptr));
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
mptr->HDisplay, mptr->HSyncStart,
mptr->HSyncEnd, mptr->HTotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
mptr->VDisplay, mptr->VSyncStart, mptr->VSyncEnd,
mptr->VTotal, mptr->Flags);
if (MODEMATCH(mptr, stuff, vptr))
return BadValue;
while ((mptr = mptr->next) != curmptr) {
ErrorF("Checking against clock: %d (%d)\n",
mptr->Clock, CLOCKSPD(mptr->Clock, vptr));
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
mptr->HDisplay, mptr->HSyncStart,
mptr->HSyncEnd, mptr->HTotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
mptr->VDisplay, mptr->VSyncStart, mptr->VSyncEnd,
mptr->VTotal, mptr->Flags);
if (MODEMATCH(mptr, stuff, vptr)) {
mptr->prev->next = mptr->next;
mptr->next->prev = mptr->prev;
xfree(mptr->name);
xfree(mptr->Private);
xfree(mptr);
if (xf86Verbose)
ErrorF("DeleteModeLine - Succeeded\n");
return(client->noClientException);
}
}
return BadValue;
}
static int
ProcXF86VidModeModModeLine(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeModModeLineReq);
ScrnInfoPtr vptr;
DisplayModePtr mptr;
DisplayModeRec modetmp;
int len;
if (xf86Verbose) {
ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->screen, stuff->hdisplay, stuff->hsyncstart,
stuff->hsyncend, stuff->htotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
}
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
mptr = vptr->modes;
REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2);
if (len != stuff->privsize)
return BadLength;
if (stuff->hsyncstart < stuff->hdisplay ||
stuff->hsyncend < stuff->hsyncstart ||
stuff->htotal < stuff->hsyncend ||
stuff->vsyncstart < stuff->vdisplay ||
stuff->vsyncend < stuff->vsyncstart ||
stuff->vtotal < stuff->vsyncend)
return BadValue;
memcpy(&modetmp, mptr, sizeof(DisplayModeRec));
modetmp.HDisplay = stuff->hdisplay;
modetmp.HSyncStart = stuff->hsyncstart;
modetmp.HSyncEnd = stuff->hsyncend;
modetmp.HTotal = stuff->htotal;
modetmp.VDisplay = stuff->vdisplay;
modetmp.VSyncStart = stuff->vsyncstart;
modetmp.VSyncEnd = stuff->vsyncend;
modetmp.VTotal = stuff->vtotal;
modetmp.Flags = stuff->flags;
if (mptr->PrivSize && stuff->privsize) {
if (mptr->PrivSize != stuff->privsize)
return BadValue;
}
if (mptr->PrivSize && mptr->Private) {
modetmp.Private =
(INT32 *)ALLOCATE_LOCAL(mptr->PrivSize * sizeof(INT32));
if (stuff->privsize) {
if (xf86Verbose)
ErrorF("ModModeLine - Request includes privates\n");
memcpy(modetmp.Private, &stuff[1], mptr->PrivSize * sizeof(INT32));
} else
memcpy(modetmp.Private, mptr->Private,
mptr->PrivSize * sizeof(INT32));
}
/* Check that the mode is consistent with the monitor specs */
switch (xf86CheckMode(vptr, &modetmp, vptr->monitor, FALSE)) {
case MODE_HSYNC:
DEALLOCATE_LOCAL(modetmp.Private);
return vidmodeErrorBase + XF86VidModeBadHTimings;
case MODE_VSYNC:
DEALLOCATE_LOCAL(modetmp.Private);
return vidmodeErrorBase + XF86VidModeBadVTimings;
}
/* Check that the driver is happy with the mode */
if (vptr->ValidMode(&modetmp, xf86Verbose, MODE_VID) != MODE_OK) {
DEALLOCATE_LOCAL(modetmp.Private);
return vidmodeErrorBase + XF86VidModeModeUnsuitable;
}
DEALLOCATE_LOCAL(modetmp.Private);
mptr->HDisplay = stuff->hdisplay;
mptr->HSyncStart = stuff->hsyncstart;
mptr->HSyncEnd = stuff->hsyncend;
mptr->HTotal = stuff->htotal;
mptr->VDisplay = stuff->vdisplay;
mptr->VSyncStart = stuff->vsyncstart;
mptr->VSyncEnd = stuff->vsyncend;
mptr->VTotal = stuff->vtotal;
mptr->Flags = stuff->flags;
mptr->CrtcHDisplay = stuff->hdisplay;
mptr->CrtcHSyncStart = stuff->hsyncstart;
mptr->CrtcHSyncEnd = stuff->hsyncend;
mptr->CrtcHTotal = stuff->htotal;
mptr->CrtcVDisplay = stuff->vdisplay;
mptr->CrtcVSyncStart = stuff->vsyncstart;
mptr->CrtcVSyncEnd = stuff->vsyncend;
mptr->CrtcVTotal = stuff->vtotal;
mptr->CrtcVAdjusted = FALSE;
mptr->CrtcHAdjusted = FALSE;
if (mptr->Flags & V_DBLSCAN)
{
mptr->CrtcVDisplay *= 2;
mptr->CrtcVSyncStart *= 2;
mptr->CrtcVSyncEnd *= 2;
mptr->CrtcVTotal *= 2;
mptr->CrtcVAdjusted = TRUE;
}
if (mptr->PrivSize && stuff->privsize) {
memcpy(mptr->Private, &stuff[1], mptr->PrivSize * sizeof(INT32));
}
(vptr->SwitchMode)(mptr);
(vptr->AdjustFrame)(vptr->frameX0, vptr->frameY0);
if (xf86Verbose)
ErrorF("ModModeLine - Succeeded\n");
return(client->noClientException);
}
static int
ProcXF86VidModeValidateModeLine(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeValidateModeLineReq);
xXF86VidModeValidateModeLineReply rep;
ScrnInfoPtr vptr;
DisplayModePtr mptr;
DisplayModeRec modetmp;
int len, status;
if (xf86Verbose) {
ErrorF("ValidateModeLine - scrn: %d clock: %d\n",
stuff->screen, stuff->dotclock, stuff->dotclock);
ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
stuff->hdisplay, stuff->hsyncstart,
stuff->hsyncend, stuff->htotal);
ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
stuff->vtotal, stuff->flags);
}
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
mptr = vptr->modes;
REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2);
if (len != stuff->privsize)
return BadLength;
status = MODE_OK;
modetmp.Private = NULL;
if (stuff->hsyncstart < stuff->hdisplay ||
stuff->hsyncend < stuff->hsyncstart ||
stuff->htotal < stuff->hsyncend ||
stuff->vsyncstart < stuff->vdisplay ||
stuff->vsyncend < stuff->vsyncstart ||
stuff->vtotal < stuff->vsyncend)
{
status = MODE_BAD;
goto status_reply;
}
memcpy(&modetmp, mptr, sizeof(DisplayModeRec));
modetmp.HDisplay = stuff->hdisplay;
modetmp.HSyncStart = stuff->hsyncstart;
modetmp.HSyncEnd = stuff->hsyncend;
modetmp.HTotal = stuff->htotal;
modetmp.VDisplay = stuff->vdisplay;
modetmp.VSyncStart = stuff->vsyncstart;
modetmp.VSyncEnd = stuff->vsyncend;
modetmp.VTotal = stuff->vtotal;
modetmp.Flags = stuff->flags;
modetmp.Private = NULL;
if (mptr->PrivSize && stuff->privsize) {
if (mptr->PrivSize != stuff->privsize) {
status = MODE_BAD;
goto status_reply;
}
}
if (mptr->PrivSize && mptr->Private) {
modetmp.Private =
(INT32 *)ALLOCATE_LOCAL(mptr->PrivSize * sizeof(INT32));
if (stuff->privsize) {
if (xf86Verbose)
ErrorF("ValidateModeLine - Request includes privates\n");
memcpy(modetmp.Private, &stuff[1], mptr->PrivSize * sizeof(INT32));
} else
memcpy(modetmp.Private, mptr->Private,
mptr->PrivSize * sizeof(INT32));
}
/* Check that the mode is consistent with the monitor specs */
if ((status = xf86CheckMode(vptr, &modetmp, vptr->monitor, FALSE)) != MODE_OK)
goto status_reply;
/* Check that the driver is happy with the mode */
status = vptr->ValidMode(&modetmp, xf86Verbose, MODE_VID);
status_reply:
if (modetmp.Private)
DEALLOCATE_LOCAL(modetmp.Private);
rep.type = X_Reply;
rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply)
- SIZEOF(xGenericReply)) >> 2;
rep.sequenceNumber = client->sequence;
rep.status = status;
if (client->swapped) {
register int n;
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.status, n);
}
WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep);
if (xf86Verbose)
ErrorF("ValidateModeLine - Succeeded\n");
return(client->noClientException);
}
static int
ProcXF86VidModeSwitchMode(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeSwitchModeReq);
ScreenPtr vptr;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = screenInfo.screens[stuff->screen];
if (xf86Info.dontZoom)
return vidmodeErrorBase + XF86VidModeZoomLocked;
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
xf86ZoomViewport(vptr, (short)stuff->zoom);
return (client->noClientException);
}
static int
ProcXF86VidModeSwitchToMode(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeSwitchToModeReq);
ScrnInfoPtr vptr;
DisplayModePtr curmptr, mptr;
DisplayModeRec modetmp;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
if (xf86Info.dontZoom)
return vidmodeErrorBase + XF86VidModeZoomLocked;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
curmptr = mptr = vptr->modes;
REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
if (MODEMATCH(mptr, stuff, vptr))
return (client->noClientException);
while ((mptr = mptr->next) != curmptr) {
if (MODEMATCH(mptr, stuff, vptr)) {
if ((vptr->SwitchMode)(mptr)) {
vptr->modes = mptr;
vptr->frameX0 = (vptr->frameX1 +vptr->frameX0 -mptr->HDisplay)/2;
vptr->frameX1 = vptr->frameX0 + mptr->HDisplay -1;
if (vptr->frameX0 < 0) {
vptr->frameX0 = 0;
vptr->frameX1 = mptr->HDisplay -1;
} else if (vptr->frameX1 >= vptr->virtualX) {
vptr->frameX0 = vptr->virtualX - mptr->HDisplay;
vptr->frameX1 = vptr->frameX0 + mptr->HDisplay -1;
}
vptr->frameY0 = (vptr->frameY1 +vptr->frameY0 -mptr->VDisplay)/2;
vptr->frameY1 = vptr->frameY0 + mptr->VDisplay -1;
if (vptr->frameY0 < 0) {
vptr->frameY0 = 0;
vptr->frameY1 = mptr->VDisplay -1;
} else if (vptr->frameY1 >= vptr->virtualY) {
vptr->frameY0 = vptr->virtualY - mptr->VDisplay;
vptr->frameY1 = vptr->frameY0 + mptr->VDisplay -1;
}
}
(vptr->AdjustFrame)(vptr->frameX0, vptr->frameY0);
return(client->noClientException);
}
}
return BadValue;
}
static int
ProcXF86VidModeLockModeSwitch(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeLockModeSwitchReq);
ScreenPtr vptr;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = screenInfo.screens[stuff->screen];
if (xf86Info.dontZoom)
return vidmodeErrorBase + XF86VidModeZoomLocked;
REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
xf86LockZoom(vptr, (short)stuff->lock);
return (client->noClientException);
}
static int
ProcXF86VidModeGetMonitor(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeGetMonitorReq);
xXF86VidModeGetMonitorReply rep;
register int n;
ScrnInfoPtr vptr;
MonPtr mptr;
CARD32 *hsyncdata, *vsyncdata;
int i;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
mptr = vptr->monitor;
REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
rep.type = X_Reply;
if (mptr->vendor)
rep.vendorLength = strlen(mptr->vendor);
else
rep.vendorLength = 0;
if (mptr->model)
rep.modelLength = strlen(mptr->model);
else
rep.modelLength = 0;
rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) +
(mptr->n_hsync + mptr->n_vrefresh) * sizeof(CARD32) +
((rep.vendorLength + 3) & ~3) +
((rep.modelLength + 3) & ~3)) >> 2;
rep.sequenceNumber = client->sequence;
rep.nhsync = mptr->n_hsync;
rep.nvsync = mptr->n_vrefresh;
#if 0
rep.bandwidth = (unsigned long)(mptr->bandwidth * 1e6);
#endif
hsyncdata = ALLOCATE_LOCAL(mptr->n_hsync * sizeof(CARD32));
if (!hsyncdata) {
return BadAlloc;
}
vsyncdata = ALLOCATE_LOCAL(mptr->n_vrefresh * sizeof(CARD32));
if (!vsyncdata) {
DEALLOCATE_LOCAL(hsyncdata);
return BadAlloc;
}
for (i = 0; i < mptr->n_hsync; i++) {
hsyncdata[i] = (unsigned short)(mptr->hsync[i].lo * 100.0) |
(unsigned short)(mptr->hsync[i].hi * 100.0) << 16;
}
for (i = 0; i < mptr->n_vrefresh; i++) {
vsyncdata[i] = (unsigned short)(mptr->vrefresh[i].lo * 100.0) |
(unsigned short)(mptr->vrefresh[i].hi * 100.0) << 16;
}
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.bandwidth, n);
}
WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep);
client->pSwapReplyFunc = Swap32Write;
WriteSwappedDataToClient(client, mptr->n_hsync * sizeof(CARD32),
hsyncdata);
WriteSwappedDataToClient(client, mptr->n_vrefresh * sizeof(CARD32),
vsyncdata);
if (rep.vendorLength)
WriteToClient(client, rep.vendorLength, mptr->vendor);
if (rep.modelLength)
WriteToClient(client, rep.modelLength, mptr->model);
DEALLOCATE_LOCAL(hsyncdata);
DEALLOCATE_LOCAL(vsyncdata);
return (client->noClientException);
}
static int
ProcXF86VidModeGetViewPort(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeGetViewPortReq);
xXF86VidModeGetViewPortReply rep;
register int n;
ScrnInfoPtr vptr;
MonPtr mptr;
CARD32 *hsyncdata, *vsyncdata;
int i;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
mptr = vptr->monitor;
REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
rep.type = X_Reply;
return (client->noClientException);
}
static int
ProcXF86VidModeSetViewPort(client)
register ClientPtr client;
{
REQUEST(xXF86VidModeSetViewPortReq);
register int n;
ScrnInfoPtr vptr;
MonPtr mptr;
CARD32 *hsyncdata, *vsyncdata;
int i;
if (stuff->screen > screenInfo.numScreens)
return BadValue;
vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
mptr = vptr->monitor;
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
return (client->noClientException);
}
static int
ProcXF86VidModeDispatch (client)
register ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data)
{
case X_XF86VidModeQueryVersion:
return ProcXF86VidModeQueryVersion(client);
case X_XF86VidModeGetModeLine:
return ProcXF86VidModeGetModeLine(client);
case X_XF86VidModeGetAllModeLines:
return ProcXF86VidModeGetAllModeLines(client);
case X_XF86VidModeGetMonitor:
return ProcXF86VidModeGetMonitor(client);
case X_XF86VidModeValidateModeLine:
return ProcXF86VidModeValidateModeLine(client);
case X_XF86VidModeGetViewPort:
return ProcXF86VidModeGetViewPort(client);
default:
if (!xf86VidModeEnabled)
return vidmodeErrorBase + XF86VidModeExtensionDisabled;
if (xf86VidModeAllowNonLocal || LocalClient (client)) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return ProcXF86VidModeAddModeLine(client);
case X_XF86VidModeDeleteModeLine:
return ProcXF86VidModeDeleteModeLine(client);
case X_XF86VidModeModModeLine:
return ProcXF86VidModeModModeLine(client);
case X_XF86VidModeSwitchMode:
return ProcXF86VidModeSwitchMode(client);
case X_XF86VidModeSwitchToMode:
return ProcXF86VidModeSwitchToMode(client);
case X_XF86VidModeLockModeSwitch:
return ProcXF86VidModeLockModeSwitch(client);
case X_XF86VidModeSetViewPort:
return ProcXF86VidModeSetViewPort(client);
default:
return BadRequest;
}
} else
return vidmodeErrorBase + XF86VidModeClientNotLocal;
}
}
static int
SProcXF86VidModeQueryVersion(client)
register ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeQueryVersionReq);
swaps(&stuff->length, n);
return ProcXF86VidModeQueryVersion(client);
}
static int
SProcXF86VidModeGetModeLine(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeGetModeLineReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
swaps(&stuff->screen, n);
return ProcXF86VidModeGetModeLine(client);
}
static int
SProcXF86VidModeGetAllModeLines(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeGetAllModeLinesReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
swaps(&stuff->screen, n);
return ProcXF86VidModeGetAllModeLines(client);
}
static int
SProcXF86VidModeAddModeLine(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeAddModeLineReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
swapl(&stuff->screen, n);
swaps(&stuff->hdisplay, n);
swaps(&stuff->hsyncstart, n);
swaps(&stuff->hsyncend, n);
swaps(&stuff->htotal, n);
swaps(&stuff->vdisplay, n);
swaps(&stuff->vsyncstart, n);
swaps(&stuff->vsyncend, n);
swaps(&stuff->vtotal, n);
swapl(&stuff->flags, n);
swapl(&stuff->privsize, n);
SwapRestL(stuff);
return ProcXF86VidModeAddModeLine(client);
}
static int
SProcXF86VidModeDeleteModeLine(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeDeleteModeLineReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
swapl(&stuff->screen, n);
swaps(&stuff->hdisplay, n);
swaps(&stuff->hsyncstart, n);
swaps(&stuff->hsyncend, n);
swaps(&stuff->htotal, n);
swaps(&stuff->vdisplay, n);
swaps(&stuff->vsyncstart, n);
swaps(&stuff->vsyncend, n);
swaps(&stuff->vtotal, n);
swapl(&stuff->flags, n);
swapl(&stuff->privsize, n);
SwapRestL(stuff);
return ProcXF86VidModeDeleteModeLine(client);
}
static int
SProcXF86VidModeModModeLine(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeModModeLineReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
swapl(&stuff->screen, n);
swaps(&stuff->hdisplay, n);
swaps(&stuff->hsyncstart, n);
swaps(&stuff->hsyncend, n);
swaps(&stuff->htotal, n);
swaps(&stuff->vdisplay, n);
swaps(&stuff->vsyncstart, n);
swaps(&stuff->vsyncend, n);
swaps(&stuff->vtotal, n);
swapl(&stuff->flags, n);
swapl(&stuff->privsize, n);
SwapRestL(stuff);
return ProcXF86VidModeModModeLine(client);
}
static int
SProcXF86VidModeValidateModeLine(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeValidateModeLineReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
swapl(&stuff->screen, n);
swaps(&stuff->hdisplay, n);
swaps(&stuff->hsyncstart, n);
swaps(&stuff->hsyncend, n);
swaps(&stuff->htotal, n);
swaps(&stuff->vdisplay, n);
swaps(&stuff->vsyncstart, n);
swaps(&stuff->vsyncend, n);
swaps(&stuff->vtotal, n);
swapl(&stuff->flags, n);
swapl(&stuff->privsize, n);
SwapRestL(stuff);
return ProcXF86VidModeValidateModeLine(client);
}
static int
SProcXF86VidModeSwitchMode(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeSwitchModeReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
swaps(&stuff->screen, n);
swaps(&stuff->zoom, n);
return ProcXF86VidModeSwitchMode(client);
}
static int
SProcXF86VidModeSwitchToMode(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeSwitchToModeReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
swaps(&stuff->screen, n);
return ProcXF86VidModeSwitchToMode(client);
}
static int
SProcXF86VidModeLockModeSwitch(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeLockModeSwitchReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
swaps(&stuff->screen, n);
swaps(&stuff->lock, n);
return ProcXF86VidModeLockModeSwitch(client);
}
static int
SProcXF86VidModeGetMonitor(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeGetMonitorReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
swaps(&stuff->screen, n);
return ProcXF86VidModeGetMonitor(client);
}
static int
SProcXF86VidModeGetViewPort(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeGetViewPortReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
swaps(&stuff->screen, n);
return ProcXF86VidModeGetViewPort(client);
}
static int
SProcXF86VidModeSetViewPort(client)
ClientPtr client;
{
register int n;
REQUEST(xXF86VidModeSetViewPortReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
swaps(&stuff->screen, n);
return ProcXF86VidModeSetViewPort(client);
}
static int
SProcXF86VidModeDispatch (client)
register ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data)
{
case X_XF86VidModeQueryVersion:
return SProcXF86VidModeQueryVersion(client);
case X_XF86VidModeGetModeLine:
return SProcXF86VidModeGetModeLine(client);
case X_XF86VidModeGetAllModeLines:
return SProcXF86VidModeGetAllModeLines(client);
case X_XF86VidModeGetMonitor:
return SProcXF86VidModeGetMonitor(client);
case X_XF86VidModeGetViewPort:
return SProcXF86VidModeGetViewPort(client);
case X_XF86VidModeValidateModeLine:
return SProcXF86VidModeValidateModeLine(client);
default:
if (!xf86VidModeEnabled)
return vidmodeErrorBase + XF86VidModeExtensionDisabled;
if (xf86VidModeAllowNonLocal || LocalClient(client)) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return SProcXF86VidModeAddModeLine(client);
case X_XF86VidModeDeleteModeLine:
return SProcXF86VidModeDeleteModeLine(client);
case X_XF86VidModeModModeLine:
return SProcXF86VidModeModModeLine(client);
case X_XF86VidModeSwitchMode:
return SProcXF86VidModeSwitchMode(client);
case X_XF86VidModeSwitchToMode:
return SProcXF86VidModeSwitchToMode(client);
case X_XF86VidModeLockModeSwitch:
return SProcXF86VidModeLockModeSwitch(client);
case X_XF86VidModeSetViewPort:
return SProcXF86VidModeSetViewPort(client);
default:
return BadRequest;
}
} else
return vidmodeErrorBase + XF86VidModeClientNotLocal;
}
}
|