Add patch that contain Mali fixes.
[deb_xorg-server.git] / randr / rrsdispatch.c
CommitLineData
a09e091a
JB
1/*
2 * Copyright © 2006 Keith Packard
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#include "randrstr.h"
24
25static int
26SProcRRQueryVersion(ClientPtr client)
27{
28 REQUEST(xRRQueryVersionReq);
29
30 swaps(&stuff->length);
31 swapl(&stuff->majorVersion);
32 swapl(&stuff->minorVersion);
33 return (*ProcRandrVector[stuff->randrReqType]) (client);
34}
35
36static int
37SProcRRGetScreenInfo(ClientPtr client)
38{
39 REQUEST(xRRGetScreenInfoReq);
40
41 swaps(&stuff->length);
42 swapl(&stuff->window);
43 return (*ProcRandrVector[stuff->randrReqType]) (client);
44}
45
46static int
47SProcRRSetScreenConfig(ClientPtr client)
48{
49 REQUEST(xRRSetScreenConfigReq);
50
51 if (RRClientKnowsRates(client)) {
52 REQUEST_SIZE_MATCH(xRRSetScreenConfigReq);
53 swaps(&stuff->rate);
54 }
55 else {
56 REQUEST_SIZE_MATCH(xRR1_0SetScreenConfigReq);
57 }
58
59 swaps(&stuff->length);
60 swapl(&stuff->drawable);
61 swapl(&stuff->timestamp);
62 swaps(&stuff->sizeID);
63 swaps(&stuff->rotation);
64 return (*ProcRandrVector[stuff->randrReqType]) (client);
65}
66
67static int
68SProcRRSelectInput(ClientPtr client)
69{
70 REQUEST(xRRSelectInputReq);
71
72 swaps(&stuff->length);
73 swapl(&stuff->window);
74 swaps(&stuff->enable);
75 return (*ProcRandrVector[stuff->randrReqType]) (client);
76}
77
78static int
79SProcRRGetScreenSizeRange(ClientPtr client)
80{
81 REQUEST(xRRGetScreenSizeRangeReq);
82
83 REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
84 swaps(&stuff->length);
85 swapl(&stuff->window);
86 return (*ProcRandrVector[stuff->randrReqType]) (client);
87}
88
89static int
90SProcRRSetScreenSize(ClientPtr client)
91{
92 REQUEST(xRRSetScreenSizeReq);
93
94 REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
95 swaps(&stuff->length);
96 swapl(&stuff->window);
97 swaps(&stuff->width);
98 swaps(&stuff->height);
99 swapl(&stuff->widthInMillimeters);
100 swapl(&stuff->heightInMillimeters);
101 return (*ProcRandrVector[stuff->randrReqType]) (client);
102}
103
104static int
105SProcRRGetScreenResources(ClientPtr client)
106{
107 REQUEST(xRRGetScreenResourcesReq);
108
109 REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
110 swaps(&stuff->length);
111 swapl(&stuff->window);
112 return (*ProcRandrVector[stuff->randrReqType]) (client);
113}
114
115static int
116SProcRRGetOutputInfo(ClientPtr client)
117{
118 REQUEST(xRRGetOutputInfoReq);
119
120 REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
121 swaps(&stuff->length);
122 swapl(&stuff->output);
123 swapl(&stuff->configTimestamp);
124 return (*ProcRandrVector[stuff->randrReqType]) (client);
125}
126
127static int
128SProcRRListOutputProperties(ClientPtr client)
129{
130 REQUEST(xRRListOutputPropertiesReq);
131
132 REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
133 swaps(&stuff->length);
134 swapl(&stuff->output);
135 return (*ProcRandrVector[stuff->randrReqType]) (client);
136}
137
138static int
139SProcRRQueryOutputProperty(ClientPtr client)
140{
141 REQUEST(xRRQueryOutputPropertyReq);
142
143 REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
144 swaps(&stuff->length);
145 swapl(&stuff->output);
146 swapl(&stuff->property);
147 return (*ProcRandrVector[stuff->randrReqType]) (client);
148}
149
150static int
151SProcRRConfigureOutputProperty(ClientPtr client)
152{
153 REQUEST(xRRConfigureOutputPropertyReq);
154
155 swaps(&stuff->length);
156 swapl(&stuff->output);
157 swapl(&stuff->property);
158 SwapRestL(stuff);
159 return (*ProcRandrVector[stuff->randrReqType]) (client);
160}
161
162static int
163SProcRRChangeOutputProperty(ClientPtr client)
164{
165 REQUEST(xRRChangeOutputPropertyReq);
166
167 REQUEST_AT_LEAST_SIZE(xRRChangeOutputPropertyReq);
168 swaps(&stuff->length);
169 swapl(&stuff->output);
170 swapl(&stuff->property);
171 swapl(&stuff->type);
172 swapl(&stuff->nUnits);
173 switch (stuff->format) {
174 case 8:
175 break;
176 case 16:
177 SwapRestS(stuff);
178 break;
179 case 32:
180 SwapRestL(stuff);
181 break;
182 default:
183 client->errorValue = stuff->format;
184 return BadValue;
185 }
186 return (*ProcRandrVector[stuff->randrReqType]) (client);
187}
188
189static int
190SProcRRDeleteOutputProperty(ClientPtr client)
191{
192 REQUEST(xRRDeleteOutputPropertyReq);
193
194 REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
195 swaps(&stuff->length);
196 swapl(&stuff->output);
197 swapl(&stuff->property);
198 return (*ProcRandrVector[stuff->randrReqType]) (client);
199}
200
201static int
202SProcRRGetOutputProperty(ClientPtr client)
203{
204 REQUEST(xRRGetOutputPropertyReq);
205
206 REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
207 swaps(&stuff->length);
208 swapl(&stuff->output);
209 swapl(&stuff->property);
210 swapl(&stuff->type);
211 swapl(&stuff->longOffset);
212 swapl(&stuff->longLength);
213 return (*ProcRandrVector[stuff->randrReqType]) (client);
214}
215
216static int
217SProcRRCreateMode(ClientPtr client)
218{
219 xRRModeInfo *modeinfo;
220
221 REQUEST(xRRCreateModeReq);
222
223 REQUEST_AT_LEAST_SIZE(xRRCreateModeReq);
224 swaps(&stuff->length);
225 swapl(&stuff->window);
226
227 modeinfo = &stuff->modeInfo;
228 swapl(&modeinfo->id);
229 swaps(&modeinfo->width);
230 swaps(&modeinfo->height);
231 swapl(&modeinfo->dotClock);
232 swaps(&modeinfo->hSyncStart);
233 swaps(&modeinfo->hSyncEnd);
234 swaps(&modeinfo->hTotal);
235 swaps(&modeinfo->vSyncStart);
236 swaps(&modeinfo->vSyncEnd);
237 swaps(&modeinfo->vTotal);
238 swaps(&modeinfo->nameLength);
239 swapl(&modeinfo->modeFlags);
240 return (*ProcRandrVector[stuff->randrReqType]) (client);
241}
242
243static int
244SProcRRDestroyMode(ClientPtr client)
245{
246 REQUEST(xRRDestroyModeReq);
247
248 REQUEST_SIZE_MATCH(xRRDestroyModeReq);
249 swaps(&stuff->length);
250 swapl(&stuff->mode);
251 return (*ProcRandrVector[stuff->randrReqType]) (client);
252}
253
254static int
255SProcRRAddOutputMode(ClientPtr client)
256{
257 REQUEST(xRRAddOutputModeReq);
258
259 REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
260 swaps(&stuff->length);
261 swapl(&stuff->output);
262 swapl(&stuff->mode);
263 return (*ProcRandrVector[stuff->randrReqType]) (client);
264}
265
266static int
267SProcRRDeleteOutputMode(ClientPtr client)
268{
269 REQUEST(xRRDeleteOutputModeReq);
270
271 REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
272 swaps(&stuff->length);
273 swapl(&stuff->output);
274 swapl(&stuff->mode);
275 return (*ProcRandrVector[stuff->randrReqType]) (client);
276}
277
278static int
279SProcRRGetCrtcInfo(ClientPtr client)
280{
281 REQUEST(xRRGetCrtcInfoReq);
282
283 REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
284 swaps(&stuff->length);
285 swapl(&stuff->crtc);
286 swapl(&stuff->configTimestamp);
287 return (*ProcRandrVector[stuff->randrReqType]) (client);
288}
289
290static int
291SProcRRSetCrtcConfig(ClientPtr client)
292{
293 REQUEST(xRRSetCrtcConfigReq);
294
295 REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
296 swaps(&stuff->length);
297 swapl(&stuff->crtc);
298 swapl(&stuff->timestamp);
299 swapl(&stuff->configTimestamp);
300 swaps(&stuff->x);
301 swaps(&stuff->y);
302 swapl(&stuff->mode);
303 swaps(&stuff->rotation);
304 SwapRestL(stuff);
305 return (*ProcRandrVector[stuff->randrReqType]) (client);
306}
307
308static int
309SProcRRGetCrtcGammaSize(ClientPtr client)
310{
311 REQUEST(xRRGetCrtcGammaSizeReq);
312
313 REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
314 swaps(&stuff->length);
315 swapl(&stuff->crtc);
316 return (*ProcRandrVector[stuff->randrReqType]) (client);
317}
318
319static int
320SProcRRGetCrtcGamma(ClientPtr client)
321{
322 REQUEST(xRRGetCrtcGammaReq);
323
324 REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
325 swaps(&stuff->length);
326 swapl(&stuff->crtc);
327 return (*ProcRandrVector[stuff->randrReqType]) (client);
328}
329
330static int
331SProcRRSetCrtcGamma(ClientPtr client)
332{
333 REQUEST(xRRSetCrtcGammaReq);
334
335 REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
336 swaps(&stuff->length);
337 swapl(&stuff->crtc);
338 swaps(&stuff->size);
339 SwapRestS(stuff);
340 return (*ProcRandrVector[stuff->randrReqType]) (client);
341}
342
343static int
344SProcRRSetCrtcTransform(ClientPtr client)
345{
346 int nparams;
347 char *filter;
348 CARD32 *params;
349
350 REQUEST(xRRSetCrtcTransformReq);
351
352 REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
353 swaps(&stuff->length);
354 swapl(&stuff->crtc);
355 SwapLongs((CARD32 *) &stuff->transform,
356 bytes_to_int32(sizeof(xRenderTransform)));
357 swaps(&stuff->nbytesFilter);
358 filter = (char *) (stuff + 1);
359 params = (CARD32 *) (filter + pad_to_int32(stuff->nbytesFilter));
360 nparams = ((CARD32 *) stuff + client->req_len) - params;
361 if (nparams < 0)
362 return BadLength;
363
364 SwapLongs(params, nparams);
365 return (*ProcRandrVector[stuff->randrReqType]) (client);
366}
367
368static int
369SProcRRGetCrtcTransform(ClientPtr client)
370{
371 REQUEST(xRRGetCrtcTransformReq);
372
373 REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq);
374 swaps(&stuff->length);
375 swapl(&stuff->crtc);
376 return (*ProcRandrVector[stuff->randrReqType]) (client);
377}
378
379static int
380SProcRRGetPanning(ClientPtr client)
381{
382 REQUEST(xRRGetPanningReq);
383
384 REQUEST_SIZE_MATCH(xRRGetPanningReq);
385 swaps(&stuff->length);
386 swapl(&stuff->crtc);
387 return (*ProcRandrVector[stuff->randrReqType]) (client);
388}
389
390static int
391SProcRRSetPanning(ClientPtr client)
392{
393 REQUEST(xRRSetPanningReq);
394
395 REQUEST_SIZE_MATCH(xRRSetPanningReq);
396 swaps(&stuff->length);
397 swapl(&stuff->crtc);
398 swapl(&stuff->timestamp);
399 swaps(&stuff->left);
400 swaps(&stuff->top);
401 swaps(&stuff->width);
402 swaps(&stuff->height);
403 swaps(&stuff->track_left);
404 swaps(&stuff->track_top);
405 swaps(&stuff->track_width);
406 swaps(&stuff->track_height);
407 swaps(&stuff->border_left);
408 swaps(&stuff->border_top);
409 swaps(&stuff->border_right);
410 swaps(&stuff->border_bottom);
411 return (*ProcRandrVector[stuff->randrReqType]) (client);
412}
413
414static int
415SProcRRSetOutputPrimary(ClientPtr client)
416{
417 REQUEST(xRRSetOutputPrimaryReq);
418
419 REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
420 swaps(&stuff->length);
421 swapl(&stuff->window);
422 swapl(&stuff->output);
423 return ProcRandrVector[stuff->randrReqType] (client);
424}
425
426static int
427SProcRRGetOutputPrimary(ClientPtr client)
428{
429 REQUEST(xRRGetOutputPrimaryReq);
430
431 REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
432 swaps(&stuff->length);
433 swapl(&stuff->window);
434 return ProcRandrVector[stuff->randrReqType] (client);
435}
436
437int (*SProcRandrVector[RRNumberRequests]) (ClientPtr) = {
438 SProcRRQueryVersion, /* 0 */
439/* we skip 1 to make old clients fail pretty immediately */
440 NULL, /* 1 SProcRandrOldGetScreenInfo */
441/* V1.0 apps share the same set screen config request id */
442 SProcRRSetScreenConfig, /* 2 */
443 NULL, /* 3 SProcRandrOldScreenChangeSelectInput */
444/* 3 used to be ScreenChangeSelectInput; deprecated */
445 SProcRRSelectInput, /* 4 */
446 SProcRRGetScreenInfo, /* 5 */
447/* V1.2 additions */
448 SProcRRGetScreenSizeRange, /* 6 */
449 SProcRRSetScreenSize, /* 7 */
450 SProcRRGetScreenResources, /* 8 */
451 SProcRRGetOutputInfo, /* 9 */
452 SProcRRListOutputProperties, /* 10 */
453 SProcRRQueryOutputProperty, /* 11 */
454 SProcRRConfigureOutputProperty, /* 12 */
455 SProcRRChangeOutputProperty, /* 13 */
456 SProcRRDeleteOutputProperty, /* 14 */
457 SProcRRGetOutputProperty, /* 15 */
458 SProcRRCreateMode, /* 16 */
459 SProcRRDestroyMode, /* 17 */
460 SProcRRAddOutputMode, /* 18 */
461 SProcRRDeleteOutputMode, /* 19 */
462 SProcRRGetCrtcInfo, /* 20 */
463 SProcRRSetCrtcConfig, /* 21 */
464 SProcRRGetCrtcGammaSize, /* 22 */
465 SProcRRGetCrtcGamma, /* 23 */
466 SProcRRSetCrtcGamma, /* 24 */
467/* V1.3 additions */
468 SProcRRGetScreenResources, /* 25 GetScreenResourcesCurrent */
469 SProcRRSetCrtcTransform, /* 26 */
470 SProcRRGetCrtcTransform, /* 27 */
471 SProcRRGetPanning, /* 28 */
472 SProcRRSetPanning, /* 29 */
473 SProcRRSetOutputPrimary, /* 30 */
474 SProcRRGetOutputPrimary, /* 31 */
475};