File: | hw/xfree86/common/xf86vmode.c |
Location: | line 1627, column 5 |
Description: | Potential leak of memory pointed to by 'pPriv' |
1 | ||||
2 | /* | |||
3 | ||||
4 | Copyright 1995 Kaleb S. KEITHLEY | |||
5 | ||||
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: | |||
13 | ||||
14 | The above copyright notice and this permission notice shall be | |||
15 | included in all copies or substantial portions of the Software. | |||
16 | ||||
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. | |||
24 | ||||
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 | |||
29 | ||||
30 | */ | |||
31 | /* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ | |||
32 | ||||
33 | #ifdef HAVE_XORG_CONFIG_H1 | |||
34 | #include <xorg-config.h> | |||
35 | #endif | |||
36 | ||||
37 | #include <X11/X.h> | |||
38 | #include <X11/Xproto.h> | |||
39 | #include "misc.h" | |||
40 | #include "dixstruct.h" | |||
41 | #include "extnsionst.h" | |||
42 | #include "xf86Extensions.h" | |||
43 | #include "scrnintstr.h" | |||
44 | #include "servermd.h" | |||
45 | #include <X11/extensions/xf86vmproto.h> | |||
46 | #include "swaprep.h" | |||
47 | #include "xf86.h" | |||
48 | #include "vidmodeproc.h" | |||
49 | #include "globals.h" | |||
50 | #include "protocol-versions.h" | |||
51 | ||||
52 | #define DEFAULT_XF86VIDMODE_VERBOSITY3 3 | |||
53 | ||||
54 | static int VidModeErrorBase; | |||
55 | static DevPrivateKeyRec VidModeClientPrivateKeyRec; | |||
56 | ||||
57 | #define VidModeClientPrivateKey(&VidModeClientPrivateKeyRec) (&VidModeClientPrivateKeyRec) | |||
58 | ||||
59 | /* This holds the client's version information */ | |||
60 | typedef struct { | |||
61 | int major; | |||
62 | int minor; | |||
63 | } VidModePrivRec, *VidModePrivPtr; | |||
64 | ||||
65 | #define VM_GETPRIV(c)((VidModePrivPtr) dixLookupPrivate(&(c)->devPrivates, ( &VidModeClientPrivateKeyRec))) ((VidModePrivPtr) \ | |||
66 | dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey(&VidModeClientPrivateKeyRec))) | |||
67 | #define VM_SETPRIV(c,p)dixSetPrivate(&(c)->devPrivates, (&VidModeClientPrivateKeyRec ), p) \ | |||
68 | dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey(&VidModeClientPrivateKeyRec), p) | |||
69 | ||||
70 | #if 0 | |||
71 | static unsigned char XF86VidModeReqCode = 0; | |||
72 | #endif | |||
73 | ||||
74 | /* The XF86VIDMODE_EVENTS code is far from complete */ | |||
75 | ||||
76 | #ifdef XF86VIDMODE_EVENTS | |||
77 | static int XF86VidModeEventBase = 0; | |||
78 | ||||
79 | static void SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent * /* to */ | |||
80 | ); | |||
81 | ||||
82 | static RESTYPE EventType; /* resource type for event masks */ | |||
83 | ||||
84 | typedef struct _XF86VidModeEvent *XF86VidModeEventPtr; | |||
85 | ||||
86 | typedef struct _XF86VidModeEvent { | |||
87 | XF86VidModeEventPtr next; | |||
88 | ClientPtr client; | |||
89 | ScreenPtr screen; | |||
90 | XID resource; | |||
91 | CARD32 mask; | |||
92 | } XF86VidModeEventRec; | |||
93 | ||||
94 | static int XF86VidModeFreeEvents(); | |||
95 | ||||
96 | typedef struct _XF86VidModeScreenPrivate { | |||
97 | XF86VidModeEventPtr events; | |||
98 | Bool hasWindow; | |||
99 | } XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr; | |||
100 | ||||
101 | static DevPrivateKeyRec ScreenPrivateKeyRec; | |||
102 | ||||
103 | #define ScreenPrivateKey (&ScreenPrivateKeyRec) | |||
104 | ||||
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) | |||
110 | ||||
111 | #define New(t) (malloc(sizeof (t))) | |||
112 | #endif | |||
113 | ||||
114 | #ifdef DEBUG | |||
115 | #define DEBUG_P(x) ErrorF(x"\n"); | |||
116 | #else | |||
117 | #define DEBUG_P(x) /**/ | |||
118 | #endif | |||
119 | static int | |||
120 | ClientMajorVersion(ClientPtr client) | |||
121 | { | |||
122 | VidModePrivPtr pPriv; | |||
123 | ||||
124 | pPriv = VM_GETPRIV(client)((VidModePrivPtr) dixLookupPrivate(&(client)->devPrivates , (&VidModeClientPrivateKeyRec))); | |||
125 | if (!pPriv) | |||
126 | return 0; | |||
127 | else | |||
128 | return pPriv->major; | |||
129 | } | |||
130 | ||||
131 | #ifdef XF86VIDMODE_EVENTS | |||
132 | static void | |||
133 | CheckScreenPrivate(pScreen) | |||
134 | ScreenPtr | |||
135 | pScreen; | |||
136 | { | |||
137 | SetupScreen(pScreen); | |||
138 | ||||
139 | if (!pPriv) | |||
140 | return; | |||
141 | if (!pPriv->events && !pPriv->hasWindow) { | |||
142 | free(pPriv); | |||
143 | SetScreenPrivate(pScreen, NULL((void*)0)); | |||
144 | } | |||
145 | } | |||
146 | ||||
147 | static XF86VidModeScreenPrivatePtr | |||
148 | MakeScreenPrivate(pScreen) | |||
149 | ScreenPtr | |||
150 | pScreen; | |||
151 | { | |||
152 | SetupScreen(pScreen); | |||
153 | ||||
154 | if (pPriv) | |||
155 | return pPriv; | |||
156 | pPriv = New(XF86VidModeScreenPrivateRec); | |||
157 | if (!pPriv) | |||
158 | return 0; | |||
159 | pPriv->events = 0; | |||
160 | pPriv->hasWindow = FALSE0; | |||
161 | SetScreenPrivate(pScreen, pPriv); | |||
162 | return pPriv; | |||
163 | } | |||
164 | ||||
165 | static unsigned long | |||
166 | getEventMask(ScreenPtr pScreen, ClientPtr client) | |||
167 | { | |||
168 | SetupScreen(pScreen); | |||
169 | XF86VidModeEventPtr pEv; | |||
170 | ||||
171 | if (!pPriv) | |||
172 | return 0; | |||
173 | for (pEv = pPriv->events; pEv; pEv = pEv->next) | |||
174 | if (pEv->client == client) | |||
175 | return pEv->mask; | |||
176 | return 0; | |||
177 | } | |||
178 | ||||
179 | static Bool | |||
180 | setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask) | |||
181 | { | |||
182 | SetupScreen(pScreen); | |||
183 | XF86VidModeEventPtr pEv, *pPrev; | |||
184 | ||||
185 | if (getEventMask(pScreen, client) == mask) | |||
186 | return TRUE1; | |||
187 | if (!pPriv) { | |||
188 | pPriv = MakeScreenPrivate(pScreen); | |||
189 | if (!pPriv) | |||
190 | return FALSE0; | |||
191 | } | |||
192 | for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next) | |||
193 | if (pEv->client == client) | |||
194 | break; | |||
195 | if (mask == 0) { | |||
196 | *pPrev = pEv->next; | |||
197 | free(pEv); | |||
198 | CheckScreenPrivate(pScreen); | |||
199 | } | |||
200 | else { | |||
201 | if (!pEv) { | |||
202 | pEv = New(ScreenSaverEventRec); | |||
203 | if (!pEv) { | |||
204 | CheckScreenPrivate(pScreen); | |||
205 | return FALSE0; | |||
206 | } | |||
207 | *pPrev = pEv; | |||
208 | pEv->next = NULL((void*)0); | |||
209 | pEv->client = client; | |||
210 | pEv->screen = pScreen; | |||
211 | pEv->resource = FakeClientID(client->index); | |||
212 | } | |||
213 | pEv->mask = mask; | |||
214 | } | |||
215 | return TRUE1; | |||
216 | } | |||
217 | ||||
218 | static int | |||
219 | XF86VidModeFreeEvents(void *value, XID id) | |||
220 | { | |||
221 | XF86VidModeEventPtr pOld = (XF86VidModeEventPtr) value; | |||
222 | ScreenPtr pScreen = pOld->screen; | |||
223 | ||||
224 | SetupScreen(pScreen); | |||
225 | XF86VidModeEventPtr pEv, *pPrev; | |||
226 | ||||
227 | if (!pPriv) | |||
228 | return TRUE1; | |||
229 | for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next) | |||
230 | if (pEv == pOld) | |||
231 | break; | |||
232 | if (!pEv) | |||
233 | return TRUE1; | |||
234 | *pPrev = pEv->next; | |||
235 | free(pEv); | |||
236 | CheckScreenPrivate(pScreen); | |||
237 | return TRUE1; | |||
238 | } | |||
239 | ||||
240 | static void | |||
241 | SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) | |||
242 | { | |||
243 | XF86VidModeScreenPrivatePtr pPriv; | |||
244 | unsigned long mask; | |||
245 | xXF86VidModeNotifyEvent ev; | |||
246 | int kind; | |||
247 | ||||
248 | UpdateCurrentTimeIf(); | |||
249 | mask = XF86VidModeNotifyMask; | |||
250 | pScreen = screenInfo.screens[pScreen->myNum]; | |||
251 | pPriv = GetScreenPrivate(pScreen); | |||
252 | if (!pPriv) | |||
253 | return; | |||
254 | kind = XF86VidModeModeChange; | |||
255 | for (pEv = pPriv->events; pEv; pEv = pEv->next) { | |||
256 | if (pEv->mask & mask) { | |||
257 | XF86VidModeEventPtr pEv = { | |||
258 | .type = XF86VidModeNotify + XF86VidModeEventBase, | |||
259 | .state = state, | |||
260 | .timestamp = currentTime.milliseconds, | |||
261 | .root = pScreen->root->drawable.id, | |||
262 | .kind = kind, | |||
263 | .forced = forced | |||
264 | }; | |||
265 | WriteEventsToClient(pEv->client, 1, (xEvent *) &ev); | |||
266 | } | |||
267 | } | |||
268 | } | |||
269 | ||||
270 | static void | |||
271 | SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from, | |||
272 | xXF86VidModeNotifyEvent * to) | |||
273 | { | |||
274 | to->type = from->type; | |||
275 | to->state = from->state; | |||
276 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); | |||
277 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); | |||
278 | cpswapl(from->root, to->root)do { if (sizeof((from->root)) != 4 || sizeof((to->root) ) != 4) wrong_size(); (to->root) = lswapl((from->root)) ; } while (0); | |||
279 | to->kind = from->kind; | |||
280 | to->forced = from->forced; | |||
281 | } | |||
282 | #endif | |||
283 | ||||
284 | static int | |||
285 | ProcXF86VidModeQueryVersion(ClientPtr client) | |||
286 | { | |||
287 | xXF86VidModeQueryVersionReply rep = { | |||
288 | .type = X_Reply1, | |||
289 | .sequenceNumber = client->sequence, | |||
290 | .length = 0, | |||
291 | .majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION2, | |||
292 | .minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION2 | |||
293 | }; | |||
294 | ||||
295 | DEBUG_P("XF86VidModeQueryVersion"); | |||
296 | ||||
297 | REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq)if ((sizeof(xXF86VidModeQueryVersionReq) >> 2) != client ->req_len) return(16); | |||
298 | ||||
299 | if (client->swapped) { | |||
300 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
301 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
302 | swaps(&rep.majorVersion)do { if (sizeof(*(&rep.majorVersion)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.majorVersion) & 1) && ((uintptr_t)(&rep.majorVersion) & 1) == 0) *(&rep.majorVersion) = lswaps(*(&rep.majorVersion )); else swap_uint16((uint16_t *)(&rep.majorVersion)); } while (0); | |||
303 | swaps(&rep.minorVersion)do { if (sizeof(*(&rep.minorVersion)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.minorVersion) & 1) && ((uintptr_t)(&rep.minorVersion) & 1) == 0) *(&rep.minorVersion) = lswaps(*(&rep.minorVersion )); else swap_uint16((uint16_t *)(&rep.minorVersion)); } while (0); | |||
304 | } | |||
305 | WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), &rep); | |||
306 | return Success0; | |||
307 | } | |||
308 | ||||
309 | static int | |||
310 | ProcXF86VidModeGetModeLine(ClientPtr client) | |||
311 | { | |||
312 | REQUEST(xXF86VidModeGetModeLineReq)xXF86VidModeGetModeLineReq *stuff = (xXF86VidModeGetModeLineReq *)client->requestBuffer; | |||
313 | xXF86VidModeGetModeLineReply rep = { | |||
314 | .type = X_Reply1, | |||
315 | .sequenceNumber = client->sequence | |||
316 | }; | |||
317 | void *mode; | |||
318 | int dotClock; | |||
319 | int ver; | |||
320 | ||||
321 | DEBUG_P("XF86VidModeGetModeline"); | |||
322 | ||||
323 | ver = ClientMajorVersion(client); | |||
324 | REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq)if ((sizeof(xXF86VidModeGetModeLineReq) >> 2) != client ->req_len) return(16); | |||
325 | ||||
326 | if (ver < 2) { | |||
327 | rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply)36 - | |||
328 | SIZEOF(xGenericReply)32); | |||
329 | } | |||
330 | else { | |||
331 | rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply)52 - | |||
332 | SIZEOF(xGenericReply)32); | |||
333 | } | |||
334 | ||||
335 | if (stuff->screen >= screenInfo.numScreens) | |||
336 | return BadValue2; | |||
337 | ||||
338 | if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) | |||
339 | return BadValue2; | |||
340 | ||||
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); | |||
352 | ||||
353 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
361 | } | |||
362 | ||||
363 | /* | |||
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 | |||
367 | */ | |||
368 | rep.privsize = 0; | |||
369 | ||||
370 | if (client->swapped) { | |||
371 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
372 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
373 | swapl(&rep.dotclock)do { if (sizeof(*(&rep.dotclock)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.dotclock) & 3) && ((uintptr_t)(&rep.dotclock) & 3) == 0) *(&rep.dotclock ) = lswapl(*(&rep.dotclock)); else swap_uint32((uint32_t * )(&rep.dotclock)); } while (0); | |||
374 | swaps(&rep.hdisplay)do { if (sizeof(*(&rep.hdisplay)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.hdisplay) & 1) && ((uintptr_t)(&rep.hdisplay) & 1) == 0) *(&rep.hdisplay ) = lswaps(*(&rep.hdisplay)); else swap_uint16((uint16_t * )(&rep.hdisplay)); } while (0); | |||
375 | swaps(&rep.hsyncstart)do { if (sizeof(*(&rep.hsyncstart)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.hsyncstart) & 1) && ((uintptr_t)(&rep.hsyncstart) & 1) == 0 ) *(&rep.hsyncstart) = lswaps(*(&rep.hsyncstart)); else swap_uint16((uint16_t *)(&rep.hsyncstart)); } while (0); | |||
376 | swaps(&rep.hsyncend)do { if (sizeof(*(&rep.hsyncend)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.hsyncend) & 1) && ((uintptr_t)(&rep.hsyncend) & 1) == 0) *(&rep.hsyncend ) = lswaps(*(&rep.hsyncend)); else swap_uint16((uint16_t * )(&rep.hsyncend)); } while (0); | |||
377 | swaps(&rep.htotal)do { if (sizeof(*(&rep.htotal)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.htotal) & 1) && ((uintptr_t )(&rep.htotal) & 1) == 0) *(&rep.htotal) = lswaps (*(&rep.htotal)); else swap_uint16((uint16_t *)(&rep. htotal)); } while (0); | |||
378 | swaps(&rep.hskew)do { if (sizeof(*(&rep.hskew)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.hskew) & 1) && ((uintptr_t) (&rep.hskew) & 1) == 0) *(&rep.hskew) = lswaps(*( &rep.hskew)); else swap_uint16((uint16_t *)(&rep.hskew )); } while (0); | |||
379 | swaps(&rep.vdisplay)do { if (sizeof(*(&rep.vdisplay)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.vdisplay) & 1) && ((uintptr_t)(&rep.vdisplay) & 1) == 0) *(&rep.vdisplay ) = lswaps(*(&rep.vdisplay)); else swap_uint16((uint16_t * )(&rep.vdisplay)); } while (0); | |||
380 | swaps(&rep.vsyncstart)do { if (sizeof(*(&rep.vsyncstart)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.vsyncstart) & 1) && ((uintptr_t)(&rep.vsyncstart) & 1) == 0 ) *(&rep.vsyncstart) = lswaps(*(&rep.vsyncstart)); else swap_uint16((uint16_t *)(&rep.vsyncstart)); } while (0); | |||
381 | swaps(&rep.vsyncend)do { if (sizeof(*(&rep.vsyncend)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.vsyncend) & 1) && ((uintptr_t)(&rep.vsyncend) & 1) == 0) *(&rep.vsyncend ) = lswaps(*(&rep.vsyncend)); else swap_uint16((uint16_t * )(&rep.vsyncend)); } while (0); | |||
382 | swaps(&rep.vtotal)do { if (sizeof(*(&rep.vtotal)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.vtotal) & 1) && ((uintptr_t )(&rep.vtotal) & 1) == 0) *(&rep.vtotal) = lswaps (*(&rep.vtotal)); else swap_uint16((uint16_t *)(&rep. vtotal)); } while (0); | |||
383 | swapl(&rep.flags)do { if (sizeof(*(&rep.flags)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.flags) & 3) && ((uintptr_t) (&rep.flags) & 3) == 0) *(&rep.flags) = lswapl(*( &rep.flags)); else swap_uint32((uint32_t *)(&rep.flags )); } while (0); | |||
384 | swapl(&rep.privsize)do { if (sizeof(*(&rep.privsize)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.privsize) & 3) && ((uintptr_t)(&rep.privsize) & 3) == 0) *(&rep.privsize ) = lswapl(*(&rep.privsize)); else swap_uint32((uint32_t * )(&rep.privsize)); } while (0); | |||
385 | } | |||
386 | if (ver < 2) { | |||
387 | xXF86OldVidModeGetModeLineReply oldrep = { | |||
388 | .type = rep.type, | |||
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, | |||
400 | .flags = rep.flags, | |||
401 | .privsize = rep.privsize | |||
402 | }; | |||
403 | WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), &oldrep); | |||
404 | } | |||
405 | else { | |||
406 | WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), &rep); | |||
407 | } | |||
408 | return Success0; | |||
409 | } | |||
410 | ||||
411 | static int | |||
412 | ProcXF86VidModeGetAllModeLines(ClientPtr client) | |||
413 | { | |||
414 | REQUEST(xXF86VidModeGetAllModeLinesReq)xXF86VidModeGetAllModeLinesReq *stuff = (xXF86VidModeGetAllModeLinesReq *)client->requestBuffer; | |||
415 | xXF86VidModeGetAllModeLinesReply rep; | |||
416 | void *mode; | |||
417 | int modecount, dotClock; | |||
418 | int ver; | |||
419 | ||||
420 | DEBUG_P("XF86VidModeGetAllModelines"); | |||
421 | ||||
422 | REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq)if ((sizeof(xXF86VidModeGetAllModeLinesReq) >> 2) != client ->req_len) return(16); | |||
423 | ||||
424 | if (stuff->screen >= screenInfo.numScreens) | |||
425 | return BadValue2; | |||
426 | ||||
427 | ver = ClientMajorVersion(client); | |||
428 | ||||
429 | modecount = VidModeGetNumOfModes(stuff->screen); | |||
430 | if (modecount < 1) | |||
431 | return VidModeErrorBase + XF86VidModeExtensionDisabled4; | |||
432 | ||||
433 | if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) | |||
434 | return BadValue2; | |||
435 | ||||
436 | rep = (xXF86VidModeGetAllModeLinesReply) { | |||
437 | .type = X_Reply1, | |||
438 | .length = SIZEOF(xXF86VidModeGetAllModeLinesReply)32 - | |||
439 | SIZEOF(xGenericReply)32, | |||
440 | .sequenceNumber = client->sequence, | |||
441 | .modecount = modecount | |||
442 | }; | |||
443 | if (ver < 2) | |||
444 | rep.length += modecount * sizeof(xXF86OldVidModeModeInfo); | |||
445 | else | |||
446 | rep.length += modecount * sizeof(xXF86VidModeModeInfo); | |||
447 | rep.length >>= 2; | |||
448 | if (client->swapped) { | |||
449 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
450 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
451 | swapl(&rep.modecount)do { if (sizeof(*(&rep.modecount)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.modecount) & 3 ) && ((uintptr_t)(&rep.modecount) & 3) == 0) * (&rep.modecount) = lswapl(*(&rep.modecount)); else swap_uint32 ((uint32_t *)(&rep.modecount)); } while (0); | |||
452 | } | |||
453 | WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep); | |||
454 | ||||
455 | do { | |||
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), | |||
468 | .privsize = 0 | |||
469 | }; | |||
470 | if (client->swapped) { | |||
471 | swapl(&mdinf.dotclock)do { if (sizeof(*(&mdinf.dotclock)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.dotclock) & 3) && ((uintptr_t)(&mdinf.dotclock) & 3) == 0 ) *(&mdinf.dotclock) = lswapl(*(&mdinf.dotclock)); else swap_uint32((uint32_t *)(&mdinf.dotclock)); } while (0); | |||
472 | swaps(&mdinf.hdisplay)do { if (sizeof(*(&mdinf.hdisplay)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.hdisplay) & 1) && ((uintptr_t)(&mdinf.hdisplay) & 1) == 0 ) *(&mdinf.hdisplay) = lswaps(*(&mdinf.hdisplay)); else swap_uint16((uint16_t *)(&mdinf.hdisplay)); } while (0); | |||
473 | swaps(&mdinf.hsyncstart)do { if (sizeof(*(&mdinf.hsyncstart)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.hsyncstart) & 1) && ((uintptr_t)(&mdinf.hsyncstart) & 1) == 0) *(&mdinf.hsyncstart) = lswaps(*(&mdinf.hsyncstart )); else swap_uint16((uint16_t *)(&mdinf.hsyncstart)); } while (0); | |||
474 | swaps(&mdinf.hsyncend)do { if (sizeof(*(&mdinf.hsyncend)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.hsyncend) & 1) && ((uintptr_t)(&mdinf.hsyncend) & 1) == 0 ) *(&mdinf.hsyncend) = lswaps(*(&mdinf.hsyncend)); else swap_uint16((uint16_t *)(&mdinf.hsyncend)); } while (0); | |||
475 | swaps(&mdinf.htotal)do { if (sizeof(*(&mdinf.htotal)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&mdinf.htotal) & 1) && ((uintptr_t)(&mdinf.htotal) & 1) == 0) *(&mdinf. htotal) = lswaps(*(&mdinf.htotal)); else swap_uint16((uint16_t *)(&mdinf.htotal)); } while (0); | |||
476 | swapl(&mdinf.hskew)do { if (sizeof(*(&mdinf.hskew)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&mdinf.hskew) & 3) && ((uintptr_t)(&mdinf.hskew) & 3) == 0) *(&mdinf.hskew ) = lswapl(*(&mdinf.hskew)); else swap_uint32((uint32_t * )(&mdinf.hskew)); } while (0); | |||
477 | swaps(&mdinf.vdisplay)do { if (sizeof(*(&mdinf.vdisplay)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.vdisplay) & 1) && ((uintptr_t)(&mdinf.vdisplay) & 1) == 0 ) *(&mdinf.vdisplay) = lswaps(*(&mdinf.vdisplay)); else swap_uint16((uint16_t *)(&mdinf.vdisplay)); } while (0); | |||
478 | swaps(&mdinf.vsyncstart)do { if (sizeof(*(&mdinf.vsyncstart)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.vsyncstart) & 1) && ((uintptr_t)(&mdinf.vsyncstart) & 1) == 0) *(&mdinf.vsyncstart) = lswaps(*(&mdinf.vsyncstart )); else swap_uint16((uint16_t *)(&mdinf.vsyncstart)); } while (0); | |||
479 | swaps(&mdinf.vsyncend)do { if (sizeof(*(&mdinf.vsyncend)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.vsyncend) & 1) && ((uintptr_t)(&mdinf.vsyncend) & 1) == 0 ) *(&mdinf.vsyncend) = lswaps(*(&mdinf.vsyncend)); else swap_uint16((uint16_t *)(&mdinf.vsyncend)); } while (0); | |||
480 | swaps(&mdinf.vtotal)do { if (sizeof(*(&mdinf.vtotal)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&mdinf.vtotal) & 1) && ((uintptr_t)(&mdinf.vtotal) & 1) == 0) *(&mdinf. vtotal) = lswaps(*(&mdinf.vtotal)); else swap_uint16((uint16_t *)(&mdinf.vtotal)); } while (0); | |||
481 | swapl(&mdinf.flags)do { if (sizeof(*(&mdinf.flags)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&mdinf.flags) & 3) && ((uintptr_t)(&mdinf.flags) & 3) == 0) *(&mdinf.flags ) = lswapl(*(&mdinf.flags)); else swap_uint32((uint32_t * )(&mdinf.flags)); } while (0); | |||
482 | swapl(&mdinf.privsize)do { if (sizeof(*(&mdinf.privsize)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&mdinf.privsize) & 3) && ((uintptr_t)(&mdinf.privsize) & 3) == 0 ) *(&mdinf.privsize) = lswapl(*(&mdinf.privsize)); else swap_uint32((uint32_t *)(&mdinf.privsize)); } while (0); | |||
483 | } | |||
484 | if (ver < 2) { | |||
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 | |||
497 | }; | |||
498 | WriteToClient(client, sizeof(xXF86OldVidModeModeInfo), &oldmdinf); | |||
499 | } | |||
500 | else { | |||
501 | WriteToClient(client, sizeof(xXF86VidModeModeInfo), &mdinf); | |||
502 | } | |||
503 | ||||
504 | } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); | |||
505 | ||||
506 | return Success0; | |||
507 | } | |||
508 | ||||
509 | #define MODEMATCH(mode,stuff)(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND ) == stuff->hsyncend && VidModeGetModeValue(mode, VIDMODE_H_TOTAL ) == stuff->htotal && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY ) == stuff->vdisplay && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART ) == stuff->vsyncstart && VidModeGetModeValue(mode , VIDMODE_V_SYNCEND) == stuff->vsyncend && VidModeGetModeValue (mode, VIDMODE_V_TOTAL) == stuff->vtotal && VidModeGetModeValue (mode, VIDMODE_FLAGS) == stuff->flags ) \ | |||
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 ) | |||
519 | ||||
520 | static int | |||
521 | ProcXF86VidModeAddModeLine(ClientPtr client) | |||
522 | { | |||
523 | REQUEST(xXF86VidModeAddModeLineReq)xXF86VidModeAddModeLineReq *stuff = (xXF86VidModeAddModeLineReq *)client->requestBuffer; | |||
524 | xXF86OldVidModeAddModeLineReq *oldstuff = | |||
525 | (xXF86OldVidModeAddModeLineReq *) client->requestBuffer; | |||
526 | xXF86VidModeAddModeLineReq newstuff; | |||
527 | void *mode; | |||
528 | int len; | |||
529 | int dotClock; | |||
530 | int ver; | |||
531 | ||||
532 | DEBUG_P("XF86VidModeAddModeline"); | |||
533 | ||||
534 | ver = ClientMajorVersion(client); | |||
535 | if (ver < 2) { | |||
536 | /* convert from old format */ | |||
537 | stuff = &newstuff; | |||
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; | |||
545 | stuff->hskew = 0; | |||
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; | |||
563 | } | |||
564 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
582 | } | |||
583 | ||||
584 | if (ver < 2) { | |||
585 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq)if ((sizeof(xXF86OldVidModeAddModeLineReq) >> 2) > client ->req_len ) return(16); | |||
586 | len = | |||
587 | client->req_len - | |||
588 | bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq)); | |||
589 | } | |||
590 | else { | |||
591 | REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq)if ((sizeof(xXF86VidModeAddModeLineReq) >> 2) > client ->req_len ) return(16); | |||
592 | len = | |||
593 | client->req_len - | |||
594 | bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq)); | |||
595 | } | |||
596 | if (len != stuff->privsize) | |||
597 | return BadLength16; | |||
598 | ||||
599 | if (stuff->screen >= screenInfo.numScreens) | |||
600 | return BadValue2; | |||
601 | ||||
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) | |||
607 | return BadValue2; | |||
608 | ||||
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) | |||
615 | return BadValue2; | |||
616 | ||||
617 | if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) { | |||
618 | Bool found = FALSE0; | |||
619 | ||||
620 | if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) { | |||
621 | do { | |||
622 | if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) | |||
623 | == dotClock) && MODEMATCH(mode, stuff)(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND ) == stuff->hsyncend && VidModeGetModeValue(mode, VIDMODE_H_TOTAL ) == stuff->htotal && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY ) == stuff->vdisplay && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART ) == stuff->vsyncstart && VidModeGetModeValue(mode , VIDMODE_V_SYNCEND) == stuff->vsyncend && VidModeGetModeValue (mode, VIDMODE_V_TOTAL) == stuff->vtotal && VidModeGetModeValue (mode, VIDMODE_FLAGS) == stuff->flags )) { | |||
624 | found = TRUE1; | |||
625 | break; | |||
626 | } | |||
627 | } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); | |||
628 | } | |||
629 | if (!found) | |||
630 | return BadValue2; | |||
631 | } | |||
632 | ||||
633 | mode = VidModeCreateMode(); | |||
634 | if (mode == NULL((void*)0)) | |||
635 | return BadValue2; | |||
636 | ||||
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); | |||
648 | ||||
649 | if (stuff->privsize) | |||
650 | ErrorF("AddModeLine - Privates in request have been ignored\n"); | |||
651 | ||||
652 | /* Check that the mode is consistent with the monitor specs */ | |||
653 | switch (VidModeCheckModeForMonitor(stuff->screen, mode)) { | |||
654 | case MODE_OK: | |||
655 | break; | |||
656 | case MODE_HSYNC: | |||
657 | case MODE_H_ILLEGAL: | |||
658 | free(mode); | |||
659 | return VidModeErrorBase + XF86VidModeBadHTimings1; | |||
660 | case MODE_VSYNC: | |||
661 | case MODE_V_ILLEGAL: | |||
662 | free(mode); | |||
663 | return VidModeErrorBase + XF86VidModeBadVTimings2; | |||
664 | default: | |||
665 | free(mode); | |||
666 | return VidModeErrorBase + XF86VidModeModeUnsuitable3; | |||
667 | } | |||
668 | ||||
669 | /* Check that the driver is happy with the mode */ | |||
670 | if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) { | |||
671 | free(mode); | |||
672 | return VidModeErrorBase + XF86VidModeModeUnsuitable3; | |||
673 | } | |||
674 | ||||
675 | VidModeSetCrtcForMode(stuff->screen, mode); | |||
676 | ||||
677 | VidModeAddModeline(stuff->screen, mode); | |||
678 | ||||
679 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) | |||
680 | ErrorF("AddModeLine - Succeeded\n"); | |||
681 | return Success0; | |||
682 | } | |||
683 | ||||
684 | static int | |||
685 | ProcXF86VidModeDeleteModeLine(ClientPtr client) | |||
686 | { | |||
687 | REQUEST(xXF86VidModeDeleteModeLineReq)xXF86VidModeDeleteModeLineReq *stuff = (xXF86VidModeDeleteModeLineReq *)client->requestBuffer; | |||
688 | xXF86OldVidModeDeleteModeLineReq *oldstuff = | |||
689 | (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer; | |||
690 | xXF86VidModeDeleteModeLineReq newstuff; | |||
691 | void *mode; | |||
692 | int len, dotClock; | |||
693 | int ver; | |||
694 | ||||
695 | DEBUG_P("XF86VidModeDeleteModeline"); | |||
696 | ||||
697 | ver = ClientMajorVersion(client); | |||
698 | if (ver < 2) { | |||
699 | /* convert from old format */ | |||
700 | stuff = &newstuff; | |||
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; | |||
708 | stuff->hskew = 0; | |||
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; | |||
715 | } | |||
716 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
722 | ErrorF | |||
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); | |||
726 | } | |||
727 | ||||
728 | if (ver < 2) { | |||
729 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq)if ((sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2) > client->req_len ) return(16); | |||
730 | len = | |||
731 | client->req_len - | |||
732 | bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq)); | |||
733 | } | |||
734 | else { | |||
735 | REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq)if ((sizeof(xXF86VidModeDeleteModeLineReq) >> 2) > client ->req_len ) return(16); | |||
736 | len = | |||
737 | client->req_len - | |||
738 | bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq)); | |||
739 | } | |||
740 | if (len != stuff->privsize) { | |||
741 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
747 | } | |||
748 | return BadLength16; | |||
749 | } | |||
750 | ||||
751 | if (stuff->screen >= screenInfo.numScreens) | |||
752 | return BadValue2; | |||
753 | ||||
754 | if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) | |||
755 | return BadValue2; | |||
756 | ||||
757 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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)); | |||
765 | ErrorF | |||
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)); | |||
772 | } | |||
773 | if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) && | |||
774 | MODEMATCH(mode, stuff)(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND ) == stuff->hsyncend && VidModeGetModeValue(mode, VIDMODE_H_TOTAL ) == stuff->htotal && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY ) == stuff->vdisplay && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART ) == stuff->vsyncstart && VidModeGetModeValue(mode , VIDMODE_V_SYNCEND) == stuff->vsyncend && VidModeGetModeValue (mode, VIDMODE_V_TOTAL) == stuff->vtotal && VidModeGetModeValue (mode, VIDMODE_FLAGS) == stuff->flags )) | |||
775 | return BadValue2; | |||
776 | ||||
777 | if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) | |||
778 | return BadValue2; | |||
779 | ||||
780 | do { | |||
781 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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)); | |||
789 | ErrorF | |||
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)); | |||
796 | } | |||
797 | if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) && | |||
798 | MODEMATCH(mode, stuff)(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND ) == stuff->hsyncend && VidModeGetModeValue(mode, VIDMODE_H_TOTAL ) == stuff->htotal && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY ) == stuff->vdisplay && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART ) == stuff->vsyncstart && VidModeGetModeValue(mode , VIDMODE_V_SYNCEND) == stuff->vsyncend && VidModeGetModeValue (mode, VIDMODE_V_TOTAL) == stuff->vtotal && VidModeGetModeValue (mode, VIDMODE_FLAGS) == stuff->flags )) { | |||
799 | VidModeDeleteModeline(stuff->screen, mode); | |||
800 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) | |||
801 | ErrorF("DeleteModeLine - Succeeded\n"); | |||
802 | return Success0; | |||
803 | } | |||
804 | } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); | |||
805 | ||||
806 | return BadValue2; | |||
807 | } | |||
808 | ||||
809 | static int | |||
810 | ProcXF86VidModeModModeLine(ClientPtr client) | |||
811 | { | |||
812 | REQUEST(xXF86VidModeModModeLineReq)xXF86VidModeModModeLineReq *stuff = (xXF86VidModeModModeLineReq *)client->requestBuffer; | |||
813 | xXF86OldVidModeModModeLineReq *oldstuff = | |||
814 | (xXF86OldVidModeModModeLineReq *) client->requestBuffer; | |||
815 | xXF86VidModeModModeLineReq newstuff; | |||
816 | void *mode, *modetmp; | |||
817 | int len, dotClock; | |||
818 | int ver; | |||
819 | ||||
820 | DEBUG_P("XF86VidModeModModeline"); | |||
821 | ||||
822 | ver = ClientMajorVersion(client); | |||
823 | if (ver < 2) { | |||
824 | /* convert from old format */ | |||
825 | stuff = &newstuff; | |||
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; | |||
832 | stuff->hskew = 0; | |||
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; | |||
839 | } | |||
840 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
847 | } | |||
848 | ||||
849 | if (ver < 2) { | |||
850 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq)if ((sizeof(xXF86OldVidModeModModeLineReq) >> 2) > client ->req_len ) return(16); | |||
851 | len = | |||
852 | client->req_len - | |||
853 | bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq)); | |||
854 | } | |||
855 | else { | |||
856 | REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq)if ((sizeof(xXF86VidModeModModeLineReq) >> 2) > client ->req_len ) return(16); | |||
857 | len = | |||
858 | client->req_len - | |||
859 | bytes_to_int32(sizeof(xXF86VidModeModModeLineReq)); | |||
860 | } | |||
861 | if (len != stuff->privsize) | |||
862 | return BadLength16; | |||
863 | ||||
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) | |||
869 | return BadValue2; | |||
870 | ||||
871 | if (stuff->screen >= screenInfo.numScreens) | |||
872 | return BadValue2; | |||
873 | ||||
874 | if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) | |||
875 | return BadValue2; | |||
876 | ||||
877 | modetmp = VidModeCreateMode(); | |||
878 | VidModeCopyMode(mode, modetmp); | |||
879 | ||||
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); | |||
890 | ||||
891 | if (stuff->privsize) | |||
892 | ErrorF("ModModeLine - Privates in request have been ignored\n"); | |||
893 | ||||
894 | /* Check that the mode is consistent with the monitor specs */ | |||
895 | switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) { | |||
896 | case MODE_OK: | |||
897 | break; | |||
898 | case MODE_HSYNC: | |||
899 | case MODE_H_ILLEGAL: | |||
900 | free(modetmp); | |||
901 | return VidModeErrorBase + XF86VidModeBadHTimings1; | |||
902 | case MODE_VSYNC: | |||
903 | case MODE_V_ILLEGAL: | |||
904 | free(modetmp); | |||
905 | return VidModeErrorBase + XF86VidModeBadVTimings2; | |||
906 | default: | |||
907 | free(modetmp); | |||
908 | return VidModeErrorBase + XF86VidModeModeUnsuitable3; | |||
909 | } | |||
910 | ||||
911 | /* Check that the driver is happy with the mode */ | |||
912 | if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) { | |||
913 | free(modetmp); | |||
914 | return VidModeErrorBase + XF86VidModeModeUnsuitable3; | |||
915 | } | |||
916 | free(modetmp); | |||
917 | ||||
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); | |||
928 | ||||
929 | VidModeSetCrtcForMode(stuff->screen, mode); | |||
930 | VidModeSwitchMode(stuff->screen, mode); | |||
931 | ||||
932 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) | |||
933 | ErrorF("ModModeLine - Succeeded\n"); | |||
934 | return Success0; | |||
935 | } | |||
936 | ||||
937 | static int | |||
938 | ProcXF86VidModeValidateModeLine(ClientPtr client) | |||
939 | { | |||
940 | REQUEST(xXF86VidModeValidateModeLineReq)xXF86VidModeValidateModeLineReq *stuff = (xXF86VidModeValidateModeLineReq *)client->requestBuffer; | |||
941 | xXF86OldVidModeValidateModeLineReq *oldstuff = | |||
942 | (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer; | |||
943 | xXF86VidModeValidateModeLineReq newstuff; | |||
944 | xXF86VidModeValidateModeLineReply rep; | |||
945 | void *mode, *modetmp = NULL((void*)0); | |||
946 | int len, status, dotClock; | |||
947 | int ver; | |||
948 | ||||
949 | DEBUG_P("XF86VidModeValidateModeline"); | |||
950 | ||||
951 | ver = ClientMajorVersion(client); | |||
952 | if (ver < 2) { | |||
953 | /* convert from old format */ | |||
954 | stuff = &newstuff; | |||
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; | |||
962 | stuff->hskew = 0; | |||
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; | |||
969 | } | |||
970 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
976 | ErrorF | |||
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); | |||
980 | } | |||
981 | ||||
982 | if (ver < 2) { | |||
983 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq)if ((sizeof(xXF86OldVidModeValidateModeLineReq) >> 2) > client->req_len ) return(16); | |||
984 | len = client->req_len - | |||
985 | bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq)); | |||
986 | } | |||
987 | else { | |||
988 | REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq)if ((sizeof(xXF86VidModeValidateModeLineReq) >> 2) > client->req_len ) return(16); | |||
989 | len = | |||
990 | client->req_len - | |||
991 | bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq)); | |||
992 | } | |||
993 | if (len != stuff->privsize) | |||
994 | return BadLength16; | |||
995 | ||||
996 | if (stuff->screen >= screenInfo.numScreens) | |||
997 | return BadValue2; | |||
998 | ||||
999 | status = MODE_OK; | |||
1000 | ||||
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) { | |||
1007 | status = MODE_BAD; | |||
1008 | goto status_reply; | |||
1009 | } | |||
1010 | ||||
1011 | if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) | |||
1012 | return BadValue2; | |||
1013 | ||||
1014 | modetmp = VidModeCreateMode(); | |||
1015 | VidModeCopyMode(mode, modetmp); | |||
1016 | ||||
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"); | |||
1029 | ||||
1030 | /* Check that the mode is consistent with the monitor specs */ | |||
1031 | if ((status = | |||
1032 | VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK) | |||
1033 | goto status_reply; | |||
1034 | ||||
1035 | /* Check that the driver is happy with the mode */ | |||
1036 | status = VidModeCheckModeForDriver(stuff->screen, modetmp); | |||
1037 | ||||
1038 | status_reply: | |||
1039 | free(modetmp); | |||
1040 | ||||
1041 | rep = (xXF86VidModeValidateModeLineReply) { | |||
1042 | .type = X_Reply1, | |||
1043 | .sequenceNumber = client->sequence, | |||
1044 | .length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)32 | |||
1045 | - SIZEOF(xGenericReply)32), | |||
1046 | .status = status | |||
1047 | }; | |||
1048 | if (client->swapped) { | |||
1049 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1050 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1051 | swapl(&rep.status)do { if (sizeof(*(&rep.status)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.status) & 3) && ((uintptr_t )(&rep.status) & 3) == 0) *(&rep.status) = lswapl (*(&rep.status)); else swap_uint32((uint32_t *)(&rep. status)); } while (0); | |||
1052 | } | |||
1053 | WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), &rep); | |||
1054 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) | |||
1055 | ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status); | |||
1056 | return Success0; | |||
1057 | } | |||
1058 | ||||
1059 | static int | |||
1060 | ProcXF86VidModeSwitchMode(ClientPtr client) | |||
1061 | { | |||
1062 | REQUEST(xXF86VidModeSwitchModeReq)xXF86VidModeSwitchModeReq *stuff = (xXF86VidModeSwitchModeReq *)client->requestBuffer; | |||
1063 | ||||
1064 | DEBUG_P("XF86VidModeSwitchMode"); | |||
1065 | ||||
1066 | REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq)if ((sizeof(xXF86VidModeSwitchModeReq) >> 2) != client-> req_len) return(16); | |||
1067 | ||||
1068 | if (stuff->screen >= screenInfo.numScreens) | |||
1069 | return BadValue2; | |||
1070 | ||||
1071 | VidModeZoomViewport(stuff->screen, (short) stuff->zoom); | |||
1072 | ||||
1073 | return Success0; | |||
1074 | } | |||
1075 | ||||
1076 | static int | |||
1077 | ProcXF86VidModeSwitchToMode(ClientPtr client) | |||
1078 | { | |||
1079 | REQUEST(xXF86VidModeSwitchToModeReq)xXF86VidModeSwitchToModeReq *stuff = (xXF86VidModeSwitchToModeReq *)client->requestBuffer; | |||
1080 | xXF86OldVidModeSwitchToModeReq *oldstuff = | |||
1081 | (xXF86OldVidModeSwitchToModeReq *) client->requestBuffer; | |||
1082 | xXF86VidModeSwitchToModeReq newstuff; | |||
1083 | void *mode; | |||
1084 | int len, dotClock; | |||
1085 | int ver; | |||
1086 | ||||
1087 | DEBUG_P("XF86VidModeSwitchToMode"); | |||
1088 | ||||
1089 | ver = ClientMajorVersion(client); | |||
1090 | if (ver < 2) { | |||
1091 | /* convert from old format */ | |||
1092 | stuff = &newstuff; | |||
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; | |||
1100 | stuff->hskew = 0; | |||
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; | |||
1107 | } | |||
1108 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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); | |||
1114 | ErrorF | |||
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); | |||
1118 | } | |||
1119 | ||||
1120 | if (ver < 2) { | |||
1121 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq)if ((sizeof(xXF86OldVidModeSwitchToModeReq) >> 2) > client ->req_len ) return(16); | |||
1122 | len = | |||
1123 | client->req_len - | |||
1124 | bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq)); | |||
1125 | } | |||
1126 | else { | |||
1127 | REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq)if ((sizeof(xXF86VidModeSwitchToModeReq) >> 2) > client ->req_len ) return(16); | |||
1128 | len = | |||
1129 | client->req_len - | |||
1130 | bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq)); | |||
1131 | } | |||
1132 | if (len != stuff->privsize) | |||
1133 | return BadLength16; | |||
1134 | ||||
1135 | if (stuff->screen >= screenInfo.numScreens) | |||
1136 | return BadValue2; | |||
1137 | ||||
1138 | if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) | |||
1139 | return BadValue2; | |||
1140 | ||||
1141 | if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) | |||
1142 | && MODEMATCH(mode, stuff)(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND ) == stuff->hsyncend && VidModeGetModeValue(mode, VIDMODE_H_TOTAL ) == stuff->htotal && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY ) == stuff->vdisplay && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART ) == stuff->vsyncstart && VidModeGetModeValue(mode , VIDMODE_V_SYNCEND) == stuff->vsyncend && VidModeGetModeValue (mode, VIDMODE_V_TOTAL) == stuff->vtotal && VidModeGetModeValue (mode, VIDMODE_FLAGS) == stuff->flags )) | |||
1143 | return Success0; | |||
1144 | ||||
1145 | if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) | |||
1146 | return BadValue2; | |||
1147 | ||||
1148 | do { | |||
1149 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) { | |||
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)); | |||
1157 | ErrorF | |||
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)); | |||
1164 | } | |||
1165 | if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) && | |||
1166 | MODEMATCH(mode, stuff)(VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND ) == stuff->hsyncend && VidModeGetModeValue(mode, VIDMODE_H_TOTAL ) == stuff->htotal && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY ) == stuff->vdisplay && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART ) == stuff->vsyncstart && VidModeGetModeValue(mode , VIDMODE_V_SYNCEND) == stuff->vsyncend && VidModeGetModeValue (mode, VIDMODE_V_TOTAL) == stuff->vtotal && VidModeGetModeValue (mode, VIDMODE_FLAGS) == stuff->flags )) { | |||
1167 | ||||
1168 | if (!VidModeSwitchMode(stuff->screen, mode)) | |||
1169 | return BadValue2; | |||
1170 | ||||
1171 | if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY3) | |||
1172 | ErrorF("SwitchToMode - Succeeded\n"); | |||
1173 | return Success0; | |||
1174 | } | |||
1175 | } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); | |||
1176 | ||||
1177 | return BadValue2; | |||
1178 | } | |||
1179 | ||||
1180 | static int | |||
1181 | ProcXF86VidModeLockModeSwitch(ClientPtr client) | |||
1182 | { | |||
1183 | REQUEST(xXF86VidModeLockModeSwitchReq)xXF86VidModeLockModeSwitchReq *stuff = (xXF86VidModeLockModeSwitchReq *)client->requestBuffer; | |||
1184 | ||||
1185 | REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq)if ((sizeof(xXF86VidModeLockModeSwitchReq) >> 2) != client ->req_len) return(16); | |||
1186 | ||||
1187 | DEBUG_P("XF86VidModeLockModeSwitch"); | |||
1188 | ||||
1189 | if (stuff->screen >= screenInfo.numScreens) | |||
1190 | return BadValue2; | |||
1191 | ||||
1192 | if (!VidModeLockZoom(stuff->screen, (short) stuff->lock)) | |||
1193 | return VidModeErrorBase + XF86VidModeZoomLocked6; | |||
1194 | ||||
1195 | return Success0; | |||
1196 | } | |||
1197 | ||||
1198 | static int | |||
1199 | ProcXF86VidModeGetMonitor(ClientPtr client) | |||
1200 | { | |||
1201 | REQUEST(xXF86VidModeGetMonitorReq)xXF86VidModeGetMonitorReq *stuff = (xXF86VidModeGetMonitorReq *)client->requestBuffer; | |||
1202 | xXF86VidModeGetMonitorReply rep = { | |||
1203 | .type = X_Reply1, | |||
1204 | .sequenceNumber = client->sequence | |||
1205 | }; | |||
1206 | CARD32 *hsyncdata, *vsyncdata; | |||
1207 | int i, nHsync, nVrefresh; | |||
1208 | void *monitor; | |||
1209 | ||||
1210 | DEBUG_P("XF86VidModeGetMonitor"); | |||
1211 | ||||
1212 | REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq)if ((sizeof(xXF86VidModeGetMonitorReq) >> 2) != client-> req_len) return(16); | |||
1213 | ||||
1214 | if (stuff->screen >= screenInfo.numScreens) | |||
1215 | return BadValue2; | |||
1216 | ||||
1217 | if (!VidModeGetMonitor(stuff->screen, &monitor)) | |||
1218 | return BadValue2; | |||
1219 | ||||
1220 | nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i; | |||
1221 | nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i; | |||
1222 | ||||
1223 | if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr) | |||
1224 | rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor, | |||
1225 | VIDMODE_MON_VENDOR, | |||
1226 | 0)).ptr); | |||
1227 | else | |||
1228 | rep.vendorLength = 0; | |||
1229 | if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr) | |||
1230 | rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor, | |||
1231 | VIDMODE_MON_MODEL, | |||
1232 | 0)).ptr); | |||
1233 | else | |||
1234 | rep.modelLength = 0; | |||
1235 | rep.length = | |||
1236 | bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply)32 - | |||
1237 | SIZEOF(xGenericReply)32 + (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)); | |||
1244 | if (!hsyncdata) { | |||
1245 | return BadAlloc11; | |||
1246 | } | |||
1247 | vsyncdata = malloc(nVrefresh * sizeof(CARD32)); | |||
1248 | ||||
1249 | if (!vsyncdata) { | |||
1250 | free(hsyncdata); | |||
1251 | return BadAlloc11; | |||
1252 | } | |||
1253 | ||||
1254 | for (i = 0; i < nHsync; i++) { | |||
1255 | hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor, | |||
1256 | VIDMODE_MON_HSYNC_LO, | |||
1257 | i)).f | | |||
1258 | (unsigned | |||
1259 | short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI, | |||
1260 | i)).f << 16; | |||
1261 | } | |||
1262 | for (i = 0; i < nVrefresh; i++) { | |||
1263 | vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor, | |||
1264 | VIDMODE_MON_VREFRESH_LO, | |||
1265 | i)).f | | |||
1266 | (unsigned | |||
1267 | short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VREFRESH_HI, | |||
1268 | i)).f << 16; | |||
1269 | } | |||
1270 | ||||
1271 | if (client->swapped) { | |||
1272 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1273 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1274 | } | |||
1275 | WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply)32, &rep); | |||
1276 | client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; | |||
1277 | WriteSwappedDataToClient(client, nHsync * sizeof(CARD32), hsyncdata)if ((client)->swapped) (*(client)->pSwapReplyFunc)(client , (int)(nHsync * sizeof(CARD32)), hsyncdata); else WriteToClient (client, (int)(nHsync * sizeof(CARD32)), (hsyncdata));; | |||
1278 | WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), vsyncdata)if ((client)->swapped) (*(client)->pSwapReplyFunc)(client , (int)(nVrefresh * sizeof(CARD32)), vsyncdata); else WriteToClient (client, (int)(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); | |||
1285 | ||||
1286 | free(hsyncdata); | |||
1287 | free(vsyncdata); | |||
1288 | ||||
1289 | return Success0; | |||
1290 | } | |||
1291 | ||||
1292 | static int | |||
1293 | ProcXF86VidModeGetViewPort(ClientPtr client) | |||
1294 | { | |||
1295 | REQUEST(xXF86VidModeGetViewPortReq)xXF86VidModeGetViewPortReq *stuff = (xXF86VidModeGetViewPortReq *)client->requestBuffer; | |||
1296 | xXF86VidModeGetViewPortReply rep; | |||
1297 | int x, y; | |||
1298 | ||||
1299 | DEBUG_P("XF86VidModeGetViewPort"); | |||
1300 | ||||
1301 | REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq)if ((sizeof(xXF86VidModeGetViewPortReq) >> 2) != client ->req_len) return(16); | |||
1302 | ||||
1303 | if (stuff->screen >= screenInfo.numScreens) | |||
1304 | return BadValue2; | |||
1305 | ||||
1306 | VidModeGetViewPort(stuff->screen, &x, &y); | |||
1307 | ||||
1308 | rep = (xXF86VidModeGetViewPortReply) { | |||
1309 | .type = X_Reply1, | |||
1310 | .sequenceNumber = client->sequence, | |||
1311 | .length = 0, | |||
1312 | .x = x, | |||
1313 | .y = y | |||
1314 | }; | |||
1315 | ||||
1316 | if (client->swapped) { | |||
1317 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1318 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1319 | swapl(&rep.x)do { if (sizeof(*(&rep.x)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.x) & 3) && ((uintptr_t)(& rep.x) & 3) == 0) *(&rep.x) = lswapl(*(&rep.x)); else swap_uint32((uint32_t *)(&rep.x)); } while (0); | |||
1320 | swapl(&rep.y)do { if (sizeof(*(&rep.y)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.y) & 3) && ((uintptr_t)(& rep.y) & 3) == 0) *(&rep.y) = lswapl(*(&rep.y)); else swap_uint32((uint32_t *)(&rep.y)); } while (0); | |||
1321 | } | |||
1322 | WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply)32, &rep); | |||
1323 | return Success0; | |||
1324 | } | |||
1325 | ||||
1326 | static int | |||
1327 | ProcXF86VidModeSetViewPort(ClientPtr client) | |||
1328 | { | |||
1329 | REQUEST(xXF86VidModeSetViewPortReq)xXF86VidModeSetViewPortReq *stuff = (xXF86VidModeSetViewPortReq *)client->requestBuffer; | |||
1330 | ||||
1331 | DEBUG_P("XF86VidModeSetViewPort"); | |||
1332 | ||||
1333 | REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq)if ((sizeof(xXF86VidModeSetViewPortReq) >> 2) != client ->req_len) return(16); | |||
1334 | ||||
1335 | if (stuff->screen >= screenInfo.numScreens) | |||
1336 | return BadValue2; | |||
1337 | ||||
1338 | if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y)) | |||
1339 | return BadValue2; | |||
1340 | ||||
1341 | return Success0; | |||
1342 | } | |||
1343 | ||||
1344 | static int | |||
1345 | ProcXF86VidModeGetDotClocks(ClientPtr client) | |||
1346 | { | |||
1347 | REQUEST(xXF86VidModeGetDotClocksReq)xXF86VidModeGetDotClocksReq *stuff = (xXF86VidModeGetDotClocksReq *)client->requestBuffer; | |||
1348 | xXF86VidModeGetDotClocksReply rep; | |||
1349 | int n; | |||
1350 | int numClocks; | |||
1351 | CARD32 dotclock; | |||
1352 | int *Clocks = NULL((void*)0); | |||
1353 | Bool ClockProg; | |||
1354 | ||||
1355 | DEBUG_P("XF86VidModeGetDotClocks"); | |||
1356 | ||||
1357 | REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq)if ((sizeof(xXF86VidModeGetDotClocksReq) >> 2) != client ->req_len) return(16); | |||
1358 | ||||
1359 | if (stuff->screen >= screenInfo.numScreens) | |||
1360 | return BadValue2; | |||
1361 | ||||
1362 | numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg); | |||
1363 | ||||
1364 | rep = (xXF86VidModeGetDotClocksReply) { | |||
1365 | .type = X_Reply1, | |||
1366 | .sequenceNumber = client->sequence, | |||
1367 | .length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)32 | |||
1368 | - SIZEOF(xGenericReply)32 + numClocks), | |||
1369 | .clocks = numClocks, | |||
1370 | .maxclocks = MAXCLOCKS128, | |||
1371 | .flags = 0 | |||
1372 | }; | |||
1373 | ||||
1374 | if (!ClockProg) { | |||
1375 | Clocks = calloc(numClocks, sizeof(int)); | |||
1376 | if (!Clocks) | |||
1377 | return BadValue2; | |||
1378 | if (!VidModeGetClocks(stuff->screen, Clocks)) { | |||
1379 | free(Clocks); | |||
1380 | return BadValue2; | |||
1381 | } | |||
1382 | } | |||
1383 | if (ClockProg) { | |||
1384 | rep.flags |= CLKFLAG_PROGRAMABLE1; | |||
1385 | } | |||
1386 | if (client->swapped) { | |||
1387 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1388 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1389 | swapl(&rep.clocks)do { if (sizeof(*(&rep.clocks)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.clocks) & 3) && ((uintptr_t )(&rep.clocks) & 3) == 0) *(&rep.clocks) = lswapl (*(&rep.clocks)); else swap_uint32((uint32_t *)(&rep. clocks)); } while (0); | |||
1390 | swapl(&rep.maxclocks)do { if (sizeof(*(&rep.maxclocks)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.maxclocks) & 3 ) && ((uintptr_t)(&rep.maxclocks) & 3) == 0) * (&rep.maxclocks) = lswapl(*(&rep.maxclocks)); else swap_uint32 ((uint32_t *)(&rep.maxclocks)); } while (0); | |||
1391 | swapl(&rep.flags)do { if (sizeof(*(&rep.flags)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.flags) & 3) && ((uintptr_t) (&rep.flags) & 3) == 0) *(&rep.flags) = lswapl(*( &rep.flags)); else swap_uint32((uint32_t *)(&rep.flags )); } while (0); | |||
1392 | } | |||
1393 | WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep); | |||
1394 | if (!ClockProg) { | |||
1395 | for (n = 0; n < numClocks; n++) { | |||
1396 | dotclock = *Clocks++; | |||
1397 | if (client->swapped) { | |||
1398 | WriteSwappedDataToClient(client, 4, (char *) &dotclock)if ((client)->swapped) (*(client)->pSwapReplyFunc)(client , (int)(4), (char *) &dotclock); else WriteToClient(client , (int)(4), ((char *) &dotclock));; | |||
1399 | } | |||
1400 | else { | |||
1401 | WriteToClient(client, 4, &dotclock); | |||
1402 | } | |||
1403 | } | |||
1404 | } | |||
1405 | ||||
1406 | free(Clocks); | |||
1407 | return Success0; | |||
1408 | } | |||
1409 | ||||
1410 | static int | |||
1411 | ProcXF86VidModeSetGamma(ClientPtr client) | |||
1412 | { | |||
1413 | REQUEST(xXF86VidModeSetGammaReq)xXF86VidModeSetGammaReq *stuff = (xXF86VidModeSetGammaReq *)client ->requestBuffer; | |||
1414 | ||||
1415 | DEBUG_P("XF86VidModeSetGamma"); | |||
1416 | ||||
1417 | REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq)if ((sizeof(xXF86VidModeSetGammaReq) >> 2) != client-> req_len) return(16); | |||
1418 | ||||
1419 | if (stuff->screen >= screenInfo.numScreens) | |||
1420 | return BadValue2; | |||
1421 | ||||
1422 | if (!VidModeSetGamma(stuff->screen, ((float) stuff->red) / 10000., | |||
1423 | ((float) stuff->green) / 10000., | |||
1424 | ((float) stuff->blue) / 10000.)) | |||
1425 | return BadValue2; | |||
1426 | ||||
1427 | return Success0; | |||
1428 | } | |||
1429 | ||||
1430 | static int | |||
1431 | ProcXF86VidModeGetGamma(ClientPtr client) | |||
1432 | { | |||
1433 | REQUEST(xXF86VidModeGetGammaReq)xXF86VidModeGetGammaReq *stuff = (xXF86VidModeGetGammaReq *)client ->requestBuffer; | |||
1434 | xXF86VidModeGetGammaReply rep; | |||
1435 | float red, green, blue; | |||
1436 | ||||
1437 | DEBUG_P("XF86VidModeGetGamma"); | |||
1438 | ||||
1439 | REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq)if ((sizeof(xXF86VidModeGetGammaReq) >> 2) != client-> req_len) return(16); | |||
1440 | ||||
1441 | if (stuff->screen >= screenInfo.numScreens) | |||
1442 | return BadValue2; | |||
1443 | ||||
1444 | if (!VidModeGetGamma(stuff->screen, &red, &green, &blue)) | |||
1445 | return BadValue2; | |||
1446 | rep = (xXF86VidModeGetGammaReply) { | |||
1447 | .type = X_Reply1, | |||
1448 | .sequenceNumber = client->sequence, | |||
1449 | .length = 0, | |||
1450 | .red = (CARD32) (red * 10000.), | |||
1451 | .green = (CARD32) (green * 10000.), | |||
1452 | .blue = (CARD32) (blue * 10000.) | |||
1453 | }; | |||
1454 | if (client->swapped) { | |||
1455 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1456 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1457 | swapl(&rep.red)do { if (sizeof(*(&rep.red)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.red) & 3) && ((uintptr_t)(& rep.red) & 3) == 0) *(&rep.red) = lswapl(*(&rep.red )); else swap_uint32((uint32_t *)(&rep.red)); } while (0); | |||
1458 | swapl(&rep.green)do { if (sizeof(*(&rep.green)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.green) & 3) && ((uintptr_t) (&rep.green) & 3) == 0) *(&rep.green) = lswapl(*( &rep.green)); else swap_uint32((uint32_t *)(&rep.green )); } while (0); | |||
1459 | swapl(&rep.blue)do { if (sizeof(*(&rep.blue)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.blue) & 3) && ((uintptr_t)( &rep.blue) & 3) == 0) *(&rep.blue) = lswapl(*(& rep.blue)); else swap_uint32((uint32_t *)(&rep.blue)); } while (0); | |||
1460 | } | |||
1461 | WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), &rep); | |||
1462 | ||||
1463 | return Success0; | |||
1464 | } | |||
1465 | ||||
1466 | static int | |||
1467 | ProcXF86VidModeSetGammaRamp(ClientPtr client) | |||
1468 | { | |||
1469 | CARD16 *r, *g, *b; | |||
1470 | int length; | |||
1471 | ||||
1472 | REQUEST(xXF86VidModeSetGammaRampReq)xXF86VidModeSetGammaRampReq *stuff = (xXF86VidModeSetGammaRampReq *)client->requestBuffer; | |||
1473 | ||||
1474 | if (stuff->screen >= screenInfo.numScreens) | |||
1475 | return BadValue2; | |||
1476 | ||||
1477 | if (stuff->size != VidModeGetGammaRampSize(stuff->screen)) | |||
1478 | return BadValue2; | |||
1479 | ||||
1480 | length = (stuff->size + 1) & ~1; | |||
1481 | ||||
1482 | REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6)if (((sizeof(xXF86VidModeSetGammaRampReq) >> 2) > client ->req_len) || (((length * 6) >> 2) >= client-> req_len) || ((((uint64_t) sizeof(xXF86VidModeSetGammaRampReq) + (length * 6) + 3) >> 2) != (uint64_t) client->req_len )) return(16); | |||
1483 | ||||
1484 | r = (CARD16 *) &stuff[1]; | |||
1485 | g = r + length; | |||
1486 | b = g + length; | |||
1487 | ||||
1488 | if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b)) | |||
1489 | return BadValue2; | |||
1490 | ||||
1491 | return Success0; | |||
1492 | } | |||
1493 | ||||
1494 | static int | |||
1495 | ProcXF86VidModeGetGammaRamp(ClientPtr client) | |||
1496 | { | |||
1497 | CARD16 *ramp = NULL((void*)0); | |||
1498 | int length; | |||
1499 | size_t ramplen = 0; | |||
1500 | xXF86VidModeGetGammaRampReply rep; | |||
1501 | ||||
1502 | REQUEST(xXF86VidModeGetGammaRampReq)xXF86VidModeGetGammaRampReq *stuff = (xXF86VidModeGetGammaRampReq *)client->requestBuffer; | |||
1503 | ||||
1504 | REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq)if ((sizeof(xXF86VidModeGetGammaRampReq) >> 2) != client ->req_len) return(16); | |||
1505 | ||||
1506 | if (stuff->screen >= screenInfo.numScreens) | |||
1507 | return BadValue2; | |||
1508 | ||||
1509 | if (stuff->size != VidModeGetGammaRampSize(stuff->screen)) | |||
1510 | return BadValue2; | |||
1511 | ||||
1512 | length = (stuff->size + 1) & ~1; | |||
1513 | ||||
1514 | if (stuff->size) { | |||
1515 | ramplen = length * 3 * sizeof(CARD16); | |||
1516 | if (!(ramp = malloc(ramplen))) | |||
1517 | return BadAlloc11; | |||
1518 | ||||
1519 | if (!VidModeGetGammaRamp(stuff->screen, stuff->size, | |||
1520 | ramp, ramp + length, ramp + (length * 2))) { | |||
1521 | free(ramp); | |||
1522 | return BadValue2; | |||
1523 | } | |||
1524 | } | |||
1525 | rep = (xXF86VidModeGetGammaRampReply) { | |||
1526 | .type = X_Reply1, | |||
1527 | .sequenceNumber = client->sequence, | |||
1528 | .length = (length >> 1) * 3, | |||
1529 | .size = stuff->size | |||
1530 | }; | |||
1531 | if (client->swapped) { | |||
1532 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1533 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1534 | swaps(&rep.size)do { if (sizeof(*(&rep.size)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.size) & 1) && ((uintptr_t)( &rep.size) & 1) == 0) *(&rep.size) = lswaps(*(& rep.size)); else swap_uint16((uint16_t *)(&rep.size)); } while (0); | |||
1535 | SwapShorts((short *) ramp, length * 3); | |||
1536 | } | |||
1537 | WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), &rep); | |||
1538 | ||||
1539 | if (stuff->size) { | |||
1540 | WriteToClient(client, ramplen, ramp); | |||
1541 | free(ramp); | |||
1542 | } | |||
1543 | ||||
1544 | return Success0; | |||
1545 | } | |||
1546 | ||||
1547 | static int | |||
1548 | ProcXF86VidModeGetGammaRampSize(ClientPtr client) | |||
1549 | { | |||
1550 | xXF86VidModeGetGammaRampSizeReply rep; | |||
1551 | ||||
1552 | REQUEST(xXF86VidModeGetGammaRampSizeReq)xXF86VidModeGetGammaRampSizeReq *stuff = (xXF86VidModeGetGammaRampSizeReq *)client->requestBuffer; | |||
1553 | ||||
1554 | REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq)if ((sizeof(xXF86VidModeGetGammaRampSizeReq) >> 2) != client ->req_len) return(16); | |||
1555 | ||||
1556 | if (stuff->screen >= screenInfo.numScreens) | |||
1557 | return BadValue2; | |||
1558 | ||||
1559 | rep = (xXF86VidModeGetGammaRampSizeReply) { | |||
1560 | .type = X_Reply1, | |||
1561 | .sequenceNumber = client->sequence, | |||
1562 | .length = 0, | |||
1563 | .size = VidModeGetGammaRampSize(stuff->screen) | |||
1564 | }; | |||
1565 | if (client->swapped) { | |||
1566 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1567 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1568 | swaps(&rep.size)do { if (sizeof(*(&rep.size)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.size) & 1) && ((uintptr_t)( &rep.size) & 1) == 0) *(&rep.size) = lswaps(*(& rep.size)); else swap_uint16((uint16_t *)(&rep.size)); } while (0); | |||
1569 | } | |||
1570 | WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply), &rep); | |||
1571 | ||||
1572 | return Success0; | |||
1573 | } | |||
1574 | ||||
1575 | static int | |||
1576 | ProcXF86VidModeGetPermissions(ClientPtr client) | |||
1577 | { | |||
1578 | xXF86VidModeGetPermissionsReply rep = { | |||
1579 | .type = X_Reply1, | |||
1580 | .sequenceNumber = client->sequence, | |||
1581 | .length = 0, | |||
1582 | .permissions = XF86VM_READ_PERMISSION1 | |||
1583 | }; | |||
1584 | ||||
1585 | REQUEST(xXF86VidModeGetPermissionsReq)xXF86VidModeGetPermissionsReq *stuff = (xXF86VidModeGetPermissionsReq *)client->requestBuffer; | |||
1586 | ||||
1587 | REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq)if ((sizeof(xXF86VidModeGetPermissionsReq) >> 2) != client ->req_len) return(16); | |||
1588 | ||||
1589 | if (stuff->screen >= screenInfo.numScreens) | |||
1590 | return BadValue2; | |||
1591 | ||||
1592 | if (xf86GetVidModeEnabled() && | |||
1593 | (xf86GetVidModeAllowNonLocal() || client->local)) { | |||
1594 | rep.permissions |= XF86VM_WRITE_PERMISSION2; | |||
1595 | } | |||
1596 | if (client->swapped) { | |||
1597 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); | |||
1598 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); | |||
1599 | swapl(&rep.permissions)do { if (sizeof(*(&rep.permissions)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.permissions) & 3) && ((uintptr_t)(&rep.permissions) & 3) == 0) *(&rep.permissions) = lswapl(*(&rep.permissions)) ; else swap_uint32((uint32_t *)(&rep.permissions)); } while (0); | |||
1600 | } | |||
1601 | WriteToClient(client, sizeof(xXF86VidModeGetPermissionsReply), &rep); | |||
1602 | ||||
1603 | return Success0; | |||
1604 | } | |||
1605 | ||||
1606 | static int | |||
1607 | ProcXF86VidModeSetClientVersion(ClientPtr client) | |||
1608 | { | |||
1609 | REQUEST(xXF86VidModeSetClientVersionReq)xXF86VidModeSetClientVersionReq *stuff = (xXF86VidModeSetClientVersionReq *)client->requestBuffer; | |||
1610 | ||||
1611 | VidModePrivPtr pPriv; | |||
1612 | ||||
1613 | DEBUG_P("XF86VidModeSetClientVersion"); | |||
1614 | ||||
1615 | REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq)if ((sizeof(xXF86VidModeSetClientVersionReq) >> 2) != client ->req_len) return(16); | |||
1616 | ||||
1617 | if ((pPriv = VM_GETPRIV(client)((VidModePrivPtr) dixLookupPrivate(&(client)->devPrivates , (&VidModeClientPrivateKeyRec)))) == NULL((void*)0)) { | |||
1618 | pPriv = malloc(sizeof(VidModePrivRec)); | |||
1619 | if (!pPriv) | |||
1620 | return BadAlloc11; | |||
1621 | VM_SETPRIV(client, pPriv)dixSetPrivate(&(client)->devPrivates, (&VidModeClientPrivateKeyRec ), pPriv); | |||
1622 | } | |||
1623 | pPriv->major = stuff->major; | |||
1624 | ||||
1625 | pPriv->minor = stuff->minor; | |||
1626 | ||||
1627 | return Success0; | |||
| ||||
1628 | } | |||
1629 | ||||
1630 | static int | |||
1631 | ProcXF86VidModeDispatch(ClientPtr client) | |||
1632 | { | |||
1633 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; | |||
1634 | switch (stuff->data) { | |||
| ||||
1635 | case X_XF86VidModeQueryVersion0: | |||
1636 | return ProcXF86VidModeQueryVersion(client); | |||
1637 | case X_XF86VidModeGetModeLine1: | |||
1638 | return ProcXF86VidModeGetModeLine(client); | |||
1639 | case X_XF86VidModeGetMonitor4: | |||
1640 | return ProcXF86VidModeGetMonitor(client); | |||
1641 | case X_XF86VidModeGetAllModeLines6: | |||
1642 | return ProcXF86VidModeGetAllModeLines(client); | |||
1643 | case X_XF86VidModeValidateModeLine9: | |||
1644 | return ProcXF86VidModeValidateModeLine(client); | |||
1645 | case X_XF86VidModeGetViewPort11: | |||
1646 | return ProcXF86VidModeGetViewPort(client); | |||
1647 | case X_XF86VidModeGetDotClocks13: | |||
1648 | return ProcXF86VidModeGetDotClocks(client); | |||
1649 | case X_XF86VidModeSetClientVersion14: | |||
1650 | return ProcXF86VidModeSetClientVersion(client); | |||
1651 | case X_XF86VidModeGetGamma16: | |||
1652 | return ProcXF86VidModeGetGamma(client); | |||
1653 | case X_XF86VidModeGetGammaRamp17: | |||
1654 | return ProcXF86VidModeGetGammaRamp(client); | |||
1655 | case X_XF86VidModeGetGammaRampSize19: | |||
1656 | return ProcXF86VidModeGetGammaRampSize(client); | |||
1657 | case X_XF86VidModeGetPermissions20: | |||
1658 | return ProcXF86VidModeGetPermissions(client); | |||
1659 | default: | |||
1660 | if (!xf86GetVidModeEnabled()) | |||
1661 | return VidModeErrorBase + XF86VidModeExtensionDisabled4; | |||
1662 | if (xf86GetVidModeAllowNonLocal() || client->local) { | |||
1663 | switch (stuff->data) { | |||
1664 | case X_XF86VidModeAddModeLine7: | |||
1665 | return ProcXF86VidModeAddModeLine(client); | |||
1666 | case X_XF86VidModeDeleteModeLine8: | |||
1667 | return ProcXF86VidModeDeleteModeLine(client); | |||
1668 | case X_XF86VidModeModModeLine2: | |||
1669 | return ProcXF86VidModeModModeLine(client); | |||
1670 | case X_XF86VidModeSwitchMode3: | |||
1671 | return ProcXF86VidModeSwitchMode(client); | |||
1672 | case X_XF86VidModeSwitchToMode10: | |||
1673 | return ProcXF86VidModeSwitchToMode(client); | |||
1674 | case X_XF86VidModeLockModeSwitch5: | |||
1675 | return ProcXF86VidModeLockModeSwitch(client); | |||
1676 | case X_XF86VidModeSetViewPort12: | |||
1677 | return ProcXF86VidModeSetViewPort(client); | |||
1678 | case X_XF86VidModeSetGamma15: | |||
1679 | return ProcXF86VidModeSetGamma(client); | |||
1680 | case X_XF86VidModeSetGammaRamp18: | |||
1681 | return ProcXF86VidModeSetGammaRamp(client); | |||
1682 | default: | |||
1683 | return BadRequest1; | |||
1684 | } | |||
1685 | } | |||
1686 | else | |||
1687 | return VidModeErrorBase + XF86VidModeClientNotLocal5; | |||
1688 | } | |||
1689 | } | |||
1690 | ||||
1691 | static int | |||
1692 | SProcXF86VidModeQueryVersion(ClientPtr client) | |||
1693 | { | |||
1694 | REQUEST(xXF86VidModeQueryVersionReq)xXF86VidModeQueryVersionReq *stuff = (xXF86VidModeQueryVersionReq *)client->requestBuffer; | |||
1695 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1696 | return ProcXF86VidModeQueryVersion(client); | |||
1697 | } | |||
1698 | ||||
1699 | static int | |||
1700 | SProcXF86VidModeGetModeLine(ClientPtr client) | |||
1701 | { | |||
1702 | REQUEST(xXF86VidModeGetModeLineReq)xXF86VidModeGetModeLineReq *stuff = (xXF86VidModeGetModeLineReq *)client->requestBuffer; | |||
1703 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1704 | REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq)if ((sizeof(xXF86VidModeGetModeLineReq) >> 2) != client ->req_len) return(16); | |||
1705 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1706 | return ProcXF86VidModeGetModeLine(client); | |||
1707 | } | |||
1708 | ||||
1709 | static int | |||
1710 | SProcXF86VidModeGetAllModeLines(ClientPtr client) | |||
1711 | { | |||
1712 | REQUEST(xXF86VidModeGetAllModeLinesReq)xXF86VidModeGetAllModeLinesReq *stuff = (xXF86VidModeGetAllModeLinesReq *)client->requestBuffer; | |||
1713 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1714 | REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq)if ((sizeof(xXF86VidModeGetAllModeLinesReq) >> 2) != client ->req_len) return(16); | |||
1715 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1716 | return ProcXF86VidModeGetAllModeLines(client); | |||
1717 | } | |||
1718 | ||||
1719 | static int | |||
1720 | SProcXF86VidModeAddModeLine(ClientPtr client) | |||
1721 | { | |||
1722 | xXF86OldVidModeAddModeLineReq *oldstuff = | |||
1723 | (xXF86OldVidModeAddModeLineReq *) client->requestBuffer; | |||
1724 | int ver; | |||
1725 | ||||
1726 | REQUEST(xXF86VidModeAddModeLineReq)xXF86VidModeAddModeLineReq *stuff = (xXF86VidModeAddModeLineReq *)client->requestBuffer; | |||
1727 | ver = ClientMajorVersion(client); | |||
1728 | if (ver < 2) { | |||
1729 | swaps(&oldstuff->length)do { if (sizeof(*(&oldstuff->length)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->length ) & 1) && ((uintptr_t)(&oldstuff->length) & 1) == 0) *(&oldstuff->length) = lswaps(*(&oldstuff ->length)); else swap_uint16((uint16_t *)(&oldstuff-> length)); } while (0); | |||
1730 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq)if ((sizeof(xXF86OldVidModeAddModeLineReq) >> 2) > client ->req_len ) return(16); | |||
1731 | swapl(&oldstuff->screen)do { if (sizeof(*(&oldstuff->screen)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->screen ) & 3) && ((uintptr_t)(&oldstuff->screen) & 3) == 0) *(&oldstuff->screen) = lswapl(*(&oldstuff ->screen)); else swap_uint32((uint32_t *)(&oldstuff-> screen)); } while (0); | |||
1732 | swaps(&oldstuff->hdisplay)do { if (sizeof(*(&oldstuff->hdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hdisplay ) & 1) && ((uintptr_t)(&oldstuff->hdisplay ) & 1) == 0) *(&oldstuff->hdisplay) = lswaps(*(& oldstuff->hdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->hdisplay)); } while (0); | |||
1733 | swaps(&oldstuff->hsyncstart)do { if (sizeof(*(&oldstuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncstart ) & 1) && ((uintptr_t)(&oldstuff->hsyncstart ) & 1) == 0) *(&oldstuff->hsyncstart) = lswaps(*(& oldstuff->hsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->hsyncstart)); } while (0); | |||
1734 | swaps(&oldstuff->hsyncend)do { if (sizeof(*(&oldstuff->hsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncend ) & 1) && ((uintptr_t)(&oldstuff->hsyncend ) & 1) == 0) *(&oldstuff->hsyncend) = lswaps(*(& oldstuff->hsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->hsyncend)); } while (0); | |||
1735 | swaps(&oldstuff->htotal)do { if (sizeof(*(&oldstuff->htotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->htotal ) & 1) && ((uintptr_t)(&oldstuff->htotal) & 1) == 0) *(&oldstuff->htotal) = lswaps(*(&oldstuff ->htotal)); else swap_uint16((uint16_t *)(&oldstuff-> htotal)); } while (0); | |||
1736 | swaps(&oldstuff->vdisplay)do { if (sizeof(*(&oldstuff->vdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vdisplay ) & 1) && ((uintptr_t)(&oldstuff->vdisplay ) & 1) == 0) *(&oldstuff->vdisplay) = lswaps(*(& oldstuff->vdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->vdisplay)); } while (0); | |||
1737 | swaps(&oldstuff->vsyncstart)do { if (sizeof(*(&oldstuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncstart ) & 1) && ((uintptr_t)(&oldstuff->vsyncstart ) & 1) == 0) *(&oldstuff->vsyncstart) = lswaps(*(& oldstuff->vsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->vsyncstart)); } while (0); | |||
1738 | swaps(&oldstuff->vsyncend)do { if (sizeof(*(&oldstuff->vsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncend ) & 1) && ((uintptr_t)(&oldstuff->vsyncend ) & 1) == 0) *(&oldstuff->vsyncend) = lswaps(*(& oldstuff->vsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->vsyncend)); } while (0); | |||
1739 | swaps(&oldstuff->vtotal)do { if (sizeof(*(&oldstuff->vtotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vtotal ) & 1) && ((uintptr_t)(&oldstuff->vtotal) & 1) == 0) *(&oldstuff->vtotal) = lswaps(*(&oldstuff ->vtotal)); else swap_uint16((uint16_t *)(&oldstuff-> vtotal)); } while (0); | |||
1740 | swapl(&oldstuff->flags)do { if (sizeof(*(&oldstuff->flags)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&oldstuff->flags ) & 3) && ((uintptr_t)(&oldstuff->flags) & 3) == 0) *(&oldstuff->flags) = lswapl(*(&oldstuff ->flags)); else swap_uint32((uint32_t *)(&oldstuff-> flags)); } while (0); | |||
1741 | swapl(&oldstuff->privsize)do { if (sizeof(*(&oldstuff->privsize)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->privsize ) & 3) && ((uintptr_t)(&oldstuff->privsize ) & 3) == 0) *(&oldstuff->privsize) = lswapl(*(& oldstuff->privsize)); else swap_uint32((uint32_t *)(&oldstuff ->privsize)); } while (0); | |||
1742 | SwapRestL(oldstuff)SwapLongs((CARD32 *)(oldstuff + 1), (client->req_len - (sizeof (*oldstuff) >> 2))); | |||
1743 | } | |||
1744 | else { | |||
1745 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1746 | REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq)if ((sizeof(xXF86VidModeAddModeLineReq) >> 2) > client ->req_len ) return(16); | |||
1747 | swapl(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 3) && ((uintptr_t)(&stuff->screen) & 3) == 0) *(&stuff->screen) = lswapl(*(&stuff->screen )); else swap_uint32((uint32_t *)(&stuff->screen)); } while (0); | |||
1748 | swaps(&stuff->hdisplay)do { if (sizeof(*(&stuff->hdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hdisplay ) & 1) && ((uintptr_t)(&stuff->hdisplay) & 1) == 0) *(&stuff->hdisplay) = lswaps(*(&stuff-> hdisplay)); else swap_uint16((uint16_t *)(&stuff->hdisplay )); } while (0); | |||
1749 | swaps(&stuff->hsyncstart)do { if (sizeof(*(&stuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncstart ) & 1) && ((uintptr_t)(&stuff->hsyncstart) & 1) == 0) *(&stuff->hsyncstart) = lswaps(*(& stuff->hsyncstart)); else swap_uint16((uint16_t *)(&stuff ->hsyncstart)); } while (0); | |||
1750 | swaps(&stuff->hsyncend)do { if (sizeof(*(&stuff->hsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncend ) & 1) && ((uintptr_t)(&stuff->hsyncend) & 1) == 0) *(&stuff->hsyncend) = lswaps(*(&stuff-> hsyncend)); else swap_uint16((uint16_t *)(&stuff->hsyncend )); } while (0); | |||
1751 | swaps(&stuff->htotal)do { if (sizeof(*(&stuff->htotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->htotal) & 1) && ((uintptr_t)(&stuff->htotal) & 1) == 0) *(&stuff->htotal) = lswaps(*(&stuff->htotal )); else swap_uint16((uint16_t *)(&stuff->htotal)); } while (0); | |||
1752 | swaps(&stuff->hskew)do { if (sizeof(*(&stuff->hskew)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->hskew) & 1) && ((uintptr_t)(&stuff->hskew) & 1) == 0) *(&stuff->hskew) = lswaps(*(&stuff->hskew)) ; else swap_uint16((uint16_t *)(&stuff->hskew)); } while (0); | |||
1753 | swaps(&stuff->vdisplay)do { if (sizeof(*(&stuff->vdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vdisplay ) & 1) && ((uintptr_t)(&stuff->vdisplay) & 1) == 0) *(&stuff->vdisplay) = lswaps(*(&stuff-> vdisplay)); else swap_uint16((uint16_t *)(&stuff->vdisplay )); } while (0); | |||
1754 | swaps(&stuff->vsyncstart)do { if (sizeof(*(&stuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncstart ) & 1) && ((uintptr_t)(&stuff->vsyncstart) & 1) == 0) *(&stuff->vsyncstart) = lswaps(*(& stuff->vsyncstart)); else swap_uint16((uint16_t *)(&stuff ->vsyncstart)); } while (0); | |||
1755 | swaps(&stuff->vsyncend)do { if (sizeof(*(&stuff->vsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncend ) & 1) && ((uintptr_t)(&stuff->vsyncend) & 1) == 0) *(&stuff->vsyncend) = lswaps(*(&stuff-> vsyncend)); else swap_uint16((uint16_t *)(&stuff->vsyncend )); } while (0); | |||
1756 | swaps(&stuff->vtotal)do { if (sizeof(*(&stuff->vtotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->vtotal) & 1) && ((uintptr_t)(&stuff->vtotal) & 1) == 0) *(&stuff->vtotal) = lswaps(*(&stuff->vtotal )); else swap_uint16((uint16_t *)(&stuff->vtotal)); } while (0); | |||
1757 | swapl(&stuff->flags)do { if (sizeof(*(&stuff->flags)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->flags) & 3) && ((uintptr_t)(&stuff->flags) & 3) == 0) *(&stuff->flags) = lswapl(*(&stuff->flags)) ; else swap_uint32((uint32_t *)(&stuff->flags)); } while (0); | |||
1758 | swapl(&stuff->privsize)do { if (sizeof(*(&stuff->privsize)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->privsize ) & 3) && ((uintptr_t)(&stuff->privsize) & 3) == 0) *(&stuff->privsize) = lswapl(*(&stuff-> privsize)); else swap_uint32((uint32_t *)(&stuff->privsize )); } while (0); | |||
1759 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
1760 | } | |||
1761 | return ProcXF86VidModeAddModeLine(client); | |||
1762 | } | |||
1763 | ||||
1764 | static int | |||
1765 | SProcXF86VidModeDeleteModeLine(ClientPtr client) | |||
1766 | { | |||
1767 | xXF86OldVidModeDeleteModeLineReq *oldstuff = | |||
1768 | (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer; | |||
1769 | int ver; | |||
1770 | ||||
1771 | REQUEST(xXF86VidModeDeleteModeLineReq)xXF86VidModeDeleteModeLineReq *stuff = (xXF86VidModeDeleteModeLineReq *)client->requestBuffer; | |||
1772 | ver = ClientMajorVersion(client); | |||
1773 | if (ver < 2) { | |||
1774 | swaps(&oldstuff->length)do { if (sizeof(*(&oldstuff->length)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->length ) & 1) && ((uintptr_t)(&oldstuff->length) & 1) == 0) *(&oldstuff->length) = lswaps(*(&oldstuff ->length)); else swap_uint16((uint16_t *)(&oldstuff-> length)); } while (0); | |||
1775 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq)if ((sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2) > client->req_len ) return(16); | |||
1776 | swapl(&oldstuff->screen)do { if (sizeof(*(&oldstuff->screen)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->screen ) & 3) && ((uintptr_t)(&oldstuff->screen) & 3) == 0) *(&oldstuff->screen) = lswapl(*(&oldstuff ->screen)); else swap_uint32((uint32_t *)(&oldstuff-> screen)); } while (0); | |||
1777 | swaps(&oldstuff->hdisplay)do { if (sizeof(*(&oldstuff->hdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hdisplay ) & 1) && ((uintptr_t)(&oldstuff->hdisplay ) & 1) == 0) *(&oldstuff->hdisplay) = lswaps(*(& oldstuff->hdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->hdisplay)); } while (0); | |||
1778 | swaps(&oldstuff->hsyncstart)do { if (sizeof(*(&oldstuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncstart ) & 1) && ((uintptr_t)(&oldstuff->hsyncstart ) & 1) == 0) *(&oldstuff->hsyncstart) = lswaps(*(& oldstuff->hsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->hsyncstart)); } while (0); | |||
1779 | swaps(&oldstuff->hsyncend)do { if (sizeof(*(&oldstuff->hsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncend ) & 1) && ((uintptr_t)(&oldstuff->hsyncend ) & 1) == 0) *(&oldstuff->hsyncend) = lswaps(*(& oldstuff->hsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->hsyncend)); } while (0); | |||
1780 | swaps(&oldstuff->htotal)do { if (sizeof(*(&oldstuff->htotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->htotal ) & 1) && ((uintptr_t)(&oldstuff->htotal) & 1) == 0) *(&oldstuff->htotal) = lswaps(*(&oldstuff ->htotal)); else swap_uint16((uint16_t *)(&oldstuff-> htotal)); } while (0); | |||
1781 | swaps(&oldstuff->vdisplay)do { if (sizeof(*(&oldstuff->vdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vdisplay ) & 1) && ((uintptr_t)(&oldstuff->vdisplay ) & 1) == 0) *(&oldstuff->vdisplay) = lswaps(*(& oldstuff->vdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->vdisplay)); } while (0); | |||
1782 | swaps(&oldstuff->vsyncstart)do { if (sizeof(*(&oldstuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncstart ) & 1) && ((uintptr_t)(&oldstuff->vsyncstart ) & 1) == 0) *(&oldstuff->vsyncstart) = lswaps(*(& oldstuff->vsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->vsyncstart)); } while (0); | |||
1783 | swaps(&oldstuff->vsyncend)do { if (sizeof(*(&oldstuff->vsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncend ) & 1) && ((uintptr_t)(&oldstuff->vsyncend ) & 1) == 0) *(&oldstuff->vsyncend) = lswaps(*(& oldstuff->vsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->vsyncend)); } while (0); | |||
1784 | swaps(&oldstuff->vtotal)do { if (sizeof(*(&oldstuff->vtotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vtotal ) & 1) && ((uintptr_t)(&oldstuff->vtotal) & 1) == 0) *(&oldstuff->vtotal) = lswaps(*(&oldstuff ->vtotal)); else swap_uint16((uint16_t *)(&oldstuff-> vtotal)); } while (0); | |||
1785 | swapl(&oldstuff->flags)do { if (sizeof(*(&oldstuff->flags)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&oldstuff->flags ) & 3) && ((uintptr_t)(&oldstuff->flags) & 3) == 0) *(&oldstuff->flags) = lswapl(*(&oldstuff ->flags)); else swap_uint32((uint32_t *)(&oldstuff-> flags)); } while (0); | |||
1786 | swapl(&oldstuff->privsize)do { if (sizeof(*(&oldstuff->privsize)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->privsize ) & 3) && ((uintptr_t)(&oldstuff->privsize ) & 3) == 0) *(&oldstuff->privsize) = lswapl(*(& oldstuff->privsize)); else swap_uint32((uint32_t *)(&oldstuff ->privsize)); } while (0); | |||
1787 | SwapRestL(oldstuff)SwapLongs((CARD32 *)(oldstuff + 1), (client->req_len - (sizeof (*oldstuff) >> 2))); | |||
1788 | } | |||
1789 | else { | |||
1790 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1791 | REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq)if ((sizeof(xXF86VidModeDeleteModeLineReq) >> 2) > client ->req_len ) return(16); | |||
1792 | swapl(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 3) && ((uintptr_t)(&stuff->screen) & 3) == 0) *(&stuff->screen) = lswapl(*(&stuff->screen )); else swap_uint32((uint32_t *)(&stuff->screen)); } while (0); | |||
1793 | swaps(&stuff->hdisplay)do { if (sizeof(*(&stuff->hdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hdisplay ) & 1) && ((uintptr_t)(&stuff->hdisplay) & 1) == 0) *(&stuff->hdisplay) = lswaps(*(&stuff-> hdisplay)); else swap_uint16((uint16_t *)(&stuff->hdisplay )); } while (0); | |||
1794 | swaps(&stuff->hsyncstart)do { if (sizeof(*(&stuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncstart ) & 1) && ((uintptr_t)(&stuff->hsyncstart) & 1) == 0) *(&stuff->hsyncstart) = lswaps(*(& stuff->hsyncstart)); else swap_uint16((uint16_t *)(&stuff ->hsyncstart)); } while (0); | |||
1795 | swaps(&stuff->hsyncend)do { if (sizeof(*(&stuff->hsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncend ) & 1) && ((uintptr_t)(&stuff->hsyncend) & 1) == 0) *(&stuff->hsyncend) = lswaps(*(&stuff-> hsyncend)); else swap_uint16((uint16_t *)(&stuff->hsyncend )); } while (0); | |||
1796 | swaps(&stuff->htotal)do { if (sizeof(*(&stuff->htotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->htotal) & 1) && ((uintptr_t)(&stuff->htotal) & 1) == 0) *(&stuff->htotal) = lswaps(*(&stuff->htotal )); else swap_uint16((uint16_t *)(&stuff->htotal)); } while (0); | |||
1797 | swaps(&stuff->hskew)do { if (sizeof(*(&stuff->hskew)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->hskew) & 1) && ((uintptr_t)(&stuff->hskew) & 1) == 0) *(&stuff->hskew) = lswaps(*(&stuff->hskew)) ; else swap_uint16((uint16_t *)(&stuff->hskew)); } while (0); | |||
1798 | swaps(&stuff->vdisplay)do { if (sizeof(*(&stuff->vdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vdisplay ) & 1) && ((uintptr_t)(&stuff->vdisplay) & 1) == 0) *(&stuff->vdisplay) = lswaps(*(&stuff-> vdisplay)); else swap_uint16((uint16_t *)(&stuff->vdisplay )); } while (0); | |||
1799 | swaps(&stuff->vsyncstart)do { if (sizeof(*(&stuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncstart ) & 1) && ((uintptr_t)(&stuff->vsyncstart) & 1) == 0) *(&stuff->vsyncstart) = lswaps(*(& stuff->vsyncstart)); else swap_uint16((uint16_t *)(&stuff ->vsyncstart)); } while (0); | |||
1800 | swaps(&stuff->vsyncend)do { if (sizeof(*(&stuff->vsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncend ) & 1) && ((uintptr_t)(&stuff->vsyncend) & 1) == 0) *(&stuff->vsyncend) = lswaps(*(&stuff-> vsyncend)); else swap_uint16((uint16_t *)(&stuff->vsyncend )); } while (0); | |||
1801 | swaps(&stuff->vtotal)do { if (sizeof(*(&stuff->vtotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->vtotal) & 1) && ((uintptr_t)(&stuff->vtotal) & 1) == 0) *(&stuff->vtotal) = lswaps(*(&stuff->vtotal )); else swap_uint16((uint16_t *)(&stuff->vtotal)); } while (0); | |||
1802 | swapl(&stuff->flags)do { if (sizeof(*(&stuff->flags)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->flags) & 3) && ((uintptr_t)(&stuff->flags) & 3) == 0) *(&stuff->flags) = lswapl(*(&stuff->flags)) ; else swap_uint32((uint32_t *)(&stuff->flags)); } while (0); | |||
1803 | swapl(&stuff->privsize)do { if (sizeof(*(&stuff->privsize)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->privsize ) & 3) && ((uintptr_t)(&stuff->privsize) & 3) == 0) *(&stuff->privsize) = lswapl(*(&stuff-> privsize)); else swap_uint32((uint32_t *)(&stuff->privsize )); } while (0); | |||
1804 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
1805 | } | |||
1806 | return ProcXF86VidModeDeleteModeLine(client); | |||
1807 | } | |||
1808 | ||||
1809 | static int | |||
1810 | SProcXF86VidModeModModeLine(ClientPtr client) | |||
1811 | { | |||
1812 | xXF86OldVidModeModModeLineReq *oldstuff = | |||
1813 | (xXF86OldVidModeModModeLineReq *) client->requestBuffer; | |||
1814 | int ver; | |||
1815 | ||||
1816 | REQUEST(xXF86VidModeModModeLineReq)xXF86VidModeModModeLineReq *stuff = (xXF86VidModeModModeLineReq *)client->requestBuffer; | |||
1817 | ver = ClientMajorVersion(client); | |||
1818 | if (ver < 2) { | |||
1819 | swaps(&oldstuff->length)do { if (sizeof(*(&oldstuff->length)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->length ) & 1) && ((uintptr_t)(&oldstuff->length) & 1) == 0) *(&oldstuff->length) = lswaps(*(&oldstuff ->length)); else swap_uint16((uint16_t *)(&oldstuff-> length)); } while (0); | |||
1820 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq)if ((sizeof(xXF86OldVidModeModModeLineReq) >> 2) > client ->req_len ) return(16); | |||
1821 | swapl(&oldstuff->screen)do { if (sizeof(*(&oldstuff->screen)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->screen ) & 3) && ((uintptr_t)(&oldstuff->screen) & 3) == 0) *(&oldstuff->screen) = lswapl(*(&oldstuff ->screen)); else swap_uint32((uint32_t *)(&oldstuff-> screen)); } while (0); | |||
1822 | swaps(&oldstuff->hdisplay)do { if (sizeof(*(&oldstuff->hdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hdisplay ) & 1) && ((uintptr_t)(&oldstuff->hdisplay ) & 1) == 0) *(&oldstuff->hdisplay) = lswaps(*(& oldstuff->hdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->hdisplay)); } while (0); | |||
1823 | swaps(&oldstuff->hsyncstart)do { if (sizeof(*(&oldstuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncstart ) & 1) && ((uintptr_t)(&oldstuff->hsyncstart ) & 1) == 0) *(&oldstuff->hsyncstart) = lswaps(*(& oldstuff->hsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->hsyncstart)); } while (0); | |||
1824 | swaps(&oldstuff->hsyncend)do { if (sizeof(*(&oldstuff->hsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncend ) & 1) && ((uintptr_t)(&oldstuff->hsyncend ) & 1) == 0) *(&oldstuff->hsyncend) = lswaps(*(& oldstuff->hsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->hsyncend)); } while (0); | |||
1825 | swaps(&oldstuff->htotal)do { if (sizeof(*(&oldstuff->htotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->htotal ) & 1) && ((uintptr_t)(&oldstuff->htotal) & 1) == 0) *(&oldstuff->htotal) = lswaps(*(&oldstuff ->htotal)); else swap_uint16((uint16_t *)(&oldstuff-> htotal)); } while (0); | |||
1826 | swaps(&oldstuff->vdisplay)do { if (sizeof(*(&oldstuff->vdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vdisplay ) & 1) && ((uintptr_t)(&oldstuff->vdisplay ) & 1) == 0) *(&oldstuff->vdisplay) = lswaps(*(& oldstuff->vdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->vdisplay)); } while (0); | |||
1827 | swaps(&oldstuff->vsyncstart)do { if (sizeof(*(&oldstuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncstart ) & 1) && ((uintptr_t)(&oldstuff->vsyncstart ) & 1) == 0) *(&oldstuff->vsyncstart) = lswaps(*(& oldstuff->vsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->vsyncstart)); } while (0); | |||
1828 | swaps(&oldstuff->vsyncend)do { if (sizeof(*(&oldstuff->vsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncend ) & 1) && ((uintptr_t)(&oldstuff->vsyncend ) & 1) == 0) *(&oldstuff->vsyncend) = lswaps(*(& oldstuff->vsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->vsyncend)); } while (0); | |||
1829 | swaps(&oldstuff->vtotal)do { if (sizeof(*(&oldstuff->vtotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vtotal ) & 1) && ((uintptr_t)(&oldstuff->vtotal) & 1) == 0) *(&oldstuff->vtotal) = lswaps(*(&oldstuff ->vtotal)); else swap_uint16((uint16_t *)(&oldstuff-> vtotal)); } while (0); | |||
1830 | swapl(&oldstuff->flags)do { if (sizeof(*(&oldstuff->flags)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&oldstuff->flags ) & 3) && ((uintptr_t)(&oldstuff->flags) & 3) == 0) *(&oldstuff->flags) = lswapl(*(&oldstuff ->flags)); else swap_uint32((uint32_t *)(&oldstuff-> flags)); } while (0); | |||
1831 | swapl(&oldstuff->privsize)do { if (sizeof(*(&oldstuff->privsize)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->privsize ) & 3) && ((uintptr_t)(&oldstuff->privsize ) & 3) == 0) *(&oldstuff->privsize) = lswapl(*(& oldstuff->privsize)); else swap_uint32((uint32_t *)(&oldstuff ->privsize)); } while (0); | |||
1832 | SwapRestL(oldstuff)SwapLongs((CARD32 *)(oldstuff + 1), (client->req_len - (sizeof (*oldstuff) >> 2))); | |||
1833 | } | |||
1834 | else { | |||
1835 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1836 | REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq)if ((sizeof(xXF86VidModeModModeLineReq) >> 2) > client ->req_len ) return(16); | |||
1837 | swapl(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 3) && ((uintptr_t)(&stuff->screen) & 3) == 0) *(&stuff->screen) = lswapl(*(&stuff->screen )); else swap_uint32((uint32_t *)(&stuff->screen)); } while (0); | |||
1838 | swaps(&stuff->hdisplay)do { if (sizeof(*(&stuff->hdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hdisplay ) & 1) && ((uintptr_t)(&stuff->hdisplay) & 1) == 0) *(&stuff->hdisplay) = lswaps(*(&stuff-> hdisplay)); else swap_uint16((uint16_t *)(&stuff->hdisplay )); } while (0); | |||
1839 | swaps(&stuff->hsyncstart)do { if (sizeof(*(&stuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncstart ) & 1) && ((uintptr_t)(&stuff->hsyncstart) & 1) == 0) *(&stuff->hsyncstart) = lswaps(*(& stuff->hsyncstart)); else swap_uint16((uint16_t *)(&stuff ->hsyncstart)); } while (0); | |||
1840 | swaps(&stuff->hsyncend)do { if (sizeof(*(&stuff->hsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncend ) & 1) && ((uintptr_t)(&stuff->hsyncend) & 1) == 0) *(&stuff->hsyncend) = lswaps(*(&stuff-> hsyncend)); else swap_uint16((uint16_t *)(&stuff->hsyncend )); } while (0); | |||
1841 | swaps(&stuff->htotal)do { if (sizeof(*(&stuff->htotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->htotal) & 1) && ((uintptr_t)(&stuff->htotal) & 1) == 0) *(&stuff->htotal) = lswaps(*(&stuff->htotal )); else swap_uint16((uint16_t *)(&stuff->htotal)); } while (0); | |||
1842 | swaps(&stuff->hskew)do { if (sizeof(*(&stuff->hskew)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->hskew) & 1) && ((uintptr_t)(&stuff->hskew) & 1) == 0) *(&stuff->hskew) = lswaps(*(&stuff->hskew)) ; else swap_uint16((uint16_t *)(&stuff->hskew)); } while (0); | |||
1843 | swaps(&stuff->vdisplay)do { if (sizeof(*(&stuff->vdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vdisplay ) & 1) && ((uintptr_t)(&stuff->vdisplay) & 1) == 0) *(&stuff->vdisplay) = lswaps(*(&stuff-> vdisplay)); else swap_uint16((uint16_t *)(&stuff->vdisplay )); } while (0); | |||
1844 | swaps(&stuff->vsyncstart)do { if (sizeof(*(&stuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncstart ) & 1) && ((uintptr_t)(&stuff->vsyncstart) & 1) == 0) *(&stuff->vsyncstart) = lswaps(*(& stuff->vsyncstart)); else swap_uint16((uint16_t *)(&stuff ->vsyncstart)); } while (0); | |||
1845 | swaps(&stuff->vsyncend)do { if (sizeof(*(&stuff->vsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncend ) & 1) && ((uintptr_t)(&stuff->vsyncend) & 1) == 0) *(&stuff->vsyncend) = lswaps(*(&stuff-> vsyncend)); else swap_uint16((uint16_t *)(&stuff->vsyncend )); } while (0); | |||
1846 | swaps(&stuff->vtotal)do { if (sizeof(*(&stuff->vtotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->vtotal) & 1) && ((uintptr_t)(&stuff->vtotal) & 1) == 0) *(&stuff->vtotal) = lswaps(*(&stuff->vtotal )); else swap_uint16((uint16_t *)(&stuff->vtotal)); } while (0); | |||
1847 | swapl(&stuff->flags)do { if (sizeof(*(&stuff->flags)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->flags) & 3) && ((uintptr_t)(&stuff->flags) & 3) == 0) *(&stuff->flags) = lswapl(*(&stuff->flags)) ; else swap_uint32((uint32_t *)(&stuff->flags)); } while (0); | |||
1848 | swapl(&stuff->privsize)do { if (sizeof(*(&stuff->privsize)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->privsize ) & 3) && ((uintptr_t)(&stuff->privsize) & 3) == 0) *(&stuff->privsize) = lswapl(*(&stuff-> privsize)); else swap_uint32((uint32_t *)(&stuff->privsize )); } while (0); | |||
1849 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
1850 | } | |||
1851 | return ProcXF86VidModeModModeLine(client); | |||
1852 | } | |||
1853 | ||||
1854 | static int | |||
1855 | SProcXF86VidModeValidateModeLine(ClientPtr client) | |||
1856 | { | |||
1857 | xXF86OldVidModeValidateModeLineReq *oldstuff = | |||
1858 | (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer; | |||
1859 | int ver; | |||
1860 | ||||
1861 | REQUEST(xXF86VidModeValidateModeLineReq)xXF86VidModeValidateModeLineReq *stuff = (xXF86VidModeValidateModeLineReq *)client->requestBuffer; | |||
1862 | ver = ClientMajorVersion(client); | |||
1863 | if (ver < 2) { | |||
1864 | swaps(&oldstuff->length)do { if (sizeof(*(&oldstuff->length)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->length ) & 1) && ((uintptr_t)(&oldstuff->length) & 1) == 0) *(&oldstuff->length) = lswaps(*(&oldstuff ->length)); else swap_uint16((uint16_t *)(&oldstuff-> length)); } while (0); | |||
1865 | REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq)if ((sizeof(xXF86OldVidModeValidateModeLineReq) >> 2) > client->req_len ) return(16); | |||
1866 | swapl(&oldstuff->screen)do { if (sizeof(*(&oldstuff->screen)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->screen ) & 3) && ((uintptr_t)(&oldstuff->screen) & 3) == 0) *(&oldstuff->screen) = lswapl(*(&oldstuff ->screen)); else swap_uint32((uint32_t *)(&oldstuff-> screen)); } while (0); | |||
1867 | swaps(&oldstuff->hdisplay)do { if (sizeof(*(&oldstuff->hdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hdisplay ) & 1) && ((uintptr_t)(&oldstuff->hdisplay ) & 1) == 0) *(&oldstuff->hdisplay) = lswaps(*(& oldstuff->hdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->hdisplay)); } while (0); | |||
1868 | swaps(&oldstuff->hsyncstart)do { if (sizeof(*(&oldstuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncstart ) & 1) && ((uintptr_t)(&oldstuff->hsyncstart ) & 1) == 0) *(&oldstuff->hsyncstart) = lswaps(*(& oldstuff->hsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->hsyncstart)); } while (0); | |||
1869 | swaps(&oldstuff->hsyncend)do { if (sizeof(*(&oldstuff->hsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->hsyncend ) & 1) && ((uintptr_t)(&oldstuff->hsyncend ) & 1) == 0) *(&oldstuff->hsyncend) = lswaps(*(& oldstuff->hsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->hsyncend)); } while (0); | |||
1870 | swaps(&oldstuff->htotal)do { if (sizeof(*(&oldstuff->htotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->htotal ) & 1) && ((uintptr_t)(&oldstuff->htotal) & 1) == 0) *(&oldstuff->htotal) = lswaps(*(&oldstuff ->htotal)); else swap_uint16((uint16_t *)(&oldstuff-> htotal)); } while (0); | |||
1871 | swaps(&oldstuff->vdisplay)do { if (sizeof(*(&oldstuff->vdisplay)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vdisplay ) & 1) && ((uintptr_t)(&oldstuff->vdisplay ) & 1) == 0) *(&oldstuff->vdisplay) = lswaps(*(& oldstuff->vdisplay)); else swap_uint16((uint16_t *)(&oldstuff ->vdisplay)); } while (0); | |||
1872 | swaps(&oldstuff->vsyncstart)do { if (sizeof(*(&oldstuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncstart ) & 1) && ((uintptr_t)(&oldstuff->vsyncstart ) & 1) == 0) *(&oldstuff->vsyncstart) = lswaps(*(& oldstuff->vsyncstart)); else swap_uint16((uint16_t *)(& oldstuff->vsyncstart)); } while (0); | |||
1873 | swaps(&oldstuff->vsyncend)do { if (sizeof(*(&oldstuff->vsyncend)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vsyncend ) & 1) && ((uintptr_t)(&oldstuff->vsyncend ) & 1) == 0) *(&oldstuff->vsyncend) = lswaps(*(& oldstuff->vsyncend)); else swap_uint16((uint16_t *)(&oldstuff ->vsyncend)); } while (0); | |||
1874 | swaps(&oldstuff->vtotal)do { if (sizeof(*(&oldstuff->vtotal)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->vtotal ) & 1) && ((uintptr_t)(&oldstuff->vtotal) & 1) == 0) *(&oldstuff->vtotal) = lswaps(*(&oldstuff ->vtotal)); else swap_uint16((uint16_t *)(&oldstuff-> vtotal)); } while (0); | |||
1875 | swapl(&oldstuff->flags)do { if (sizeof(*(&oldstuff->flags)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&oldstuff->flags ) & 3) && ((uintptr_t)(&oldstuff->flags) & 3) == 0) *(&oldstuff->flags) = lswapl(*(&oldstuff ->flags)); else swap_uint32((uint32_t *)(&oldstuff-> flags)); } while (0); | |||
1876 | swapl(&oldstuff->privsize)do { if (sizeof(*(&oldstuff->privsize)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&oldstuff->privsize ) & 3) && ((uintptr_t)(&oldstuff->privsize ) & 3) == 0) *(&oldstuff->privsize) = lswapl(*(& oldstuff->privsize)); else swap_uint32((uint32_t *)(&oldstuff ->privsize)); } while (0); | |||
1877 | SwapRestL(oldstuff)SwapLongs((CARD32 *)(oldstuff + 1), (client->req_len - (sizeof (*oldstuff) >> 2))); | |||
1878 | } | |||
1879 | else { | |||
1880 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1881 | REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq)if ((sizeof(xXF86VidModeValidateModeLineReq) >> 2) > client->req_len ) return(16); | |||
1882 | swapl(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 3) && ((uintptr_t)(&stuff->screen) & 3) == 0) *(&stuff->screen) = lswapl(*(&stuff->screen )); else swap_uint32((uint32_t *)(&stuff->screen)); } while (0); | |||
1883 | swaps(&stuff->hdisplay)do { if (sizeof(*(&stuff->hdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hdisplay ) & 1) && ((uintptr_t)(&stuff->hdisplay) & 1) == 0) *(&stuff->hdisplay) = lswaps(*(&stuff-> hdisplay)); else swap_uint16((uint16_t *)(&stuff->hdisplay )); } while (0); | |||
1884 | swaps(&stuff->hsyncstart)do { if (sizeof(*(&stuff->hsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncstart ) & 1) && ((uintptr_t)(&stuff->hsyncstart) & 1) == 0) *(&stuff->hsyncstart) = lswaps(*(& stuff->hsyncstart)); else swap_uint16((uint16_t *)(&stuff ->hsyncstart)); } while (0); | |||
1885 | swaps(&stuff->hsyncend)do { if (sizeof(*(&stuff->hsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->hsyncend ) & 1) && ((uintptr_t)(&stuff->hsyncend) & 1) == 0) *(&stuff->hsyncend) = lswaps(*(&stuff-> hsyncend)); else swap_uint16((uint16_t *)(&stuff->hsyncend )); } while (0); | |||
1886 | swaps(&stuff->htotal)do { if (sizeof(*(&stuff->htotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->htotal) & 1) && ((uintptr_t)(&stuff->htotal) & 1) == 0) *(&stuff->htotal) = lswaps(*(&stuff->htotal )); else swap_uint16((uint16_t *)(&stuff->htotal)); } while (0); | |||
1887 | swaps(&stuff->hskew)do { if (sizeof(*(&stuff->hskew)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->hskew) & 1) && ((uintptr_t)(&stuff->hskew) & 1) == 0) *(&stuff->hskew) = lswaps(*(&stuff->hskew)) ; else swap_uint16((uint16_t *)(&stuff->hskew)); } while (0); | |||
1888 | swaps(&stuff->vdisplay)do { if (sizeof(*(&stuff->vdisplay)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vdisplay ) & 1) && ((uintptr_t)(&stuff->vdisplay) & 1) == 0) *(&stuff->vdisplay) = lswaps(*(&stuff-> vdisplay)); else swap_uint16((uint16_t *)(&stuff->vdisplay )); } while (0); | |||
1889 | swaps(&stuff->vsyncstart)do { if (sizeof(*(&stuff->vsyncstart)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncstart ) & 1) && ((uintptr_t)(&stuff->vsyncstart) & 1) == 0) *(&stuff->vsyncstart) = lswaps(*(& stuff->vsyncstart)); else swap_uint16((uint16_t *)(&stuff ->vsyncstart)); } while (0); | |||
1890 | swaps(&stuff->vsyncend)do { if (sizeof(*(&stuff->vsyncend)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->vsyncend ) & 1) && ((uintptr_t)(&stuff->vsyncend) & 1) == 0) *(&stuff->vsyncend) = lswaps(*(&stuff-> vsyncend)); else swap_uint16((uint16_t *)(&stuff->vsyncend )); } while (0); | |||
1891 | swaps(&stuff->vtotal)do { if (sizeof(*(&stuff->vtotal)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->vtotal) & 1) && ((uintptr_t)(&stuff->vtotal) & 1) == 0) *(&stuff->vtotal) = lswaps(*(&stuff->vtotal )); else swap_uint16((uint16_t *)(&stuff->vtotal)); } while (0); | |||
1892 | swapl(&stuff->flags)do { if (sizeof(*(&stuff->flags)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->flags) & 3) && ((uintptr_t)(&stuff->flags) & 3) == 0) *(&stuff->flags) = lswapl(*(&stuff->flags)) ; else swap_uint32((uint32_t *)(&stuff->flags)); } while (0); | |||
1893 | swapl(&stuff->privsize)do { if (sizeof(*(&stuff->privsize)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&stuff->privsize ) & 3) && ((uintptr_t)(&stuff->privsize) & 3) == 0) *(&stuff->privsize) = lswapl(*(&stuff-> privsize)); else swap_uint32((uint32_t *)(&stuff->privsize )); } while (0); | |||
1894 | SwapRestL(stuff)SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof (*stuff) >> 2))); | |||
1895 | } | |||
1896 | return ProcXF86VidModeValidateModeLine(client); | |||
1897 | } | |||
1898 | ||||
1899 | static int | |||
1900 | SProcXF86VidModeSwitchMode(ClientPtr client) | |||
1901 | { | |||
1902 | REQUEST(xXF86VidModeSwitchModeReq)xXF86VidModeSwitchModeReq *stuff = (xXF86VidModeSwitchModeReq *)client->requestBuffer; | |||
1903 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1904 | REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq)if ((sizeof(xXF86VidModeSwitchModeReq) >> 2) != client-> req_len) return(16); | |||
1905 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1906 | swaps(&stuff->zoom)do { if (sizeof(*(&stuff->zoom)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->zoom) & 1) && ((uintptr_t)(&stuff->zoom) & 1) == 0 ) *(&stuff->zoom) = lswaps(*(&stuff->zoom)); else swap_uint16((uint16_t *)(&stuff->zoom)); } while (0); | |||
1907 | return ProcXF86VidModeSwitchMode(client); | |||
1908 | } | |||
1909 | ||||
1910 | static int | |||
1911 | SProcXF86VidModeSwitchToMode(ClientPtr client) | |||
1912 | { | |||
1913 | REQUEST(xXF86VidModeSwitchToModeReq)xXF86VidModeSwitchToModeReq *stuff = (xXF86VidModeSwitchToModeReq *)client->requestBuffer; | |||
1914 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1915 | REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq)if ((sizeof(xXF86VidModeSwitchToModeReq) >> 2) != client ->req_len) return(16); | |||
1916 | swapl(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 3) && ((uintptr_t)(&stuff->screen) & 3) == 0) *(&stuff->screen) = lswapl(*(&stuff->screen )); else swap_uint32((uint32_t *)(&stuff->screen)); } while (0); | |||
1917 | return ProcXF86VidModeSwitchToMode(client); | |||
1918 | } | |||
1919 | ||||
1920 | static int | |||
1921 | SProcXF86VidModeLockModeSwitch(ClientPtr client) | |||
1922 | { | |||
1923 | REQUEST(xXF86VidModeLockModeSwitchReq)xXF86VidModeLockModeSwitchReq *stuff = (xXF86VidModeLockModeSwitchReq *)client->requestBuffer; | |||
1924 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1925 | REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq)if ((sizeof(xXF86VidModeLockModeSwitchReq) >> 2) != client ->req_len) return(16); | |||
1926 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1927 | swaps(&stuff->lock)do { if (sizeof(*(&stuff->lock)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->lock) & 1) && ((uintptr_t)(&stuff->lock) & 1) == 0 ) *(&stuff->lock) = lswaps(*(&stuff->lock)); else swap_uint16((uint16_t *)(&stuff->lock)); } while (0); | |||
1928 | return ProcXF86VidModeLockModeSwitch(client); | |||
1929 | } | |||
1930 | ||||
1931 | static int | |||
1932 | SProcXF86VidModeGetMonitor(ClientPtr client) | |||
1933 | { | |||
1934 | REQUEST(xXF86VidModeGetMonitorReq)xXF86VidModeGetMonitorReq *stuff = (xXF86VidModeGetMonitorReq *)client->requestBuffer; | |||
1935 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1936 | REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq)if ((sizeof(xXF86VidModeGetMonitorReq) >> 2) != client-> req_len) return(16); | |||
1937 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1938 | return ProcXF86VidModeGetMonitor(client); | |||
1939 | } | |||
1940 | ||||
1941 | static int | |||
1942 | SProcXF86VidModeGetViewPort(ClientPtr client) | |||
1943 | { | |||
1944 | REQUEST(xXF86VidModeGetViewPortReq)xXF86VidModeGetViewPortReq *stuff = (xXF86VidModeGetViewPortReq *)client->requestBuffer; | |||
1945 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1946 | REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq)if ((sizeof(xXF86VidModeGetViewPortReq) >> 2) != client ->req_len) return(16); | |||
1947 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1948 | return ProcXF86VidModeGetViewPort(client); | |||
1949 | } | |||
1950 | ||||
1951 | static int | |||
1952 | SProcXF86VidModeSetViewPort(ClientPtr client) | |||
1953 | { | |||
1954 | REQUEST(xXF86VidModeSetViewPortReq)xXF86VidModeSetViewPortReq *stuff = (xXF86VidModeSetViewPortReq *)client->requestBuffer; | |||
1955 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1956 | REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq)if ((sizeof(xXF86VidModeSetViewPortReq) >> 2) != client ->req_len) return(16); | |||
1957 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1958 | swapl(&stuff->x)do { if (sizeof(*(&stuff->x)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&stuff->x) & 3) && ((uintptr_t)(&stuff->x) & 3) == 0) *(&stuff-> x) = lswapl(*(&stuff->x)); else swap_uint32((uint32_t * )(&stuff->x)); } while (0); | |||
1959 | swapl(&stuff->y)do { if (sizeof(*(&stuff->y)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&stuff->y) & 3) && ((uintptr_t)(&stuff->y) & 3) == 0) *(&stuff-> y) = lswapl(*(&stuff->y)); else swap_uint32((uint32_t * )(&stuff->y)); } while (0); | |||
1960 | return ProcXF86VidModeSetViewPort(client); | |||
1961 | } | |||
1962 | ||||
1963 | static int | |||
1964 | SProcXF86VidModeGetDotClocks(ClientPtr client) | |||
1965 | { | |||
1966 | REQUEST(xXF86VidModeGetDotClocksReq)xXF86VidModeGetDotClocksReq *stuff = (xXF86VidModeGetDotClocksReq *)client->requestBuffer; | |||
1967 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1968 | REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq)if ((sizeof(xXF86VidModeGetDotClocksReq) >> 2) != client ->req_len) return(16); | |||
1969 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1970 | return ProcXF86VidModeGetDotClocks(client); | |||
1971 | } | |||
1972 | ||||
1973 | static int | |||
1974 | SProcXF86VidModeSetClientVersion(ClientPtr client) | |||
1975 | { | |||
1976 | REQUEST(xXF86VidModeSetClientVersionReq)xXF86VidModeSetClientVersionReq *stuff = (xXF86VidModeSetClientVersionReq *)client->requestBuffer; | |||
1977 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1978 | REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq)if ((sizeof(xXF86VidModeSetClientVersionReq) >> 2) != client ->req_len) return(16); | |||
1979 | swaps(&stuff->major)do { if (sizeof(*(&stuff->major)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->major) & 1) && ((uintptr_t)(&stuff->major) & 1) == 0) *(&stuff->major) = lswaps(*(&stuff->major)) ; else swap_uint16((uint16_t *)(&stuff->major)); } while (0); | |||
1980 | swaps(&stuff->minor)do { if (sizeof(*(&stuff->minor)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->minor) & 1) && ((uintptr_t)(&stuff->minor) & 1) == 0) *(&stuff->minor) = lswaps(*(&stuff->minor)) ; else swap_uint16((uint16_t *)(&stuff->minor)); } while (0); | |||
1981 | return ProcXF86VidModeSetClientVersion(client); | |||
1982 | } | |||
1983 | ||||
1984 | static int | |||
1985 | SProcXF86VidModeSetGamma(ClientPtr client) | |||
1986 | { | |||
1987 | REQUEST(xXF86VidModeSetGammaReq)xXF86VidModeSetGammaReq *stuff = (xXF86VidModeSetGammaReq *)client ->requestBuffer; | |||
1988 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
1989 | REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq)if ((sizeof(xXF86VidModeSetGammaReq) >> 2) != client-> req_len) return(16); | |||
1990 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
1991 | swapl(&stuff->red)do { if (sizeof(*(&stuff->red)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->red) & 3 ) && ((uintptr_t)(&stuff->red) & 3) == 0) * (&stuff->red) = lswapl(*(&stuff->red)); else swap_uint32 ((uint32_t *)(&stuff->red)); } while (0); | |||
1992 | swapl(&stuff->green)do { if (sizeof(*(&stuff->green)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->green) & 3) && ((uintptr_t)(&stuff->green) & 3) == 0) *(&stuff->green) = lswapl(*(&stuff->green)) ; else swap_uint32((uint32_t *)(&stuff->green)); } while (0); | |||
1993 | swapl(&stuff->blue)do { if (sizeof(*(&stuff->blue)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->blue) & 3) && ((uintptr_t)(&stuff->blue) & 3) == 0 ) *(&stuff->blue) = lswapl(*(&stuff->blue)); else swap_uint32((uint32_t *)(&stuff->blue)); } while (0); | |||
1994 | return ProcXF86VidModeSetGamma(client); | |||
1995 | } | |||
1996 | ||||
1997 | static int | |||
1998 | SProcXF86VidModeGetGamma(ClientPtr client) | |||
1999 | { | |||
2000 | REQUEST(xXF86VidModeGetGammaReq)xXF86VidModeGetGammaReq *stuff = (xXF86VidModeGetGammaReq *)client ->requestBuffer; | |||
2001 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2002 | REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq)if ((sizeof(xXF86VidModeGetGammaReq) >> 2) != client-> req_len) return(16); | |||
2003 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
2004 | return ProcXF86VidModeGetGamma(client); | |||
2005 | } | |||
2006 | ||||
2007 | static int | |||
2008 | SProcXF86VidModeSetGammaRamp(ClientPtr client) | |||
2009 | { | |||
2010 | int length; | |||
2011 | ||||
2012 | REQUEST(xXF86VidModeSetGammaRampReq)xXF86VidModeSetGammaRampReq *stuff = (xXF86VidModeSetGammaRampReq *)client->requestBuffer; | |||
2013 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2014 | REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq)if ((sizeof(xXF86VidModeSetGammaRampReq) >> 2) > client ->req_len ) return(16); | |||
2015 | swaps(&stuff->size)do { if (sizeof(*(&stuff->size)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->size) & 1) && ((uintptr_t)(&stuff->size) & 1) == 0 ) *(&stuff->size) = lswaps(*(&stuff->size)); else swap_uint16((uint16_t *)(&stuff->size)); } while (0); | |||
2016 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
2017 | length = ((stuff->size + 1) & ~1) * 6; | |||
2018 | REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length)if (((sizeof(xXF86VidModeSetGammaRampReq) >> 2) > client ->req_len) || (((length) >> 2) >= client->req_len ) || ((((uint64_t) sizeof(xXF86VidModeSetGammaRampReq) + (length ) + 3) >> 2) != (uint64_t) client->req_len)) return( 16); | |||
2019 | SwapRestS(stuff)SwapShorts((short *)(stuff + 1), ((client->req_len << 1) - (sizeof(*stuff) >> 1))); | |||
2020 | return ProcXF86VidModeSetGammaRamp(client); | |||
2021 | } | |||
2022 | ||||
2023 | static int | |||
2024 | SProcXF86VidModeGetGammaRamp(ClientPtr client) | |||
2025 | { | |||
2026 | REQUEST(xXF86VidModeGetGammaRampReq)xXF86VidModeGetGammaRampReq *stuff = (xXF86VidModeGetGammaRampReq *)client->requestBuffer; | |||
2027 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2028 | REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq)if ((sizeof(xXF86VidModeGetGammaRampReq) >> 2) != client ->req_len) return(16); | |||
2029 | swaps(&stuff->size)do { if (sizeof(*(&stuff->size)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->size) & 1) && ((uintptr_t)(&stuff->size) & 1) == 0 ) *(&stuff->size) = lswaps(*(&stuff->size)); else swap_uint16((uint16_t *)(&stuff->size)); } while (0); | |||
2030 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
2031 | return ProcXF86VidModeGetGammaRamp(client); | |||
2032 | } | |||
2033 | ||||
2034 | static int | |||
2035 | SProcXF86VidModeGetGammaRampSize(ClientPtr client) | |||
2036 | { | |||
2037 | REQUEST(xXF86VidModeGetGammaRampSizeReq)xXF86VidModeGetGammaRampSizeReq *stuff = (xXF86VidModeGetGammaRampSizeReq *)client->requestBuffer; | |||
2038 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2039 | REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq)if ((sizeof(xXF86VidModeGetGammaRampSizeReq) >> 2) != client ->req_len) return(16); | |||
2040 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
2041 | return ProcXF86VidModeGetGammaRampSize(client); | |||
2042 | } | |||
2043 | ||||
2044 | static int | |||
2045 | SProcXF86VidModeGetPermissions(ClientPtr client) | |||
2046 | { | |||
2047 | REQUEST(xXF86VidModeGetPermissionsReq)xXF86VidModeGetPermissionsReq *stuff = (xXF86VidModeGetPermissionsReq *)client->requestBuffer; | |||
2048 | swaps(&stuff->length)do { if (sizeof(*(&stuff->length)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->length) & 1) && ((uintptr_t)(&stuff->length) & 1) == 0) *(&stuff->length) = lswaps(*(&stuff->length )); else swap_uint16((uint16_t *)(&stuff->length)); } while (0); | |||
2049 | REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq)if ((sizeof(xXF86VidModeGetPermissionsReq) >> 2) != client ->req_len) return(16); | |||
2050 | swaps(&stuff->screen)do { if (sizeof(*(&stuff->screen)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&stuff->screen) & 1) && ((uintptr_t)(&stuff->screen) & 1) == 0) *(&stuff->screen) = lswaps(*(&stuff->screen )); else swap_uint16((uint16_t *)(&stuff->screen)); } while (0); | |||
2051 | return ProcXF86VidModeGetPermissions(client); | |||
2052 | } | |||
2053 | ||||
2054 | static int | |||
2055 | SProcXF86VidModeDispatch(ClientPtr client) | |||
2056 | { | |||
2057 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; | |||
2058 | switch (stuff->data) { | |||
2059 | case X_XF86VidModeQueryVersion0: | |||
2060 | return SProcXF86VidModeQueryVersion(client); | |||
2061 | case X_XF86VidModeGetModeLine1: | |||
2062 | return SProcXF86VidModeGetModeLine(client); | |||
2063 | case X_XF86VidModeGetMonitor4: | |||
2064 | return SProcXF86VidModeGetMonitor(client); | |||
2065 | case X_XF86VidModeGetAllModeLines6: | |||
2066 | return SProcXF86VidModeGetAllModeLines(client); | |||
2067 | case X_XF86VidModeGetViewPort11: | |||
2068 | return SProcXF86VidModeGetViewPort(client); | |||
2069 | case X_XF86VidModeValidateModeLine9: | |||
2070 | return SProcXF86VidModeValidateModeLine(client); | |||
2071 | case X_XF86VidModeGetDotClocks13: | |||
2072 | return SProcXF86VidModeGetDotClocks(client); | |||
2073 | case X_XF86VidModeSetClientVersion14: | |||
2074 | return SProcXF86VidModeSetClientVersion(client); | |||
2075 | case X_XF86VidModeGetGamma16: | |||
2076 | return SProcXF86VidModeGetGamma(client); | |||
2077 | case X_XF86VidModeGetGammaRamp17: | |||
2078 | return SProcXF86VidModeGetGammaRamp(client); | |||
2079 | case X_XF86VidModeGetGammaRampSize19: | |||
2080 | return SProcXF86VidModeGetGammaRampSize(client); | |||
2081 | case X_XF86VidModeGetPermissions20: | |||
2082 | return SProcXF86VidModeGetPermissions(client); | |||
2083 | default: | |||
2084 | if (!xf86GetVidModeEnabled()) | |||
2085 | return VidModeErrorBase + XF86VidModeExtensionDisabled4; | |||
2086 | if (xf86GetVidModeAllowNonLocal() || client->local) { | |||
2087 | switch (stuff->data) { | |||
2088 | case X_XF86VidModeAddModeLine7: | |||
2089 | return SProcXF86VidModeAddModeLine(client); | |||
2090 | case X_XF86VidModeDeleteModeLine8: | |||
2091 | return SProcXF86VidModeDeleteModeLine(client); | |||
2092 | case X_XF86VidModeModModeLine2: | |||
2093 | return SProcXF86VidModeModModeLine(client); | |||
2094 | case X_XF86VidModeSwitchMode3: | |||
2095 | return SProcXF86VidModeSwitchMode(client); | |||
2096 | case X_XF86VidModeSwitchToMode10: | |||
2097 | return SProcXF86VidModeSwitchToMode(client); | |||
2098 | case X_XF86VidModeLockModeSwitch5: | |||
2099 | return SProcXF86VidModeLockModeSwitch(client); | |||
2100 | case X_XF86VidModeSetViewPort12: | |||
2101 | return SProcXF86VidModeSetViewPort(client); | |||
2102 | case X_XF86VidModeSetGamma15: | |||
2103 | return SProcXF86VidModeSetGamma(client); | |||
2104 | case X_XF86VidModeSetGammaRamp18: | |||
2105 | return SProcXF86VidModeSetGammaRamp(client); | |||
2106 | default: | |||
2107 | return BadRequest1; | |||
2108 | } | |||
2109 | } | |||
2110 | else | |||
2111 | return VidModeErrorBase + XF86VidModeClientNotLocal5; | |||
2112 | } | |||
2113 | } | |||
2114 | ||||
2115 | void | |||
2116 | XFree86VidModeExtensionInit(void) | |||
2117 | { | |||
2118 | ExtensionEntry *extEntry; | |||
2119 | ScreenPtr pScreen; | |||
2120 | int i; | |||
2121 | Bool enabled = FALSE0; | |||
2122 | ||||
2123 | DEBUG_P("XFree86VidModeExtensionInit"); | |||
2124 | ||||
2125 | if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0)) | |||
2126 | return; | |||
2127 | #ifdef XF86VIDMODE_EVENTS | |||
2128 | if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) | |||
2129 | return; | |||
2130 | #endif | |||
2131 | ||||
2132 | #ifdef XF86VIDMODE_EVENTS | |||
2133 | EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent"); | |||
2134 | #endif | |||
2135 | ||||
2136 | for (i = 0; i < screenInfo.numScreens; i++) { | |||
2137 | pScreen = screenInfo.screens[i]; | |||
2138 | if (VidModeExtensionInit(pScreen)) | |||
2139 | enabled = TRUE1; | |||
2140 | } | |||
2141 | /* This means that the DDX doesn't want the vidmode extension enabled */ | |||
2142 | if (!enabled) | |||
2143 | return; | |||
2144 | ||||
2145 | if ( | |||
2146 | #ifdef XF86VIDMODE_EVENTS | |||
2147 | EventType && | |||
2148 | #endif | |||
2149 | (extEntry = AddExtension(XF86VIDMODENAME"XFree86-VidModeExtension", | |||
2150 | XF86VidModeNumberEvents0, | |||
2151 | XF86VidModeNumberErrors(6 + 1), | |||
2152 | ProcXF86VidModeDispatch, | |||
2153 | SProcXF86VidModeDispatch, | |||
2154 | NULL((void*)0), StandardMinorOpcode))) { | |||
2155 | #if 0 | |||
2156 | XF86VidModeReqCode = (unsigned char) extEntry->base; | |||
2157 | #endif | |||
2158 | VidModeErrorBase = extEntry->errorBase; | |||
2159 | #ifdef XF86VIDMODE_EVENTS | |||
2160 | XF86VidModeEventBase = extEntry->eventBase; | |||
2161 | EventSwapVector[XF86VidModeEventBase] = | |||
2162 | (EventSwapPtr) SXF86VidModeNotifyEvent; | |||
2163 | #endif | |||
2164 | } | |||
2165 | } |