1 /* 2 * Copyright (c) 2008 NVIDIA, Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 * 23 * 24 * NV-CONTROL Protocol Version History 25 * 26 * 1.0 - 1.5 NVIDIA Internal development versions 27 * 1.6 Initial public version 28 * 1.7 Added QueryBinaryData request 29 * 1.8 Added TargetTypes 30 * 1.9 Added QueryTargetCount request 31 * 1.10 Fixed target type/id byte ordering for compatibility with 32 * pre-1.8 NV-CONTROL clients 33 * 1.11 NVIDIA Internal development version 34 * 1.12 Added StringOperation request 35 * 1.13 NVIDIA Internal development version 36 * 1.14 Fixed an NV_CTRL_BINARY_DATA_MODELINES double scan modeline 37 * reporting bug (vsyncstart, vsyncend, and vtotal were incorrectly 38 * doubled) 39 * 1.15 Added AVAILABILITY_TARGET_ATTRIBUTE_CHANGED_EVENT 40 * 1.16 Added TARGET_STRING_ATTRIBUTE_CHANGED_EVENT 41 * 1.17 Added TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT 42 * 1.18 Updated QueryTargetCount to return a count of 0, rather than 43 * BadMatch, if an unknown TargetType is specified 44 * 1.19 Added TargetType support for SetAttributeAndGetStatus and 45 * SetStringAttribute requests 46 * 1.20 Added COOLER TargetType 47 * 1.21 Added initial 64-bit integer attribute support (read-only) 48 * 1.22 Added X_nvCtrlQueryValidStringAttributeValues to check 49 * string attribute permissions. 50 * 1.23 Added SENSOR TargetType 51 * 1.24 Fixed a bug where SLI_MOSAIC_MODE_AVAILABLE attribute would 52 * report false positives via the GPU and X screen target types 53 * 1.25 Added 3D_VISION_PRO_TRANSCEIVER TargetType 54 * 1.26 Added XNVCTRLQueryXXXAttributePermissions. 55 * 1.27 Added DISPLAY TargetType 56 * 1.28 Added NV_CTRL_CURRENT_METAMODE_ID: clients should use this 57 * attribute to switch MetaModes, rather than pass the MetaMode ID 58 * through the RRSetScreenConfig protocol request. 59 */ 60 61 #ifndef __NVCONTROL_H 62 #define __NVCONTROL_H 63 64 #define NV_CONTROL_ERRORS 0 65 #define NV_CONTROL_EVENTS 5 66 #define NV_CONTROL_NAME "NV-CONTROL" 67 68 #define NV_CONTROL_MAJOR 1 69 #define NV_CONTROL_MINOR 28 70 71 #define X_nvCtrlQueryExtension 0 72 #define X_nvCtrlIsNv 1 73 #define X_nvCtrlQueryAttribute 2 74 #define X_nvCtrlSetAttribute 3 75 #define X_nvCtrlQueryStringAttribute 4 76 #define X_nvCtrlQueryValidAttributeValues 5 77 #define X_nvCtrlSelectNotify 6 78 #define X_nvCtrlSetGvoColorConversionDeprecated 7 79 #define X_nvCtrlQueryGvoColorConversionDeprecated 8 80 #define X_nvCtrlSetStringAttribute 9 81 /* STUB X_nvCtrlQueryDDCCILutSize 10 */ 82 /* STUB X_nvCtrlQueryDDCCISinglePointLutOperation 11 */ 83 /* STUB X_nvCtrlSetDDCCISinglePointLutOperation 12 */ 84 /* STUB X_nvCtrlQueryDDCCIBlockLutOperation 13 */ 85 /* STUB X_nvCtrlSetDDCCIBlockLutOperation 14 */ 86 /* STUB X_nvCtrlSetDDCCIRemoteProcedureCall 15 */ 87 /* STUB X_nvCtrlQueryDDCCIDisplayControllerType 16 */ 88 /* STUB X_nvCtrlQueryDDCCICapabilities 17 */ 89 /* STUB X_nvCtrlQueryDDCCITimingReport 18 */ 90 #define X_nvCtrlSetAttributeAndGetStatus 19 91 #define X_nvCtrlQueryBinaryData 20 92 #define X_nvCtrlSetGvoColorConversion 21 93 #define X_nvCtrlQueryGvoColorConversion 22 94 #define X_nvCtrlSelectTargetNotify 23 95 #define X_nvCtrlQueryTargetCount 24 96 #define X_nvCtrlStringOperation 25 97 #define X_nvCtrlQueryValidAttributeValues64 26 98 #define X_nvCtrlQueryAttribute64 27 99 #define X_nvCtrlQueryValidStringAttributeValues 28 100 #define X_nvCtrlQueryAttributePermissions 29 101 #define X_nvCtrlQueryStringAttributePermissions 30 102 #define X_nvCtrlQueryBinaryDataAttributePermissions 31 103 #define X_nvCtrlQueryStringOperationAttributePermissions 32 104 105 #define X_nvCtrlLastRequest (X_nvCtrlQueryStringOperationAttributePermissions + 1) 106 107 /* Define 32 bit floats */ 108 typedef float FLOAT32; 109 #ifndef F32 110 # define F32 111 #endif 112 113 typedef struct 114 { 115 CARD8 reqType; 116 CARD8 nvReqType; 117 CARD16 length B16; 118 } xnvCtrlQueryExtensionReq; 119 #define sz_xnvCtrlQueryExtensionReq 4 120 121 typedef struct 122 { 123 BYTE type; /* X_Reply */ 124 CARD8 padb1; 125 CARD16 sequenceNumber B16; 126 CARD32 length B32; 127 CARD16 major B16; 128 CARD16 minor B16; 129 CARD32 padl4 B32; 130 CARD32 padl5 B32; 131 CARD32 padl6 B32; 132 CARD32 padl7 B32; 133 CARD32 padl8 B32; 134 } xnvCtrlQueryExtensionReply; 135 #define sz_xnvCtrlQueryExtensionReply 32 136 137 typedef struct 138 { 139 CARD8 reqType; 140 CARD8 nvReqType; 141 CARD16 length B16; 142 CARD32 screen B32; 143 } xnvCtrlIsNvReq; 144 #define sz_xnvCtrlIsNvReq 8 145 146 typedef struct 147 { 148 BYTE type; /* X_Reply */ 149 CARD8 padb1; 150 CARD16 sequenceNumber B16; 151 CARD32 length B32; 152 CARD32 isnv B32; 153 CARD32 padl4 B32; 154 CARD32 padl5 B32; 155 CARD32 padl6 B32; 156 CARD32 padl7 B32; 157 CARD32 padl8 B32; 158 } xnvCtrlIsNvReply; 159 #define sz_xnvCtrlIsNvReply 32 160 161 typedef struct 162 { 163 CARD8 reqType; 164 CARD8 nvReqType; 165 CARD16 length B16; 166 CARD32 target_type B32; 167 } xnvCtrlQueryTargetCountReq; 168 #define sz_xnvCtrlQueryTargetCountReq 8 169 170 typedef struct 171 { 172 BYTE type; /* X_Reply */ 173 CARD8 padb1; 174 CARD16 sequenceNumber B16; 175 CARD32 length B32; 176 CARD32 count B32; 177 CARD32 padl4 B32; 178 CARD32 padl5 B32; 179 CARD32 padl6 B32; 180 CARD32 padl7 B32; 181 CARD32 padl8 B32; 182 } xnvCtrlQueryTargetCountReply; 183 #define sz_xnvCtrlQueryTargetCountReply 32 184 185 typedef struct 186 { 187 CARD8 reqType; 188 CARD8 nvReqType; 189 CARD16 length B16; 190 CARD16 target_id B16; /* X screen number or GPU number */ 191 CARD16 target_type B16; /* X screen or GPU */ 192 CARD32 display_mask B32; 193 CARD32 attribute B32; 194 } xnvCtrlQueryAttributeReq; 195 #define sz_xnvCtrlQueryAttributeReq 16 196 197 typedef struct 198 { 199 BYTE type; 200 BYTE pad0; 201 CARD16 sequenceNumber B16; 202 CARD32 length B32; 203 CARD32 flags B32; 204 INT32 value B32; 205 CARD32 pad4 B32; 206 CARD32 pad5 B32; 207 CARD32 pad6 B32; 208 CARD32 pad7 B32; 209 } xnvCtrlQueryAttributeReply; 210 #define sz_xnvCtrlQueryAttributeReply 32 211 212 typedef struct 213 { 214 BYTE type; 215 BYTE pad0; 216 CARD16 sequenceNumber B16; 217 CARD32 length B32; 218 CARD32 flags B32; 219 CARD32 pad3 B32; 220 int64_t value_64; 221 CARD32 pad6 B32; 222 CARD32 pad7 B32; 223 } xnvCtrlQueryAttribute64Reply; 224 #define sz_xnvCtrlQueryAttribute64Reply 32 225 226 typedef struct 227 { 228 CARD8 reqType; 229 CARD8 nvReqType; 230 CARD16 length B16; 231 CARD16 target_id B16; 232 CARD16 target_type B16; 233 CARD32 display_mask B32; 234 CARD32 attribute B32; 235 INT32 value B32; 236 } xnvCtrlSetAttributeReq; 237 #define sz_xnvCtrlSetAttributeReq 20 238 239 typedef struct 240 { 241 CARD8 reqType; 242 CARD8 nvReqType; 243 CARD16 length B16; 244 CARD16 target_id B16; 245 CARD16 target_type B16; 246 CARD32 display_mask B32; 247 CARD32 attribute B32; 248 INT32 value B32; 249 } xnvCtrlSetAttributeAndGetStatusReq; 250 #define sz_xnvCtrlSetAttributeAndGetStatusReq 20 251 252 typedef struct 253 { 254 BYTE type; 255 BYTE pad0; 256 CARD16 sequenceNumber B16; 257 CARD32 length B32; 258 CARD32 flags B32; 259 CARD32 pad3 B32; 260 CARD32 pad4 B32; 261 CARD32 pad5 B32; 262 CARD32 pad6 B32; 263 CARD32 pad7 B32; 264 } xnvCtrlSetAttributeAndGetStatusReply; 265 #define sz_xnvCtrlSetAttributeAndGetStatusReply 32 266 267 typedef struct 268 { 269 CARD8 reqType; 270 CARD8 nvReqType; 271 CARD16 length B16; 272 CARD16 target_id B16; /* X screen number or GPU number */ 273 CARD16 target_type B16; /* X screen or GPU */ 274 CARD32 display_mask B32; 275 CARD32 attribute B32; 276 } xnvCtrlQueryStringAttributeReq; 277 #define sz_xnvCtrlQueryStringAttributeReq 16 278 279 typedef struct 280 { 281 BYTE type; 282 BYTE pad0; 283 CARD16 sequenceNumber B16; 284 CARD32 length B32; 285 CARD32 flags B32; 286 CARD32 n B32; /* Length of string */ 287 CARD32 pad4 B32; 288 CARD32 pad5 B32; 289 CARD32 pad6 B32; 290 CARD32 pad7 B32; 291 } xnvCtrlQueryStringAttributeReply; 292 #define sz_xnvCtrlQueryStringAttributeReply 32 293 294 typedef struct 295 { 296 CARD8 reqType; 297 CARD8 nvReqType; 298 CARD16 length B16; 299 CARD16 target_id B16; 300 CARD16 target_type B16; 301 CARD32 display_mask B32; 302 CARD32 attribute B32; 303 CARD32 num_bytes B32; 304 } xnvCtrlSetStringAttributeReq; 305 #define sz_xnvCtrlSetStringAttributeReq 20 306 307 typedef struct 308 { 309 BYTE type; 310 BYTE pad0; 311 CARD16 sequenceNumber B16; 312 CARD32 length B32; 313 CARD32 flags B32; 314 CARD32 pad3 B32; 315 CARD32 pad4 B32; 316 CARD32 pad5 B32; 317 CARD32 pad6 B32; 318 CARD32 pad7 B32; 319 } xnvCtrlSetStringAttributeReply; 320 #define sz_xnvCtrlSetStringAttributeReply 32 321 322 typedef struct 323 { 324 CARD8 reqType; 325 CARD8 nvReqType; 326 CARD16 length B16; 327 CARD16 target_id B16; /* X screen number or GPU number */ 328 CARD16 target_type B16; /* X screen or GPU */ 329 CARD32 display_mask B32; 330 CARD32 attribute B32; 331 } xnvCtrlQueryValidAttributeValuesReq; 332 #define sz_xnvCtrlQueryValidAttributeValuesReq 16 333 334 typedef struct 335 { 336 BYTE type; 337 BYTE pad0; 338 CARD16 sequenceNumber B16; 339 CARD32 length B32; 340 CARD32 flags B32; 341 INT32 attr_type B32; 342 INT32 min B32; 343 INT32 max B32; 344 CARD32 bits B32; 345 CARD32 perms B32; 346 } xnvCtrlQueryValidAttributeValuesReply; 347 #define sz_xnvCtrlQueryValidAttributeValuesReply 32 348 349 typedef struct 350 { 351 BYTE type; 352 BYTE pad0; 353 CARD16 sequenceNumber B16; 354 CARD32 length B32; 355 CARD32 flags B32; 356 INT32 attr_type B32; 357 int64_t min_64; 358 int64_t max_64; 359 CARD64 bits_64; 360 CARD32 perms B32; 361 CARD32 pad1 B32; 362 } xnvCtrlQueryValidAttributeValues64Reply; 363 #define sz_xnvCtrlQueryValidAttributeValues64Reply 48 364 #define sz_xnvCtrlQueryValidAttributeValues64Reply_extra ((48 - 32) >> 2) 365 366 typedef struct 367 { 368 CARD8 reqType; 369 CARD8 nvReqType; 370 CARD16 length B16; 371 CARD32 attribute B32; 372 } xnvCtrlQueryAttributePermissionsReq; 373 #define sz_xnvCtrlQueryAttributePermissionsReq 8 374 375 typedef struct 376 { 377 BYTE type; 378 BYTE pad0; 379 CARD16 sequenceNumber B16; 380 CARD32 length B32; 381 CARD32 flags B32; 382 INT32 attr_type B32; 383 CARD32 perms B32; 384 CARD32 pad5 B32; 385 CARD32 pad6 B32; 386 CARD32 pad7 B32; 387 CARD32 pad8 B32; 388 } xnvCtrlQueryAttributePermissionsReply; 389 #define sz_xnvCtrlQueryAttributePermissionsReply 32 390 391 /* Set GVO Color Conversion request (deprecated) */ 392 typedef struct 393 { 394 CARD8 reqType; 395 CARD8 nvReqType; 396 CARD16 length B16; 397 CARD32 screen B32; 398 FLOAT32 row1_col1 F32; 399 FLOAT32 row1_col2 F32; 400 FLOAT32 row1_col3 F32; 401 FLOAT32 row1_col4 F32; 402 FLOAT32 row2_col1 F32; 403 FLOAT32 row2_col2 F32; 404 FLOAT32 row2_col3 F32; 405 FLOAT32 row2_col4 F32; 406 FLOAT32 row3_col1 F32; 407 FLOAT32 row3_col2 F32; 408 FLOAT32 row3_col3 F32; 409 FLOAT32 row3_col4 F32; 410 } xnvCtrlSetGvoColorConversionDeprecatedReq; 411 #define sz_xnvCtrlSetGvoColorConversionDeprecatedReq 56 412 413 /* Query GVO Color Conversion request (deprecated) */ 414 typedef struct 415 { 416 CARD8 reqType; 417 CARD8 nvReqType; 418 CARD16 length B16; 419 CARD32 screen B32; 420 } xnvCtrlQueryGvoColorConversionDeprecatedReq; 421 #define sz_xnvCtrlQueryGvoColorConversionDeprecatedReq 8 422 423 /* Query GVO Color Conversion reply (deprecated) */ 424 typedef struct 425 { 426 BYTE type; /* X_Reply */ 427 BYTE pad0; 428 CARD16 sequenceNumber B16; 429 CARD32 length B32; 430 CARD32 pad3 B32; 431 CARD32 pad4 B32; 432 CARD32 pad5 B32; 433 CARD32 pad6 B32; 434 CARD32 pad7 B32; 435 CARD32 pad8 B32; 436 } xnvCtrlQueryGvoColorConversionDeprecatedReply; 437 #define sz_xnvCtrlQueryGvoColorConversionDeprecatedReply 32 438 439 /* Set GVO Color Conversion request */ 440 typedef struct 441 { 442 CARD8 reqType; 443 CARD8 nvReqType; 444 CARD16 length B16; 445 CARD32 screen B32; 446 447 FLOAT32 cscMatrix_y_r F32; 448 FLOAT32 cscMatrix_y_g F32; 449 FLOAT32 cscMatrix_y_b F32; 450 451 FLOAT32 cscMatrix_cr_r F32; 452 FLOAT32 cscMatrix_cr_g F32; 453 FLOAT32 cscMatrix_cr_b F32; 454 455 FLOAT32 cscMatrix_cb_r F32; 456 FLOAT32 cscMatrix_cb_g F32; 457 FLOAT32 cscMatrix_cb_b F32; 458 459 FLOAT32 cscOffset_y F32; 460 FLOAT32 cscOffset_cr F32; 461 FLOAT32 cscOffset_cb F32; 462 463 FLOAT32 cscScale_y F32; 464 FLOAT32 cscScale_cr F32; 465 FLOAT32 cscScale_cb F32; 466 467 } xnvCtrlSetGvoColorConversionReq; 468 #define sz_xnvCtrlSetGvoColorConversionReq 68 469 470 /* Query GVO Color Conversion request */ 471 typedef struct 472 { 473 CARD8 reqType; 474 CARD8 nvReqType; 475 CARD16 length B16; 476 CARD32 screen B32; 477 } xnvCtrlQueryGvoColorConversionReq; 478 #define sz_xnvCtrlQueryGvoColorConversionReq 8 479 480 /* Query GVO Color Conversion reply */ 481 typedef struct 482 { 483 BYTE type; /* X_Reply */ 484 BYTE pad0; 485 CARD16 sequenceNumber B16; 486 CARD32 length B32; 487 CARD32 pad3 B32; 488 CARD32 pad4 B32; 489 CARD32 pad5 B32; 490 CARD32 pad6 B32; 491 CARD32 pad7 B32; 492 CARD32 pad8 B32; 493 } xnvCtrlQueryGvoColorConversionReply; 494 #define sz_xnvCtrlQueryGvoColorConversionReply 32 495 496 typedef struct 497 { 498 CARD8 reqType; 499 CARD8 nvReqType; 500 CARD16 length B16; 501 CARD16 target_id B16; /* X screen number or GPU number */ 502 CARD16 target_type B16; /* X screen or GPU */ 503 CARD32 display_mask B32; 504 CARD32 attribute B32; 505 } xnvCtrlQueryBinaryDataReq; 506 #define sz_xnvCtrlQueryBinaryDataReq 16 507 508 typedef struct 509 { 510 BYTE type; 511 BYTE pad0; 512 CARD16 sequenceNumber B16; 513 CARD32 length B32; 514 CARD32 flags B32; 515 CARD32 n B32; 516 CARD32 pad4 B32; 517 CARD32 pad5 B32; 518 CARD32 pad6 B32; 519 CARD32 pad7 B32; 520 } xnvCtrlQueryBinaryDataReply; 521 #define sz_xnvCtrlQueryBinaryDataReply 32 522 523 typedef struct 524 { 525 CARD8 reqType; 526 CARD8 nvReqType; 527 CARD16 length B16; 528 CARD32 screen B32; 529 CARD16 notifyType B16; 530 CARD16 onoff B16; 531 } xnvCtrlSelectNotifyReq; 532 #define sz_xnvCtrlSelectNotifyReq 12 533 534 typedef struct 535 { 536 CARD8 reqType; 537 CARD8 nvReqType; 538 CARD16 length B16; 539 CARD16 target_id B16; /* X screen number or GPU number */ 540 CARD16 target_type B16; /* X screen or GPU */ 541 CARD32 display_mask B32; 542 CARD32 attribute B32; 543 CARD32 num_bytes B32; /* Length of string */ 544 } xnvCtrlStringOperationReq; 545 #define sz_xnvCtrlStringOperationReq 20 546 547 typedef struct 548 { 549 BYTE type; /* X_Reply */ 550 CARD8 padb1; 551 CARD16 sequenceNumber B16; 552 CARD32 length B32; 553 CARD32 ret B32; 554 CARD32 num_bytes B32; /* Length of string */ 555 CARD32 padl4 B32; 556 CARD32 padl5 B32; 557 CARD32 padl6 B32; 558 CARD32 padl7 B32; 559 } xnvCtrlStringOperationReply; 560 #define sz_xnvCtrlStringOperationReply 32 561 562 typedef struct 563 { 564 union 565 { 566 struct 567 { 568 BYTE type; 569 BYTE detail; 570 CARD16 sequenceNumber B16; 571 } u; 572 struct 573 { 574 BYTE type; 575 BYTE detail; 576 CARD16 sequenceNumber B16; 577 CARD32 time B32; 578 CARD32 screen B32; 579 CARD32 display_mask B32; 580 CARD32 attribute B32; 581 CARD32 value B32; 582 CARD32 pad0 B32; 583 CARD32 pad1 B32; 584 } attribute_changed; 585 } u; 586 } xnvctrlEvent; 587 588 /* 589 * Leave target_type before target_id for the 590 * xnvCtrlSelectTargetNotifyReq and xnvctrlEventTarget 591 * structures, even though other request protocol structures 592 * store target_id in the bottom 16-bits of the second DWORD of the 593 * structures. The event-related structures were added in version 594 * 1.8, and so there is no prior version with which to maintain 595 * compatibility. 596 */ 597 typedef struct 598 { 599 CARD8 reqType; 600 CARD8 nvReqType; 601 CARD16 length B16; 602 CARD16 target_type B16; /* Don't swap these */ 603 CARD16 target_id B16; 604 CARD16 notifyType B16; 605 CARD16 onoff B16; 606 } xnvCtrlSelectTargetNotifyReq; 607 #define sz_xnvCtrlSelectTargetNotifyReq 12 608 609 typedef struct 610 { 611 union 612 { 613 struct 614 { 615 BYTE type; 616 BYTE detail; 617 CARD16 sequenceNumber B16; 618 } u; 619 struct 620 { 621 BYTE type; 622 BYTE detail; 623 CARD16 sequenceNumber B16; 624 CARD32 time B32; 625 CARD16 target_type B16; /* Don't swap these */ 626 CARD16 target_id B16; 627 CARD32 display_mask B32; 628 CARD32 attribute B32; 629 CARD32 value B32; 630 CARD32 pad0 B32; 631 CARD32 pad1 B32; 632 } attribute_changed; 633 struct 634 { 635 BYTE type; 636 BYTE detail; 637 CARD16 sequenceNumber B16; 638 CARD32 time B32; 639 CARD16 target_type B16; /* Don't swap these */ 640 CARD16 target_id B16; 641 CARD32 display_mask B32; 642 CARD32 attribute B32; 643 CARD32 value B32; 644 CARD8 availability; 645 CARD8 pad0; 646 CARD16 pad1 B16; 647 CARD32 pad2 B32; 648 } availability_changed; 649 } u; 650 } xnvctrlEventTarget; 651 652 #endif /* __NVCONTROL_H */ 653