Path: blob/main_old/src/third_party/libXNVCtrl/NVCtrlLib.h
1693 views
/*1* Copyright (c) 2008 NVIDIA, Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a copy4* of this software and associated documentation files (the "Software"), to deal5* in the Software without restriction, including without limitation the rights6* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell7* copies of the Software, and to permit persons to whom the Software is8* furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*/2223#ifndef __NVCTRLLIB_H24#define __NVCTRLLIB_H2526#include "NVCtrl.h"2728#if defined __cplusplus29extern "C" {30#endif3132/*33* XNVCTRLQueryExtension -34*35* Returns True if the extension exists, returns False otherwise.36* event_basep and error_basep are the extension event and error37* bases. Currently, no extension specific errors or events are38* defined.39*/4041Bool XNVCTRLQueryExtension(Display *dpy, int *event_basep, int *error_basep);4243/*44* XNVCTRLQueryVersion -45*46* Returns True if the extension exists, returns False otherwise.47* major and minor are the extension's major and minor version48* numbers.49*/5051Bool XNVCTRLQueryVersion(Display *dpy, int *major, int *minor);5253/*54* XNVCTRLIsNvScreen55*56* Returns True is the specified screen is controlled by the NVIDIA57* driver. Returns False otherwise.58*/5960Bool XNVCTRLIsNvScreen(Display *dpy, int screen);6162/*63* XNVCTRLQueryTargetCount -64*65* Returns True if the target type exists. Returns False otherwise.66* If XNVCTRLQueryTargetCount returns True, value will contain the67* count of existing targets on the server of the specified target68* type.69*70* Please see "Attribute Targets" in NVCtrl.h for the list of valid71* target types.72*73* Possible errors:74* BadValue - The target doesn't exist.75*/7677Bool XNVCTRLQueryTargetCount(Display *dpy, int target_type, int *value);7879/*80* XNVCTRLSetAttribute -81*82* Sets the attribute to the given value. The attributes and their83* possible values are listed in NVCtrl.h.84*85* Not all attributes require the display_mask parameter; see86* NVCtrl.h for details.87*88* Calling this function is equivalent to calling XNVCTRLSetTargetAttribute()89* with the target_type set to NV_CTRL_TARGET_TYPE_X_SCREEN and90* target_id set to 'screen'.91*92* Possible errors:93* BadValue - The screen or attribute doesn't exist.94* BadMatch - The NVIDIA driver is not present on that screen.95*/9697void XNVCTRLSetAttribute(Display *dpy,98int screen,99unsigned int display_mask,100unsigned int attribute,101int value);102103/*104* XNVCTRLSetTargetAttribute -105*106* Sets the attribute to the given value. The attributes and their107* possible values are listed in NVCtrl.h.108*109* Not all attributes require the display_mask parameter; see110* NVCtrl.h for details.111*112* Possible errors:113* BadValue - The target or attribute doesn't exist.114* BadMatch - The NVIDIA driver is not present on that target.115*/116117void XNVCTRLSetTargetAttribute(Display *dpy,118int target_type,119int target_id,120unsigned int display_mask,121unsigned int attribute,122int value);123124/*125* XNVCTRLSetAttributeAndGetStatus -126*127* Same as XNVCTRLSetAttribute().128* In addition, XNVCTRLSetAttributeAndGetStatus() returns129* True if the operation succeeds, False otherwise.130*131*/132133Bool XNVCTRLSetAttributeAndGetStatus(Display *dpy,134int screen,135unsigned int display_mask,136unsigned int attribute,137int value);138139/*140* XNVCTRLSetTargetAttributeAndGetStatus -141*142* Same as XNVCTRLSetTargetAttribute().143* In addition, XNVCTRLSetTargetAttributeAndGetStatus() returns144* True if the operation succeeds, False otherwise.145*146*/147148Bool XNVCTRLSetTargetAttributeAndGetStatus(Display *dpy,149int target_type,150int target_id,151unsigned int display_mask,152unsigned int attribute,153int value);154155/*156* XNVCTRLQueryAttribute -157*158* Returns True if the attribute exists. Returns False otherwise.159* If XNVCTRLQueryAttribute returns True, value will contain the160* value of the specified attribute.161*162* Not all attributes require the display_mask parameter; see163* NVCtrl.h for details.164*165* Calling this function is equivalent to calling166* XNVCTRLQueryTargetAttribute() with the target_type set to167* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.168*169* Possible errors:170* BadValue - The screen doesn't exist.171* BadMatch - The NVIDIA driver is not present on that screen.172*/173174Bool XNVCTRLQueryAttribute(Display *dpy,175int screen,176unsigned int display_mask,177unsigned int attribute,178int *value);179180/*181* XNVCTRLQueryTargetAttribute -182*183* Returns True if the attribute exists. Returns False otherwise.184* If XNVCTRLQueryTargetAttribute returns True, value will contain the185* value of the specified attribute.186*187* Not all attributes require the display_mask parameter; see188* NVCtrl.h for details.189*190* Possible errors:191* BadValue - The target doesn't exist.192* BadMatch - The NVIDIA driver does not control the target.193*/194195Bool XNVCTRLQueryTargetAttribute(Display *dpy,196int target_Type,197int target_id,198unsigned int display_mask,199unsigned int attribute,200int *value);201202/*203* XNVCTRLQueryTargetAttribute64 -204*205* Returns True if the attribute exists. Returns False otherwise.206* If XNVCTRLQueryTargetAttribute returns True, value will contain the207* value of the specified attribute.208*209* Not all attributes require the display_mask parameter; see210* NVCtrl.h for details.211*212* Note: this function behaves like XNVCTRLQueryTargetAttribute(),213* but supports 64-bit integer attributes.214*215* Possible errors:216* BadValue - The target doesn't exist.217* BadMatch - The NVIDIA driver does not control the target.218*/219220Bool XNVCTRLQueryTargetAttribute64(Display *dpy,221int target_Type,222int target_id,223unsigned int display_mask,224unsigned int attribute,225int64_t *value);226227/*228* XNVCTRLQueryStringAttribute -229*230* Returns True if the attribute exists. Returns False otherwise.231* If XNVCTRLQueryStringAttribute returns True, *ptr will point to an232* allocated string containing the string attribute requested. It is233* the caller's responsibility to free the string when done.234*235* Calling this function is equivalent to calling236* XNVCTRLQueryTargetStringAttribute() with the target_type set to237* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.238*239* Possible errors:240* BadValue - The screen doesn't exist.241* BadMatch - The NVIDIA driver is not present on that screen.242* BadAlloc - Insufficient resources to fulfill the request.243*/244245Bool XNVCTRLQueryStringAttribute(Display *dpy,246int screen,247unsigned int display_mask,248unsigned int attribute,249char **ptr);250251/*252* XNVCTRLQueryTargetStringAttribute -253*254* Returns True if the attribute exists. Returns False otherwise.255* If XNVCTRLQueryTargetStringAttribute returns True, *ptr will point256* to an allocated string containing the string attribute requested.257* It is the caller's responsibility to free the string when done.258*259* Possible errors:260* BadValue - The target doesn't exist.261* BadMatch - The NVIDIA driver does not control the target.262* BadAlloc - Insufficient resources to fulfill the request.263*/264265Bool XNVCTRLQueryTargetStringAttribute(Display *dpy,266int target_type,267int target_id,268unsigned int display_mask,269unsigned int attribute,270char **ptr);271272/*273* XNVCTRLSetStringAttribute -274*275* Returns True if the operation succeded. Returns False otherwise.276*277* Possible X errors:278* BadValue - The screen doesn't exist.279* BadMatch - The NVIDIA driver is not present on that screen.280* BadAlloc - Insufficient resources to fulfill the request.281*/282283Bool XNVCTRLSetStringAttribute(Display *dpy,284int screen,285unsigned int display_mask,286unsigned int attribute,287char *ptr);288289/*290* XNVCTRLSetTargetStringAttribute -291*292* Returns True if the operation succeded. Returns False otherwise.293*294* Possible X errors:295* BadValue - The screen doesn't exist.296* BadMatch - The NVIDIA driver is not present on that screen.297* BadAlloc - Insufficient resources to fulfill the request.298*/299300Bool XNVCTRLSetTargetStringAttribute(Display *dpy,301int target_type,302int target_id,303unsigned int display_mask,304unsigned int attribute,305char *ptr);306307/*308* XNVCTRLQueryValidAttributeValues -309*310* Returns True if the attribute exists. Returns False otherwise. If311* XNVCTRLQueryValidAttributeValues returns True, values will indicate312* the valid values for the specified attribute; see the description313* of NVCTRLAttributeValidValues in NVCtrl.h.314*315* Calling this function is equivalent to calling316* XNVCTRLQueryValidTargetAttributeValues() with the target_type set to317* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.318*/319320Bool XNVCTRLQueryValidAttributeValues(Display *dpy,321int screen,322unsigned int display_mask,323unsigned int attribute,324NVCTRLAttributeValidValuesRec *values);325326/*327* XNVCTRLQueryValidTargetAttributeValues -328*329* Returns True if the attribute exists. Returns False otherwise. If330* XNVCTRLQueryValidTargetAttributeValues returns True, values will indicate331* the valid values for the specified attribute.332*/333334Bool XNVCTRLQueryValidTargetAttributeValues(Display *dpy,335int target_type,336int target_id,337unsigned int display_mask,338unsigned int attribute,339NVCTRLAttributeValidValuesRec *values);340341/*342* XNVCTRLQueryValidTargetStringAttributeValues -343*344* Returns True if the attribute exists. Returns False otherwise. If345* XNVCTRLQueryValidTargetStringAttributeValues returns True, values will346* indicate the valid values for the specified attribute.347*/348349Bool XNVCTRLQueryValidTargetStringAttributeValues(Display *dpy,350int target_type,351int target_id,352unsigned int display_mask,353unsigned int attribute,354NVCTRLAttributeValidValuesRec *values);355356/*357* XNVCTRLQueryAttributePermissions -358*359* Returns True if the attribute exists. Returns False otherwise. If360* XNVCTRLQueryAttributePermissions returns True, permissions will361* indicate the permission flags for the attribute.362*/363364Bool XNVCTRLQueryAttributePermissions(Display *dpy,365unsigned int attribute,366NVCTRLAttributePermissionsRec *permissions);367368/*369* XNVCTRLQueryStringAttributePermissions -370*371* Returns True if the attribute exists. Returns False otherwise. If372* XNVCTRLQueryStringAttributePermissions returns True, permissions will373* indicate the permission flags for the attribute.374*/375376Bool XNVCTRLQueryStringAttributePermissions(Display *dpy,377unsigned int attribute,378NVCTRLAttributePermissionsRec *permissions);379380/*381* XNVCTRLQueryBinaryDataAttributePermissions -382*383* Returns True if the attribute exists. Returns False otherwise. If384* XNVCTRLQueryBinaryDataAttributePermissions returns True, permissions385* will indicate the permission flags for the attribute.386*/387388Bool XNVCTRLQueryBinaryDataAttributePermissions(Display *dpy,389unsigned int attribute,390NVCTRLAttributePermissionsRec *permissions);391392/*393* XNVCTRLQueryStringOperationAttributePermissions -394*395* Returns True if the attribute exists. Returns False otherwise. If396* XNVCTRLQueryStringOperationAttributePermissions returns True,397* permissions will indicate the permission flags for the attribute.398*/399400Bool XNVCTRLQueryStringOperationAttributePermissions(Display *dpy,401unsigned int attribute,402NVCTRLAttributePermissionsRec *permissions);403404/*405* XNVCTRLSetGvoColorConversion -406*407* Sets the color conversion matrix, offset, and scale that should be408* used for GVO (Graphic to Video Out).409*410* The Color Space Conversion data is ordered like this:411*412* colorMatrix[0][0] // r.Y413* colorMatrix[0][1] // g.Y414* colorMatrix[0][2] // b.Y415*416* colorMatrix[1][0] // r.Cr417* colorMatrix[1][1] // g.Cr418* colorMatrix[1][2] // b.Cr419*420* colorMatrix[2][0] // r.Cb421* colorMatrix[2][1] // g.Cb422* colorMatrix[2][2] // b.Cb423*424* colorOffset[0] // Y425* colorOffset[1] // Cr426* colorOffset[2] // Cb427*428* colorScale[0] // Y429* colorScale[1] // Cr430* colorScale[2] // Cb431*432* where the data is used according to the following formulae:433*434* Y = colorOffset[0] + colorScale[0] *435* (R * colorMatrix[0][0] +436* G * colorMatrix[0][1] +437* B * colorMatrix[0][2]);438*439* Cr = colorOffset[1] + colorScale[1] *440* (R * colorMatrix[1][0] +441* G * colorMatrix[1][1] +442* B * colorMatrix[1][2]);443*444* Cb = colorOffset[2] + colorScale[2] *445* (R * colorMatrix[2][0] +446* G * colorMatrix[2][1] +447* B * colorMatrix[2][2]);448*449* Possible errors:450* BadMatch - The NVIDIA driver is not present on that screen.451* BadImplementation - GVO is not available on that screen.452*/453454void XNVCTRLSetGvoColorConversion(Display *dpy,455int screen,456float colorMatrix[3][3],457float colorOffset[3],458float colorScale[3]);459460/*461* XNVCTRLQueryGvoColorConversion -462*463* Retrieves the color conversion matrix and color offset464* that are currently being used for GVO (Graphic to Video Out).465*466* The values are ordered within the arrays according to the comments467* for XNVCTRLSetGvoColorConversion().468*469* Possible errors:470* BadMatch - The NVIDIA driver is not present on that screen.471* BadImplementation - GVO is not available on that screen.472*/473474Bool XNVCTRLQueryGvoColorConversion(Display *dpy,475int screen,476float colorMatrix[3][3],477float colorOffset[3],478float colorScale[3]);479480/*481* XNVCTRLQueryBinaryData -482*483* Returns True if the attribute exists. Returns False otherwise.484* If XNVCTRLQueryBinaryData returns True, *ptr will point to an485* allocated block of memory containing the binary data attribute486* requested. It is the caller's responsibility to free the data487* when done. len will list the length of the binary data.488*489* Calling this function is equivalent to calling490* XNVCTRLQueryTargetBinaryData() with the target_type set to491* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.492*493* Possible errors:494* BadValue - The screen doesn't exist.495* BadMatch - The NVIDIA driver is not present on that screen.496* BadAlloc - Insufficient resources to fulfill the request.497*/498499Bool XNVCTRLQueryBinaryData(Display *dpy,500int screen,501unsigned int display_mask,502unsigned int attribute,503unsigned char **ptr,504int *len);505506/*507* XNVCTRLQueryTargetBinaryData -508*509* Returns True if the attribute exists. Returns False otherwise.510* If XNVCTRLQueryTargetBinaryData returns True, *ptr will point to an511* allocated block of memory containing the binary data attribute512* requested. It is the caller's responsibility to free the data513* when done. len will list the length of the binary data.514*515* Possible errors:516* BadValue - The target doesn't exist.517* BadMatch - The NVIDIA driver does not control the target.518* BadAlloc - Insufficient resources to fulfill the request.519*/520521Bool XNVCTRLQueryTargetBinaryData(Display *dpy,522int target_type,523int target_id,524unsigned int display_mask,525unsigned int attribute,526unsigned char **ptr,527int *len);528529/*530* XNVCTRLStringOperation -531*532* Takes a string as input and returns a Xmalloc'ed string as output.533* Returns True on success and False on failure.534*/535536Bool XNVCTRLStringOperation(Display *dpy,537int target_type,538int target_id,539unsigned int display_mask,540unsigned int attribute,541char *pIn,542char **ppOut);543544/*545* XNVCtrlSelectNotify -546*547* This enables/disables receiving of NV-CONTROL events. The type548* specifies the type of event to enable (currently, the only549* type that can be requested per-screen with XNVCtrlSelectNotify()550* is ATTRIBUTE_CHANGED_EVENT); onoff controls whether receiving this551* type of event should be enabled (True) or disabled (False).552*553* Returns True if successful, or False if the screen is not554* controlled by the NVIDIA driver.555*/556557Bool XNVCtrlSelectNotify(Display *dpy, int screen, int type, Bool onoff);558559/*560* XNVCtrlSelectTargetNotify -561*562* This enables/disables receiving of NV-CONTROL events that happen on563* the specified target. The notify_type specifies the type of event to564* enable (currently, the only type that can be requested per-target with565* XNVCtrlSelectTargetNotify() is TARGET_ATTRIBUTE_CHANGED_EVENT); onoff566* controls whether receiving this type of event should be enabled (True)567* or disabled (False).568*569* Returns True if successful, or False if the target is not570* controlled by the NVIDIA driver.571*/572573Bool XNVCtrlSelectTargetNotify(Display *dpy,574int target_type,575int target_id,576int notify_type,577Bool onoff);578579/*580* XNVCtrlEvent structure581*/582583typedef struct584{585int type;586unsigned long serial;587Bool send_event; /* always FALSE, we don't allow send_events */588Display *display;589Time time;590int screen;591unsigned int display_mask;592unsigned int attribute;593int value;594} XNVCtrlAttributeChangedEvent;595596typedef union597{598int type;599XNVCtrlAttributeChangedEvent attribute_changed;600long pad[24];601} XNVCtrlEvent;602603/*604* XNVCtrlEventTarget structure605*/606607typedef struct608{609int type;610unsigned long serial;611Bool send_event; /* always FALSE, we don't allow send_events */612Display *display;613Time time;614int target_type;615int target_id;616unsigned int display_mask;617unsigned int attribute;618int value;619} XNVCtrlAttributeChangedEventTarget;620621typedef union622{623int type;624XNVCtrlAttributeChangedEventTarget attribute_changed;625long pad[24];626} XNVCtrlEventTarget;627628/*629* XNVCtrlEventTargetAvailability structure630*/631632typedef struct633{634int type;635unsigned long serial;636Bool send_event; /* always FALSE, we don't allow send_events */637Display *display;638Time time;639int target_type;640int target_id;641unsigned int display_mask;642unsigned int attribute;643int value;644Bool availability;645} XNVCtrlAttributeChangedEventTargetAvailability;646647typedef union648{649int type;650XNVCtrlAttributeChangedEventTargetAvailability attribute_changed;651long pad[24];652} XNVCtrlEventTargetAvailability;653654/*655* XNVCtrlStringEventTarget structure656*/657658typedef struct659{660int type;661unsigned long serial;662Bool send_event; /* always FALSE, we don't allow send_events */663Display *display;664Time time;665int target_type;666int target_id;667unsigned int display_mask;668unsigned int attribute;669} XNVCtrlStringAttributeChangedEventTarget;670671typedef union672{673int type;674XNVCtrlStringAttributeChangedEventTarget attribute_changed;675long pad[24];676} XNVCtrlStringEventTarget;677678/*679* XNVCtrlBinaryEventTarget structure680*/681682typedef struct683{684int type;685unsigned long serial;686Bool send_event; /* always FALSE, we don't allow send_events */687Display *display;688Time time;689int target_type;690int target_id;691unsigned int display_mask;692unsigned int attribute;693} XNVCtrlBinaryAttributeChangedEventTarget;694695typedef union696{697int type;698XNVCtrlBinaryAttributeChangedEventTarget attribute_changed;699long pad[24];700} XNVCtrlBinaryEventTarget;701702#if defined __cplusplus703} /* extern "C" */704#endif705706#endif /* __NVCTRLLIB_H */707708709