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