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 108 /* Define 32 bit floats */ 109 typedef float FLOAT32; 110 #ifndef F32 111 #define F32 112 #endif 113 114 115 typedef struct { 116 CARD8 reqType; 117 CARD8 nvReqType; 118 CARD16 length B16; 119 } xnvCtrlQueryExtensionReq; 120 #define sz_xnvCtrlQueryExtensionReq 4 121 122 typedef struct { 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 CARD8 reqType; 139 CARD8 nvReqType; 140 CARD16 length B16; 141 CARD32 screen B32; 142 } xnvCtrlIsNvReq; 143 #define sz_xnvCtrlIsNvReq 8 144 145 typedef struct { 146 BYTE type; /* X_Reply */ 147 CARD8 padb1; 148 CARD16 sequenceNumber B16; 149 CARD32 length B32; 150 CARD32 isnv B32; 151 CARD32 padl4 B32; 152 CARD32 padl5 B32; 153 CARD32 padl6 B32; 154 CARD32 padl7 B32; 155 CARD32 padl8 B32; 156 } xnvCtrlIsNvReply; 157 #define sz_xnvCtrlIsNvReply 32 158 159 typedef struct { 160 CARD8 reqType; 161 CARD8 nvReqType; 162 CARD16 length B16; 163 CARD32 target_type B32; 164 } xnvCtrlQueryTargetCountReq; 165 #define sz_xnvCtrlQueryTargetCountReq 8 166 167 typedef struct { 168 BYTE type; /* X_Reply */ 169 CARD8 padb1; 170 CARD16 sequenceNumber B16; 171 CARD32 length B32; 172 CARD32 count B32; 173 CARD32 padl4 B32; 174 CARD32 padl5 B32; 175 CARD32 padl6 B32; 176 CARD32 padl7 B32; 177 CARD32 padl8 B32; 178 } xnvCtrlQueryTargetCountReply; 179 #define sz_xnvCtrlQueryTargetCountReply 32 180 181 typedef struct { 182 CARD8 reqType; 183 CARD8 nvReqType; 184 CARD16 length B16; 185 CARD16 target_id B16; /* X screen number or GPU number */ 186 CARD16 target_type B16; /* X screen or GPU */ 187 CARD32 display_mask B32; 188 CARD32 attribute B32; 189 } xnvCtrlQueryAttributeReq; 190 #define sz_xnvCtrlQueryAttributeReq 16 191 192 typedef struct { 193 BYTE type; 194 BYTE pad0; 195 CARD16 sequenceNumber B16; 196 CARD32 length B32; 197 CARD32 flags B32; 198 INT32 value B32; 199 CARD32 pad4 B32; 200 CARD32 pad5 B32; 201 CARD32 pad6 B32; 202 CARD32 pad7 B32; 203 } xnvCtrlQueryAttributeReply; 204 #define sz_xnvCtrlQueryAttributeReply 32 205 206 typedef struct { 207 BYTE type; 208 BYTE pad0; 209 CARD16 sequenceNumber B16; 210 CARD32 length B32; 211 CARD32 flags B32; 212 CARD32 pad3 B32; 213 int64_t value_64; 214 CARD32 pad6 B32; 215 CARD32 pad7 B32; 216 } xnvCtrlQueryAttribute64Reply; 217 #define sz_xnvCtrlQueryAttribute64Reply 32 218 219 typedef struct { 220 CARD8 reqType; 221 CARD8 nvReqType; 222 CARD16 length B16; 223 CARD16 target_id B16; 224 CARD16 target_type B16; 225 CARD32 display_mask B32; 226 CARD32 attribute B32; 227 INT32 value B32; 228 } xnvCtrlSetAttributeReq; 229 #define sz_xnvCtrlSetAttributeReq 20 230 231 typedef struct { 232 CARD8 reqType; 233 CARD8 nvReqType; 234 CARD16 length B16; 235 CARD16 target_id B16; 236 CARD16 target_type B16; 237 CARD32 display_mask B32; 238 CARD32 attribute B32; 239 INT32 value B32; 240 } xnvCtrlSetAttributeAndGetStatusReq; 241 #define sz_xnvCtrlSetAttributeAndGetStatusReq 20 242 243 typedef struct { 244 BYTE type; 245 BYTE pad0; 246 CARD16 sequenceNumber B16; 247 CARD32 length B32; 248 CARD32 flags B32; 249 CARD32 pad3 B32; 250 CARD32 pad4 B32; 251 CARD32 pad5 B32; 252 CARD32 pad6 B32; 253 CARD32 pad7 B32; 254 } xnvCtrlSetAttributeAndGetStatusReply; 255 #define sz_xnvCtrlSetAttributeAndGetStatusReply 32 256 257 typedef struct { 258 CARD8 reqType; 259 CARD8 nvReqType; 260 CARD16 length B16; 261 CARD16 target_id B16; /* X screen number or GPU number */ 262 CARD16 target_type B16; /* X screen or GPU */ 263 CARD32 display_mask B32; 264 CARD32 attribute B32; 265 } xnvCtrlQueryStringAttributeReq; 266 #define sz_xnvCtrlQueryStringAttributeReq 16 267 268 typedef struct { 269 BYTE type; 270 BYTE pad0; 271 CARD16 sequenceNumber B16; 272 CARD32 length B32; 273 CARD32 flags B32; 274 CARD32 n B32; /* Length of string */ 275 CARD32 pad4 B32; 276 CARD32 pad5 B32; 277 CARD32 pad6 B32; 278 CARD32 pad7 B32; 279 } xnvCtrlQueryStringAttributeReply; 280 #define sz_xnvCtrlQueryStringAttributeReply 32 281 282 283 typedef struct { 284 CARD8 reqType; 285 CARD8 nvReqType; 286 CARD16 length B16; 287 CARD16 target_id B16; 288 CARD16 target_type B16; 289 CARD32 display_mask B32; 290 CARD32 attribute B32; 291 CARD32 num_bytes B32; 292 } xnvCtrlSetStringAttributeReq; 293 #define sz_xnvCtrlSetStringAttributeReq 20 294 295 typedef struct { 296 BYTE type; 297 BYTE pad0; 298 CARD16 sequenceNumber B16; 299 CARD32 length B32; 300 CARD32 flags B32; 301 CARD32 pad3 B32; 302 CARD32 pad4 B32; 303 CARD32 pad5 B32; 304 CARD32 pad6 B32; 305 CARD32 pad7 B32; 306 } xnvCtrlSetStringAttributeReply; 307 #define sz_xnvCtrlSetStringAttributeReply 32 308 309 typedef struct { 310 CARD8 reqType; 311 CARD8 nvReqType; 312 CARD16 length B16; 313 CARD16 target_id B16; /* X screen number or GPU number */ 314 CARD16 target_type B16; /* X screen or GPU */ 315 CARD32 display_mask B32; 316 CARD32 attribute B32; 317 } xnvCtrlQueryValidAttributeValuesReq; 318 #define sz_xnvCtrlQueryValidAttributeValuesReq 16 319 320 typedef struct { 321 BYTE type; 322 BYTE pad0; 323 CARD16 sequenceNumber B16; 324 CARD32 length B32; 325 CARD32 flags B32; 326 INT32 attr_type B32; 327 INT32 min B32; 328 INT32 max B32; 329 CARD32 bits B32; 330 CARD32 perms B32; 331 } xnvCtrlQueryValidAttributeValuesReply; 332 #define sz_xnvCtrlQueryValidAttributeValuesReply 32 333 334 typedef struct { 335 BYTE type; 336 BYTE pad0; 337 CARD16 sequenceNumber B16; 338 CARD32 length B32; 339 CARD32 flags B32; 340 INT32 attr_type B32; 341 int64_t min_64; 342 int64_t max_64; 343 CARD64 bits_64; 344 CARD32 perms B32; 345 CARD32 pad1 B32; 346 } xnvCtrlQueryValidAttributeValues64Reply; 347 #define sz_xnvCtrlQueryValidAttributeValues64Reply 48 348 #define sz_xnvCtrlQueryValidAttributeValues64Reply_extra ((48 - 32) >> 2) 349 350 typedef struct { 351 CARD8 reqType; 352 CARD8 nvReqType; 353 CARD16 length B16; 354 CARD32 attribute B32; 355 } xnvCtrlQueryAttributePermissionsReq; 356 #define sz_xnvCtrlQueryAttributePermissionsReq 8 357 358 typedef struct { 359 BYTE type; 360 BYTE pad0; 361 CARD16 sequenceNumber B16; 362 CARD32 length B32; 363 CARD32 flags B32; 364 INT32 attr_type B32; 365 CARD32 perms B32; 366 CARD32 pad5 B32; 367 CARD32 pad6 B32; 368 CARD32 pad7 B32; 369 CARD32 pad8 B32; 370 } xnvCtrlQueryAttributePermissionsReply; 371 #define sz_xnvCtrlQueryAttributePermissionsReply 32 372 373 /* Set GVO Color Conversion request (deprecated) */ 374 typedef struct { 375 CARD8 reqType; 376 CARD8 nvReqType; 377 CARD16 length B16; 378 CARD32 screen B32; 379 FLOAT32 row1_col1 F32; 380 FLOAT32 row1_col2 F32; 381 FLOAT32 row1_col3 F32; 382 FLOAT32 row1_col4 F32; 383 FLOAT32 row2_col1 F32; 384 FLOAT32 row2_col2 F32; 385 FLOAT32 row2_col3 F32; 386 FLOAT32 row2_col4 F32; 387 FLOAT32 row3_col1 F32; 388 FLOAT32 row3_col2 F32; 389 FLOAT32 row3_col3 F32; 390 FLOAT32 row3_col4 F32; 391 } xnvCtrlSetGvoColorConversionDeprecatedReq; 392 #define sz_xnvCtrlSetGvoColorConversionDeprecatedReq 56 393 394 /* Query GVO Color Conversion request (deprecated) */ 395 typedef struct { 396 CARD8 reqType; 397 CARD8 nvReqType; 398 CARD16 length B16; 399 CARD32 screen B32; 400 } xnvCtrlQueryGvoColorConversionDeprecatedReq; 401 #define sz_xnvCtrlQueryGvoColorConversionDeprecatedReq 8 402 403 /* Query GVO Color Conversion reply (deprecated) */ 404 typedef struct { 405 BYTE type; /* X_Reply */ 406 BYTE pad0; 407 CARD16 sequenceNumber B16; 408 CARD32 length B32; 409 CARD32 pad3 B32; 410 CARD32 pad4 B32; 411 CARD32 pad5 B32; 412 CARD32 pad6 B32; 413 CARD32 pad7 B32; 414 CARD32 pad8 B32; 415 } xnvCtrlQueryGvoColorConversionDeprecatedReply; 416 #define sz_xnvCtrlQueryGvoColorConversionDeprecatedReply 32 417 418 419 /* Set GVO Color Conversion request */ 420 typedef struct { 421 CARD8 reqType; 422 CARD8 nvReqType; 423 CARD16 length B16; 424 CARD32 screen B32; 425 426 FLOAT32 cscMatrix_y_r F32; 427 FLOAT32 cscMatrix_y_g F32; 428 FLOAT32 cscMatrix_y_b F32; 429 430 FLOAT32 cscMatrix_cr_r F32; 431 FLOAT32 cscMatrix_cr_g F32; 432 FLOAT32 cscMatrix_cr_b F32; 433 434 FLOAT32 cscMatrix_cb_r F32; 435 FLOAT32 cscMatrix_cb_g F32; 436 FLOAT32 cscMatrix_cb_b F32; 437 438 FLOAT32 cscOffset_y F32; 439 FLOAT32 cscOffset_cr F32; 440 FLOAT32 cscOffset_cb F32; 441 442 FLOAT32 cscScale_y F32; 443 FLOAT32 cscScale_cr F32; 444 FLOAT32 cscScale_cb F32; 445 446 } xnvCtrlSetGvoColorConversionReq; 447 #define sz_xnvCtrlSetGvoColorConversionReq 68 448 449 /* Query GVO Color Conversion request */ 450 typedef struct { 451 CARD8 reqType; 452 CARD8 nvReqType; 453 CARD16 length B16; 454 CARD32 screen B32; 455 } xnvCtrlQueryGvoColorConversionReq; 456 #define sz_xnvCtrlQueryGvoColorConversionReq 8 457 458 /* Query GVO Color Conversion reply */ 459 typedef struct { 460 BYTE type; /* X_Reply */ 461 BYTE pad0; 462 CARD16 sequenceNumber B16; 463 CARD32 length B32; 464 CARD32 pad3 B32; 465 CARD32 pad4 B32; 466 CARD32 pad5 B32; 467 CARD32 pad6 B32; 468 CARD32 pad7 B32; 469 CARD32 pad8 B32; 470 } xnvCtrlQueryGvoColorConversionReply; 471 #define sz_xnvCtrlQueryGvoColorConversionReply 32 472 473 typedef struct { 474 CARD8 reqType; 475 CARD8 nvReqType; 476 CARD16 length B16; 477 CARD16 target_id B16; /* X screen number or GPU number */ 478 CARD16 target_type B16; /* X screen or GPU */ 479 CARD32 display_mask B32; 480 CARD32 attribute B32; 481 } xnvCtrlQueryBinaryDataReq; 482 #define sz_xnvCtrlQueryBinaryDataReq 16 483 484 typedef struct { 485 BYTE type; 486 BYTE pad0; 487 CARD16 sequenceNumber B16; 488 CARD32 length B32; 489 CARD32 flags B32; 490 CARD32 n B32; 491 CARD32 pad4 B32; 492 CARD32 pad5 B32; 493 CARD32 pad6 B32; 494 CARD32 pad7 B32; 495 } xnvCtrlQueryBinaryDataReply; 496 #define sz_xnvCtrlQueryBinaryDataReply 32 497 498 499 typedef struct { 500 CARD8 reqType; 501 CARD8 nvReqType; 502 CARD16 length B16; 503 CARD32 screen B32; 504 CARD16 notifyType B16; 505 CARD16 onoff B16; 506 } xnvCtrlSelectNotifyReq; 507 #define sz_xnvCtrlSelectNotifyReq 12 508 509 typedef struct { 510 CARD8 reqType; 511 CARD8 nvReqType; 512 CARD16 length B16; 513 CARD16 target_id B16; /* X screen number or GPU number */ 514 CARD16 target_type B16; /* X screen or GPU */ 515 CARD32 display_mask B32; 516 CARD32 attribute B32; 517 CARD32 num_bytes B32; /* Length of string */ 518 } xnvCtrlStringOperationReq; 519 #define sz_xnvCtrlStringOperationReq 20 520 521 typedef struct { 522 BYTE type; /* X_Reply */ 523 CARD8 padb1; 524 CARD16 sequenceNumber B16; 525 CARD32 length B32; 526 CARD32 ret B32; 527 CARD32 num_bytes B32; /* Length of string */ 528 CARD32 padl4 B32; 529 CARD32 padl5 B32; 530 CARD32 padl6 B32; 531 CARD32 padl7 B32; 532 } xnvCtrlStringOperationReply; 533 #define sz_xnvCtrlStringOperationReply 32 534 535 typedef struct { 536 union { 537 struct { 538 BYTE type; 539 BYTE detail; 540 CARD16 sequenceNumber B16; 541 } u; 542 struct { 543 BYTE type; 544 BYTE detail; 545 CARD16 sequenceNumber B16; 546 CARD32 time B32; 547 CARD32 screen B32; 548 CARD32 display_mask B32; 549 CARD32 attribute B32; 550 CARD32 value B32; 551 CARD32 pad0 B32; 552 CARD32 pad1 B32; 553 } attribute_changed; 554 } u; 555 } xnvctrlEvent; 556 557 558 /* 559 * Leave target_type before target_id for the 560 * xnvCtrlSelectTargetNotifyReq and xnvctrlEventTarget 561 * structures, even though other request protocol structures 562 * store target_id in the bottom 16-bits of the second DWORD of the 563 * structures. The event-related structures were added in version 564 * 1.8, and so there is no prior version with which to maintain 565 * compatibility. 566 */ 567 typedef struct { 568 CARD8 reqType; 569 CARD8 nvReqType; 570 CARD16 length B16; 571 CARD16 target_type B16; /* Don't swap these */ 572 CARD16 target_id B16; 573 CARD16 notifyType B16; 574 CARD16 onoff B16; 575 } xnvCtrlSelectTargetNotifyReq; 576 #define sz_xnvCtrlSelectTargetNotifyReq 12 577 578 typedef struct { 579 union { 580 struct { 581 BYTE type; 582 BYTE detail; 583 CARD16 sequenceNumber B16; 584 } u; 585 struct { 586 BYTE type; 587 BYTE detail; 588 CARD16 sequenceNumber B16; 589 CARD32 time B32; 590 CARD16 target_type B16; /* Don't swap these */ 591 CARD16 target_id B16; 592 CARD32 display_mask B32; 593 CARD32 attribute B32; 594 CARD32 value B32; 595 CARD32 pad0 B32; 596 CARD32 pad1 B32; 597 } attribute_changed; 598 struct { 599 BYTE type; 600 BYTE detail; 601 CARD16 sequenceNumber B16; 602 CARD32 time B32; 603 CARD16 target_type B16; /* Don't swap these */ 604 CARD16 target_id B16; 605 CARD32 display_mask B32; 606 CARD32 attribute B32; 607 CARD32 value B32; 608 CARD8 availability; 609 CARD8 pad0; 610 CARD16 pad1 B16; 611 CARD32 pad2 B32; 612 } availability_changed; 613 } u; 614 } xnvctrlEventTarget; 615 616 617 #endif /* __NVCONTROL_H */ 618