00001 /* 00002 * Copyright (c) 2008 NVIDIA, Corporation 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice (including the next 00012 * paragraph) shall be included in all copies or substantial portions of the 00013 * Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00021 * SOFTWARE. 00022 */ 00023 00024 #ifndef __NVCTRLLIB_H 00025 #define __NVCTRLLIB_H 00026 00027 #include "NVCtrl.h" 00028 00029 #if defined __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 /* 00034 * XNVCTRLQueryExtension - 00035 * 00036 * Returns True if the extension exists, returns False otherwise. 00037 * event_basep and error_basep are the extension event and error 00038 * bases. Currently, no extension specific errors or events are 00039 * defined. 00040 */ 00041 00042 Bool XNVCTRLQueryExtension ( 00043 Display *dpy, 00044 int *event_basep, 00045 int *error_basep 00046 ); 00047 00048 00049 /* 00050 * XNVCTRLQueryVersion - 00051 * 00052 * Returns True if the extension exists, returns False otherwise. 00053 * major and minor are the extension's major and minor version 00054 * numbers. 00055 */ 00056 00057 Bool XNVCTRLQueryVersion ( 00058 Display *dpy, 00059 int *major, 00060 int *minor 00061 ); 00062 00063 00064 /* 00065 * XNVCTRLIsNvScreen 00066 * 00067 * Returns True is the specified screen is controlled by the NVIDIA 00068 * driver. Returns False otherwise. 00069 */ 00070 00071 Bool XNVCTRLIsNvScreen ( 00072 Display *dpy, 00073 int screen 00074 ); 00075 00076 00077 /* 00078 * XNVCTRLQueryTargetCount - 00079 * 00080 * Returns True if the target type exists. Returns False otherwise. 00081 * If XNVCTRLQueryTargetCount returns True, value will contain the 00082 * count of existing targets on the server of the specified target 00083 * type. 00084 * 00085 * Please see "Attribute Targets" in NVCtrl.h for the list of valid 00086 * target types. 00087 * 00088 * Possible errors: 00089 * BadValue - The target doesn't exist. 00090 */ 00091 00092 Bool XNVCTRLQueryTargetCount ( 00093 Display *dpy, 00094 int target_type, 00095 int *value 00096 ); 00097 00098 00099 /* 00100 * XNVCTRLSetAttribute - 00101 * 00102 * Sets the attribute to the given value. The attributes and their 00103 * possible values are listed in NVCtrl.h. 00104 * 00105 * Not all attributes require the display_mask parameter; see 00106 * NVCtrl.h for details. 00107 * 00108 * Calling this function is equivalent to calling XNVCTRLSetTargetAttribute() 00109 * with the target_type set to NV_CTRL_TARGET_TYPE_X_SCREEN and 00110 * target_id set to 'screen'. 00111 * 00112 * Possible errors: 00113 * BadValue - The screen or attribute doesn't exist. 00114 * BadMatch - The NVIDIA driver is not present on that screen. 00115 */ 00116 00117 void XNVCTRLSetAttribute ( 00118 Display *dpy, 00119 int screen, 00120 unsigned int display_mask, 00121 unsigned int attribute, 00122 int value 00123 ); 00124 00125 00126 /* 00127 * XNVCTRLSetTargetAttribute - 00128 * 00129 * Sets the attribute to the given value. The attributes and their 00130 * possible values are listed in NVCtrl.h. 00131 * 00132 * Not all attributes require the display_mask parameter; see 00133 * NVCtrl.h for details. 00134 * 00135 * Possible errors: 00136 * BadValue - The target or attribute doesn't exist. 00137 * BadMatch - The NVIDIA driver is not present on that target. 00138 */ 00139 00140 void XNVCTRLSetTargetAttribute ( 00141 Display *dpy, 00142 int target_type, 00143 int target_id, 00144 unsigned int display_mask, 00145 unsigned int attribute, 00146 int value 00147 ); 00148 00149 00150 /* 00151 * XNVCTRLSetAttributeAndGetStatus - 00152 * 00153 * Same as XNVCTRLSetAttribute(). 00154 * In addition, XNVCTRLSetAttributeAndGetStatus() returns 00155 * True if the operation succeeds, False otherwise. 00156 * 00157 */ 00158 00159 Bool XNVCTRLSetAttributeAndGetStatus ( 00160 Display *dpy, 00161 int screen, 00162 unsigned int display_mask, 00163 unsigned int attribute, 00164 int value 00165 ); 00166 00167 00168 /* 00169 * XNVCTRLQueryAttribute - 00170 * 00171 * Returns True if the attribute exists. Returns False otherwise. 00172 * If XNVCTRLQueryAttribute returns True, value will contain the 00173 * value of the specified attribute. 00174 * 00175 * Not all attributes require the display_mask parameter; see 00176 * NVCtrl.h for details. 00177 * 00178 * Calling this function is equivalent to calling 00179 * XNVCTRLQueryTargetAttribute() with the target_type set to 00180 * NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'. 00181 * 00182 * Possible errors: 00183 * BadValue - The screen doesn't exist. 00184 * BadMatch - The NVIDIA driver is not present on that screen. 00185 */ 00186 00187 Bool XNVCTRLQueryAttribute ( 00188 Display *dpy, 00189 int screen, 00190 unsigned int display_mask, 00191 unsigned int attribute, 00192 int *value 00193 ); 00194 00195 00196 /* 00197 * XNVCTRLQueryTargetAttribute - 00198 * 00199 * Returns True if the attribute exists. Returns False otherwise. 00200 * If XNVCTRLQueryTargetAttribute returns True, value will contain the 00201 * value of the specified attribute. 00202 * 00203 * Not all attributes require the display_mask parameter; see 00204 * NVCtrl.h for details. 00205 * 00206 * Possible errors: 00207 * BadValue - The target doesn't exist. 00208 * BadMatch - The NVIDIA driver does not control the target. 00209 */ 00210 00211 Bool XNVCTRLQueryTargetAttribute ( 00212 Display *dpy, 00213 int target_Type, 00214 int target_id, 00215 unsigned int display_mask, 00216 unsigned int attribute, 00217 int *value 00218 ); 00219 00220 00221 /* 00222 * XNVCTRLQueryStringAttribute - 00223 * 00224 * Returns True if the attribute exists. Returns False otherwise. 00225 * If XNVCTRLQueryStringAttribute returns True, *ptr will point to an 00226 * allocated string containing the string attribute requested. It is 00227 * the caller's responsibility to free the string when done. 00228 * 00229 * Calling this function is equivalent to calling 00230 * XNVCTRLQueryTargetStringAttribute() with the target_type set to 00231 * NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'. 00232 * 00233 * Possible errors: 00234 * BadValue - The screen doesn't exist. 00235 * BadMatch - The NVIDIA driver is not present on that screen. 00236 * BadAlloc - Insufficient resources to fulfill the request. 00237 */ 00238 00239 Bool XNVCTRLQueryStringAttribute ( 00240 Display *dpy, 00241 int screen, 00242 unsigned int display_mask, 00243 unsigned int attribute, 00244 char **ptr 00245 ); 00246 00247 00248 /* 00249 * XNVCTRLQueryTargetStringAttribute - 00250 * 00251 * Returns True if the attribute exists. Returns False otherwise. 00252 * If XNVCTRLQueryTargetStringAttribute returns True, *ptr will point 00253 * to an allocated string containing the string attribute requested. 00254 * It is the caller's responsibility to free the string when done. 00255 * 00256 * Possible errors: 00257 * BadValue - The target doesn't exist. 00258 * BadMatch - The NVIDIA driver does not control the target. 00259 * BadAlloc - Insufficient resources to fulfill the request. 00260 */ 00261 00262 Bool XNVCTRLQueryTargetStringAttribute ( 00263 Display *dpy, 00264 int target_type, 00265 int target_id, 00266 unsigned int display_mask, 00267 unsigned int attribute, 00268 char **ptr 00269 ); 00270 00271 00272 /* 00273 * XNVCTRLSetStringAttribute - 00274 * 00275 * Returns True if the operation succeded. Returns False otherwise. 00276 * 00277 * Possible X errors: 00278 * BadValue - The screen doesn't exist. 00279 * BadMatch - The NVIDIA driver is not present on that screen. 00280 * BadAlloc - Insufficient resources to fulfill the request. 00281 */ 00282 00283 Bool XNVCTRLSetStringAttribute ( 00284 Display *dpy, 00285 int screen, 00286 unsigned int display_mask, 00287 unsigned int attribute, 00288 char *ptr 00289 ); 00290 00291 00292 /* 00293 * XNVCTRLQueryValidAttributeValues - 00294 * 00295 * Returns True if the attribute exists. Returns False otherwise. If 00296 * XNVCTRLQueryValidAttributeValues returns True, values will indicate 00297 * the valid values for the specified attribute; see the description 00298 * of NVCTRLAttributeValidValues in NVCtrl.h. 00299 * 00300 * Calling this function is equivalent to calling 00301 * XNVCTRLQueryValidTargetAttributeValues() with the target_type set to 00302 * NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'. 00303 */ 00304 00305 Bool XNVCTRLQueryValidAttributeValues ( 00306 Display *dpy, 00307 int screen, 00308 unsigned int display_mask, 00309 unsigned int attribute, 00310 NVCTRLAttributeValidValuesRec *values 00311 ); 00312 00313 00314 00315 /* 00316 * XNVCTRLQueryValidTargetAttributeValues - 00317 * 00318 * Returns True if the attribute exists. Returns False otherwise. If 00319 * XNVCTRLQueryValidTargetAttributeValues returns True, values will indicate 00320 * the valid values for the specified attribute. 00321 */ 00322 00323 Bool XNVCTRLQueryValidTargetAttributeValues ( 00324 Display *dpy, 00325 int target_type, 00326 int target_id, 00327 unsigned int display_mask, 00328 unsigned int attribute, 00329 NVCTRLAttributeValidValuesRec *values 00330 ); 00331 00332 00333 /* 00334 * XNVCTRLSetGvoColorConversion - 00335 * 00336 * Sets the color conversion matrix, offset, and scale that should be 00337 * used for GVO (Graphic to Video Out). 00338 * 00339 * The Color Space Conversion data is ordered like this: 00340 * 00341 * colorMatrix[0][0] // r.Y 00342 * colorMatrix[0][1] // g.Y 00343 * colorMatrix[0][2] // b.Y 00344 * 00345 * colorMatrix[1][0] // r.Cr 00346 * colorMatrix[1][1] // g.Cr 00347 * colorMatrix[1][2] // b.Cr 00348 * 00349 * colorMatrix[2][0] // r.Cb 00350 * colorMatrix[2][1] // g.Cb 00351 * colorMatrix[2][2] // b.Cb 00352 * 00353 * colorOffset[0] // Y 00354 * colorOffset[1] // Cr 00355 * colorOffset[2] // Cb 00356 * 00357 * colorScale[0] // Y 00358 * colorScale[1] // Cr 00359 * colorScale[2] // Cb 00360 * 00361 * where the data is used according to the following formulae: 00362 * 00363 * Y = colorOffset[0] + colorScale[0] * 00364 * (R * colorMatrix[0][0] + 00365 * G * colorMatrix[0][1] + 00366 * B * colorMatrix[0][2]); 00367 * 00368 * Cr = colorOffset[1] + colorScale[1] * 00369 * (R * colorMatrix[1][0] + 00370 * G * colorMatrix[1][1] + 00371 * B * colorMatrix[1][2]); 00372 * 00373 * Cb = colorOffset[2] + colorScale[2] * 00374 * (R * colorMatrix[2][0] + 00375 * G * colorMatrix[2][1] + 00376 * B * colorMatrix[2][2]); 00377 * 00378 * Possible errors: 00379 * BadMatch - The NVIDIA driver is not present on that screen. 00380 * BadImplementation - GVO is not available on that screen. 00381 */ 00382 00383 void XNVCTRLSetGvoColorConversion ( 00384 Display *dpy, 00385 int screen, 00386 float colorMatrix[3][3], 00387 float colorOffset[3], 00388 float colorScale[3] 00389 ); 00390 00391 00392 00393 /* 00394 * XNVCTRLQueryGvoColorConversion - 00395 * 00396 * Retrieves the color conversion matrix and color offset 00397 * that are currently being used for GVO (Graphic to Video Out). 00398 * 00399 * The values are ordered within the arrays according to the comments 00400 * for XNVCTRLSetGvoColorConversion(). 00401 * 00402 * Possible errors: 00403 * BadMatch - The NVIDIA driver is not present on that screen. 00404 * BadImplementation - GVO is not available on that screen. 00405 */ 00406 00407 Bool XNVCTRLQueryGvoColorConversion ( 00408 Display *dpy, 00409 int screen, 00410 float colorMatrix[3][3], 00411 float colorOffset[3], 00412 float colorScale[3] 00413 ); 00414 00415 00416 /* 00417 * XNVCTRLQueryBinaryData - 00418 * 00419 * Returns True if the attribute exists. Returns False otherwise. 00420 * If XNVCTRLQueryBinaryData returns True, *ptr will point to an 00421 * allocated block of memory containing the binary data attribute 00422 * requested. It is the caller's responsibility to free the data 00423 * when done. len will list the length of the binary data. 00424 * 00425 * Calling this function is equivalent to calling 00426 * XNVCTRLQueryTargetBinaryData() with the target_type set to 00427 * NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'. 00428 * 00429 * Possible errors: 00430 * BadValue - The screen doesn't exist. 00431 * BadMatch - The NVIDIA driver is not present on that screen. 00432 * BadAlloc - Insufficient resources to fulfill the request. 00433 */ 00434 00435 Bool XNVCTRLQueryBinaryData ( 00436 Display *dpy, 00437 int screen, 00438 unsigned int display_mask, 00439 unsigned int attribute, 00440 unsigned char **ptr, 00441 int *len 00442 ); 00443 00444 00445 /* 00446 * XNVCTRLQueryTargetBinaryData - 00447 * 00448 * Returns True if the attribute exists. Returns False otherwise. 00449 * If XNVCTRLQueryTargetBinaryData returns True, *ptr will point to an 00450 * allocated block of memory containing the binary data attribute 00451 * requested. It is the caller's responsibility to free the data 00452 * when done. len will list the length of the binary data. 00453 * 00454 * Possible errors: 00455 * BadValue - The target doesn't exist. 00456 * BadMatch - The NVIDIA driver does not control the target. 00457 * BadAlloc - Insufficient resources to fulfill the request. 00458 */ 00459 00460 Bool XNVCTRLQueryTargetBinaryData ( 00461 Display *dpy, 00462 int target_type, 00463 int target_id, 00464 unsigned int display_mask, 00465 unsigned int attribute, 00466 unsigned char **ptr, 00467 int *len 00468 ); 00469 00470 00471 /* 00472 * XNVCTRLStringOperation - 00473 * 00474 * Takes a string as input and returns a Xmalloc'ed string as output. 00475 * Returns True on success and False on failure. 00476 */ 00477 00478 Bool XNVCTRLStringOperation ( 00479 Display *dpy, 00480 int target_type, 00481 int target_id, 00482 unsigned int display_mask, 00483 unsigned int attribute, 00484 char *pIn, 00485 char **ppOut 00486 ); 00487 00488 00489 00490 /* 00491 * XNVCtrlSelectNotify - 00492 * 00493 * This enables/disables receiving of NV-CONTROL events. The type 00494 * specifies the type of event to enable (currently, the only 00495 * type that can be requested per-screen with XNVCtrlSelectNotify() 00496 * is ATTRIBUTE_CHANGED_EVENT); onoff controls whether receiving this 00497 * type of event should be enabled (True) or disabled (False). 00498 * 00499 * Returns True if successful, or False if the screen is not 00500 * controlled by the NVIDIA driver. 00501 */ 00502 00503 Bool XNVCtrlSelectNotify ( 00504 Display *dpy, 00505 int screen, 00506 int type, 00507 Bool onoff 00508 ); 00509 00510 00511 /* 00512 * XNVCtrlSelectTargetNotify - 00513 * 00514 * This enables/disables receiving of NV-CONTROL events that happen on 00515 * the specified target. The notify_type specifies the type of event to 00516 * enable (currently, the only type that can be requested per-target with 00517 * XNVCtrlSelectTargetNotify() is TARGET_ATTRIBUTE_CHANGED_EVENT); onoff 00518 * controls whether receiving this type of event should be enabled (True) 00519 * or disabled (False). 00520 * 00521 * Returns True if successful, or False if the target is not 00522 * controlled by the NVIDIA driver. 00523 */ 00524 00525 Bool XNVCtrlSelectTargetNotify ( 00526 Display *dpy, 00527 int target_type, 00528 int target_id, 00529 int notify_type, 00530 Bool onoff 00531 ); 00532 00533 00534 /* 00535 * XNVCtrlEvent structure 00536 */ 00537 00538 typedef struct { 00539 int type; 00540 unsigned long serial; 00541 Bool send_event; /* always FALSE, we don't allow send_events */ 00542 Display *display; 00543 Time time; 00544 int screen; 00545 unsigned int display_mask; 00546 unsigned int attribute; 00547 int value; 00548 } XNVCtrlAttributeChangedEvent; 00549 00550 typedef union { 00551 int type; 00552 XNVCtrlAttributeChangedEvent attribute_changed; 00553 long pad[24]; 00554 } XNVCtrlEvent; 00555 00556 00557 /* 00558 * XNVCtrlEventTarget structure 00559 */ 00560 00561 typedef struct { 00562 int type; 00563 unsigned long serial; 00564 Bool send_event; /* always FALSE, we don't allow send_events */ 00565 Display *display; 00566 Time time; 00567 int target_type; 00568 int target_id; 00569 unsigned int display_mask; 00570 unsigned int attribute; 00571 int value; 00572 } XNVCtrlAttributeChangedEventTarget; 00573 00574 typedef union { 00575 int type; 00576 XNVCtrlAttributeChangedEventTarget attribute_changed; 00577 long pad[24]; 00578 } XNVCtrlEventTarget; 00579 00580 00581 /* 00582 * XNVCtrlEventTargetAvailability structure 00583 */ 00584 00585 typedef struct { 00586 int type; 00587 unsigned long serial; 00588 Bool send_event; /* always FALSE, we don't allow send_events */ 00589 Display *display; 00590 Time time; 00591 int target_type; 00592 int target_id; 00593 unsigned int display_mask; 00594 unsigned int attribute; 00595 int value; 00596 Bool availability; 00597 } XNVCtrlAttributeChangedEventTargetAvailability; 00598 00599 typedef union { 00600 int type; 00601 XNVCtrlAttributeChangedEventTargetAvailability attribute_changed; 00602 long pad[24]; 00603 } XNVCtrlEventTargetAvailability; 00604 00605 00606 /* 00607 * XNVCtrlStringEventTarget structure 00608 */ 00609 00610 typedef struct { 00611 int type; 00612 unsigned long serial; 00613 Bool send_event; /* always FALSE, we don't allow send_events */ 00614 Display *display; 00615 Time time; 00616 int target_type; 00617 int target_id; 00618 unsigned int display_mask; 00619 unsigned int attribute; 00620 } XNVCtrlStringAttributeChangedEventTarget; 00621 00622 typedef union { 00623 int type; 00624 XNVCtrlStringAttributeChangedEventTarget attribute_changed; 00625 long pad[24]; 00626 } XNVCtrlStringEventTarget; 00627 00628 00629 00630 /* 00631 * XNVCtrlBinaryEventTarget structure 00632 */ 00633 00634 typedef struct { 00635 int type; 00636 unsigned long serial; 00637 Bool send_event; /* always FALSE, we don't allow send_events */ 00638 Display *display; 00639 Time time; 00640 int target_type; 00641 int target_id; 00642 unsigned int display_mask; 00643 unsigned int attribute; 00644 } XNVCtrlBinaryAttributeChangedEventTarget; 00645 00646 typedef union { 00647 int type; 00648 XNVCtrlBinaryAttributeChangedEventTarget attribute_changed; 00649 long pad[24]; 00650 } XNVCtrlBinaryEventTarget; 00651 00652 #if defined __cplusplus 00653 } /* extern "C" */ 00654 #endif 00655 00656 #endif /* __NVCTRLLIB_H */
1.6.3