Commit cc068e93 by Corentin Wallez Committed by Commit Bot

Add DisplayGL::getDriverVersion and implementation on Linux NVIDIA

Some GPU driver bug workarounds should be active only for specific driver version ranges. This adds NVIDIA Linux driver detection using the XNVCtrl X11 extension. BUG=590870 Change-Id: I8cbf692a0c8a6da7473169f29d720bdc2d07663d Reviewed-on: https://chromium-review.googlesource.com/329637Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent bc4c4bc5
......@@ -254,6 +254,13 @@ static_library("libANGLE") {
libs = []
defines = [ "LIBANGLE_IMPLEMENTATION" ]
deps = [
":angle_common",
":commit_id",
":includes",
":translator_static",
]
# Shared D3D sources.
if (angle_enable_d3d9 || angle_enable_d3d11) {
sources += rebase_path(gles_gypi.libangle_d3d_shared_sources, ".", "src")
......@@ -281,7 +288,14 @@ static_library("libANGLE") {
}
if (use_x11) {
sources += rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "src")
libs += [ "X11" ]
deps += [
"src/third_party/libXNVCtrl:libXNVCtrl"
]
libs += [
"X11",
"Xi",
"Xext",
]
}
}
......@@ -298,13 +312,6 @@ static_library("libANGLE") {
"//build/config/compiler:no_chromium_code",
]
deps = [
":angle_common",
":commit_id",
":includes",
":translator_static",
]
if (is_win) {
deps += [ ":copy_compiler_dll" ]
}
......
......@@ -36,6 +36,8 @@ class DisplayGL : public DisplayImpl
egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override;
virtual egl::Error getDriverVersion(std::string *version) const = 0;
protected:
RendererGL *getRenderer() const { return mRenderer; };
const gl::Version &getMaxSupportedESVersion() const;
......
......@@ -55,6 +55,8 @@ class DisplayCGL : public DisplayGL
egl::Surface *drawSurface,
egl::Surface *readSurface) const override;
egl::Error getDriverVersion(std::string *version) const override;
private:
const FunctionsGL *getFunctionsGL() const override;
......
......@@ -269,4 +269,10 @@ egl::Error DisplayCGL::waitNative(EGLint engine,
// TODO(cwallez) UNIMPLEMENTED()
return egl::Error(EGL_SUCCESS);
}
egl::Error DisplayCGL::getDriverVersion(std::string *version) const
{
*version = "";
return egl::Error(EGL_SUCCESS);
}
}
......@@ -18,6 +18,8 @@
#include "libANGLE/renderer/gl/glx/PbufferSurfaceGLX.h"
#include "libANGLE/renderer/gl/glx/WindowSurfaceGLX.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
#include "third_party/libXNVCtrl/NVCtrl.h"
#include "third_party/libXNVCtrl/NVCtrlLib.h"
namespace rx
{
......@@ -70,6 +72,7 @@ DisplayGLX::DisplayGLX()
mMinSwapInterval(0),
mMaxSwapInterval(0),
mCurrentSwapInterval(-1),
mXDisplay(nullptr),
mEGLDisplay(nullptr)
{
}
......@@ -81,24 +84,24 @@ DisplayGLX::~DisplayGLX()
egl::Error DisplayGLX::initialize(egl::Display *display)
{
mEGLDisplay = display;
Display *xDisplay = display->getNativeDisplayId();
mXDisplay = display->getNativeDisplayId();
const auto &attribMap = display->getAttributeMap();
// ANGLE_platform_angle allows the creation of a default display
// using EGL_DEFAULT_DISPLAY (= nullptr). In this case just open
// the display specified by the DISPLAY environment variable.
if (xDisplay == EGL_DEFAULT_DISPLAY)
if (mXDisplay == EGL_DEFAULT_DISPLAY)
{
mUsesNewXDisplay = true;
xDisplay = XOpenDisplay(NULL);
if (!xDisplay)
mXDisplay = XOpenDisplay(NULL);
if (!mXDisplay)
{
return egl::Error(EGL_NOT_INITIALIZED, "Could not open the default X display.");
}
}
std::string glxInitError;
if (!mGLX.initialize(xDisplay, DefaultScreen(xDisplay), &glxInitError))
if (!mGLX.initialize(mXDisplay, DefaultScreen(mXDisplay), &glxInitError))
{
return egl::Error(EGL_NOT_INITIALIZED, glxInitError.c_str());
}
......@@ -235,7 +238,8 @@ egl::Error DisplayGLX::initialize(egl::Display *display)
visualTemplate.visualid = getGLXFBConfigAttrib(mContextConfig, GLX_VISUAL_ID);
int numVisuals = 0;
XVisualInfo *visuals = XGetVisualInfo(xDisplay, VisualIDMask, &visualTemplate, &numVisuals);
XVisualInfo *visuals =
XGetVisualInfo(mXDisplay, VisualIDMask, &visualTemplate, &numVisuals);
if (numVisuals <= 0)
{
return egl::Error(EGL_NOT_INITIALIZED,
......@@ -301,6 +305,9 @@ egl::Error DisplayGLX::initialize(egl::Display *display)
reinterpret_cast<const char*>(mFunctionsGL->getString(GL_RENDERER));
mIsMesa = rendererString.find("Mesa") != std::string::npos;
std::string version;
getDriverVersion(&version);
return DisplayGL::initialize(display);
}
......@@ -711,6 +718,20 @@ egl::Error DisplayGLX::waitClient() const
return egl::Error(EGL_SUCCESS);
}
egl::Error DisplayGLX::getDriverVersion(std::string *version) const
{
VendorID vendor = GetVendorID(mFunctionsGL);
switch (vendor)
{
case VENDOR_ID_NVIDIA:
return getNVIDIADriverVersion(version);
default:
*version = "";
return egl::Error(EGL_SUCCESS);
}
}
egl::Error DisplayGLX::waitNative(EGLint engine,
egl::Surface *drawSurface,
egl::Surface *readSurface) const
......@@ -859,4 +880,29 @@ egl::Error DisplayGLX::createContextAttribs(glx::FBConfig,
}
return egl::Error(EGL_SUCCESS);
}
egl::Error DisplayGLX::getNVIDIADriverVersion(std::string *version) const
{
*version = "";
int eventBase = 0;
int errorBase = 0;
if (XNVCTRLQueryExtension(mXDisplay, &eventBase, &errorBase))
{
int screenCount = ScreenCount(mXDisplay);
for (int screen = 0; screen < screenCount; ++screen)
{
char *buffer = nullptr;
if (XNVCTRLIsNvScreen(mXDisplay, screen) &&
XNVCTRLQueryStringAttribute(mXDisplay, screen, 0,
NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, &buffer))
{
*version = buffer;
XFree(buffer);
}
}
}
return egl::Error(EGL_SUCCESS);
}
}
......@@ -72,6 +72,8 @@ class DisplayGLX : public DisplayGL
egl::Surface *drawSurface,
egl::Surface *readSurface) const override;
egl::Error getDriverVersion(std::string *version) const override;
// Synchronizes with the X server, if the display has been opened by ANGLE.
// Calling this is required at the end of every functions that does buffered
// X calls (not for glX calls) otherwise there might be race conditions
......@@ -102,6 +104,8 @@ class DisplayGLX : public DisplayGL
int profileMask,
glx::Context *context) const;
egl::Error getNVIDIADriverVersion(std::string *version) const;
FunctionsGL *mFunctionsGL;
//TODO(cwallez) yuck, change generateConfigs to be non-const or add a userdata member to egl::Config?
......@@ -133,6 +137,7 @@ class DisplayGLX : public DisplayGL
int mCurrentSwapInterval;
FunctionsGLX mGLX;
Display *mXDisplay;
egl::Display *mEGLDisplay;
};
......
......@@ -30,6 +30,7 @@ class FunctionsGL;
struct WorkaroundsGL;
VendorID GetVendorID(const FunctionsGL *functions);
std::string GetDriverVersion(const FunctionsGL *functions);
namespace nativegl_gl
{
......
......@@ -641,6 +641,12 @@ egl::Error DisplayWGL::waitNative(EGLint engine,
return egl::Error(EGL_SUCCESS);
}
egl::Error DisplayWGL::getDriverVersion(std::string *version) const
{
*version = "";
return egl::Error(EGL_SUCCESS);
}
egl::Error DisplayWGL::registerD3DDevice(IUnknown *device, HANDLE *outHandle)
{
ASSERT(device != nullptr);
......
......@@ -57,6 +57,8 @@ class DisplayWGL : public DisplayGL
egl::Surface *drawSurface,
egl::Surface *readSurface) const override;
egl::Error getDriverVersion(std::string *version) const override;
egl::Error registerD3DDevice(IUnknown *device, HANDLE *outHandle);
void releaseD3DDevice(HANDLE handle);
......
......@@ -613,7 +613,7 @@
'defines':
[
'ANGLE_USE_X11',
]
],
}],
],
}],
......@@ -732,16 +732,20 @@
[
'ANGLE_USE_X11',
],
'dependencies':
[
'<(angle_path)/src/third_party/libXNVCtrl/libXNVCtrl.gyp:libXNVCtrl',
],
'sources':
[
'<@(libangle_gl_glx_sources)',
],
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other x11 xi)',
'<!@(<(pkg-config) --libs-only-L --libs-only-other x11 xi xext)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l x11 xi) -ldl',
'<!@(<(pkg-config) --libs-only-l x11 xi xext) -ldl',
],
},
}],
......
# Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
static_library("libXNVCtrl") {
sources = [
"NVCtrl.c",
"NVCtrl.h",
"NVCtrlLib.h",
"nv_control.h",
]
}
/*
* Copyright (c) 2008 NVIDIA, Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
\ No newline at end of file
/*
* Copyright (c) 2008 NVIDIA, Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Make sure that XTHREADS is defined, so that the
* LockDisplay/UnlockDisplay macros are expanded properly and the
* libXNVCtrl library properly protects the Display connection.
*/
#if !defined(XTHREADS)
#define XTHREADS
#endif /* XTHREADS */
#define NEED_EVENTS
#define NEED_REPLIES
#include <stdint.h>
#include <stdlib.h>
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include "NVCtrlLib.h"
#include "nv_control.h"
#define NVCTRL_EXT_EXISTS 1
#define NVCTRL_EXT_NEED_TARGET_SWAP 2
#define NVCTRL_EXT_64_BIT_ATTRIBUTES 4
#define NVCTRL_EXT_NEED_CHECK (1 << (sizeof(XPointer) - 1))
static XExtensionInfo _nvctrl_ext_info_data;
static XExtensionInfo *nvctrl_ext_info = &_nvctrl_ext_info_data;
static const char *nvctrl_extension_name = NV_CONTROL_NAME;
#define XNVCTRLCheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, nvctrl_extension_name, val)
#define XNVCTRLSimpleCheckExtension(dpy,i) \
XextSimpleCheckExtension (dpy, i, nvctrl_extension_name)
static int close_display();
static uintptr_t version_flags(Display *dpy, XExtDisplayInfo *info);
static Bool wire_to_event();
static /* const */ XExtensionHooks nvctrl_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
close_display, /* close_display */
wire_to_event, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
static XEXT_GENERATE_FIND_DISPLAY (find_display, nvctrl_ext_info,
nvctrl_extension_name,
&nvctrl_extension_hooks,
NV_CONTROL_EVENTS,
(XPointer)NVCTRL_EXT_NEED_CHECK)
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info)
/*
* NV-CONTROL versions 1.8 and 1.9 pack the target_type and target_id
* fields in reversed order. In order to talk to one of these servers,
* we need to swap these fields.
*/
static void XNVCTRLCheckTargetData(Display *dpy, XExtDisplayInfo *info,
int *target_type, int *target_id)
{
uintptr_t flags = version_flags(dpy, info);
/* We need to swap the target_type and target_id */
if (flags & NVCTRL_EXT_NEED_TARGET_SWAP) {
int tmp;
tmp = *target_type;
*target_type = *target_id;
*target_id = tmp;
}
}
Bool XNVCTRLQueryExtension (
Display *dpy,
int *event_basep,
int *error_basep
){
XExtDisplayInfo *info = find_display (dpy);
if (XextHasExtension(info)) {
if (event_basep) *event_basep = info->codes->first_event;
if (error_basep) *error_basep = info->codes->first_error;
return True;
} else {
return False;
}
}
/*
* Retrieve any cached flags that depend on the version of the NV-CONTROL
* extension.
*/
static uintptr_t version_flags(Display *dpy, XExtDisplayInfo *info)
{
uintptr_t data = (uintptr_t)info->data;
/* If necessary, determine the NV-CONTROL version */
if (data & NVCTRL_EXT_NEED_CHECK) {
int major, minor;
data = 0;
if (XNVCTRLQueryVersion(dpy, &major, &minor)) {
data |= NVCTRL_EXT_EXISTS;
if (major == 1 && (minor == 8 || minor == 9)) {
data |= NVCTRL_EXT_NEED_TARGET_SWAP;
}
if ((major > 1) || ((major == 1) && (minor > 20))) {
data |= NVCTRL_EXT_64_BIT_ATTRIBUTES;
}
}
info->data = (XPointer)data;
}
return data;
}
Bool XNVCTRLQueryVersion (
Display *dpy,
int *major,
int *minor
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryExtensionReply rep;
xnvCtrlQueryExtensionReq *req;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlQueryExtension, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryExtension;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
if (major) *major = rep.major;
if (minor) *minor = rep.minor;
UnlockDisplay (dpy);
SyncHandle ();
return True;
}
Bool XNVCTRLIsNvScreen (
Display *dpy,
int screen
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlIsNvReply rep;
xnvCtrlIsNvReq *req;
Bool isnv;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlIsNv, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlIsNv;
req->screen = screen;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
isnv = rep.isnv;
UnlockDisplay (dpy);
SyncHandle ();
return isnv;
}
Bool XNVCTRLQueryTargetCount (
Display *dpy,
int target_type,
int *value
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryTargetCountReply rep;
xnvCtrlQueryTargetCountReq *req;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlQueryTargetCount, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryTargetCount;
req->target_type = target_type;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
if (value) *value = rep.count;
UnlockDisplay (dpy);
SyncHandle ();
return True;
}
void XNVCTRLSetTargetAttribute (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int value
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSetAttributeReq *req;
XNVCTRLSimpleCheckExtension (dpy, info);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
LockDisplay (dpy);
GetReq (nvCtrlSetAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSetAttribute;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
req->value = value;
UnlockDisplay (dpy);
SyncHandle ();
}
void XNVCTRLSetAttribute (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int value
){
XNVCTRLSetTargetAttribute (dpy, NV_CTRL_TARGET_TYPE_X_SCREEN, screen,
display_mask, attribute, value);
}
Bool XNVCTRLSetTargetAttributeAndGetStatus (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int value
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSetAttributeAndGetStatusReq *req;
xnvCtrlSetAttributeAndGetStatusReply rep;
Bool success;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlSetAttributeAndGetStatus, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSetAttributeAndGetStatus;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
req->value = value;
if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
UnlockDisplay (dpy);
SyncHandle ();
success = rep.flags;
return success;
}
Bool XNVCTRLSetAttributeAndGetStatus (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int value
){
return XNVCTRLSetTargetAttributeAndGetStatus(dpy,
NV_CTRL_TARGET_TYPE_X_SCREEN,
screen, display_mask,
attribute, value);
}
Bool XNVCTRLQueryTargetAttribute (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int *value
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryAttributeReply rep;
xnvCtrlQueryAttributeReq *req;
Bool exists;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
LockDisplay (dpy);
GetReq (nvCtrlQueryAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryAttribute;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
exists = rep.flags;
if (exists && value) *value = rep.value;
UnlockDisplay (dpy);
SyncHandle ();
return exists;
}
Bool XNVCTRLQueryAttribute (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int *value
){
return XNVCTRLQueryTargetAttribute(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
screen, display_mask, attribute, value);
}
Bool XNVCTRLQueryTargetAttribute64 (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int64_t *value
){
XExtDisplayInfo *info = find_display(dpy);
xnvCtrlQueryAttribute64Reply rep;
xnvCtrlQueryAttributeReq *req;
Bool exists;
if (!XextHasExtension(info))
return False;
XNVCTRLCheckExtension(dpy, info, False);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
LockDisplay(dpy);
GetReq(nvCtrlQueryAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryAttribute64;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
exists = rep.flags;
if (exists && value) *value = rep.value_64;
UnlockDisplay(dpy);
SyncHandle();
return exists;
}
Bool XNVCTRLQueryTargetStringAttribute (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
char **ptr
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryStringAttributeReply rep;
xnvCtrlQueryStringAttributeReq *req;
Bool exists;
int length, numbytes, slop;
if (!ptr) return False;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
LockDisplay (dpy);
GetReq (nvCtrlQueryStringAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryStringAttribute;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
length = rep.length;
numbytes = rep.n;
slop = numbytes & 3;
exists = rep.flags;
if (exists) {
*ptr = (char *) Xmalloc(numbytes);
}
if (!exists || !*ptr) {
_XEatData(dpy, length);
UnlockDisplay (dpy);
SyncHandle ();
return False;
} else {
_XRead(dpy, (char *) *ptr, numbytes);
if (slop) _XEatData(dpy, 4-slop);
}
UnlockDisplay (dpy);
SyncHandle ();
return exists;
}
Bool XNVCTRLQueryStringAttribute (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
char **ptr
){
return XNVCTRLQueryTargetStringAttribute(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
screen, display_mask,
attribute, ptr);
}
Bool XNVCTRLSetTargetStringAttribute (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
char *ptr
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSetStringAttributeReq *req;
xnvCtrlSetStringAttributeReply rep;
int size;
Bool success;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
size = strlen(ptr)+1;
LockDisplay (dpy);
GetReq (nvCtrlSetStringAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSetStringAttribute;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
req->length += ((size + 3) & ~3) >> 2;
req->num_bytes = size;
Data(dpy, ptr, size);
if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
UnlockDisplay (dpy);
SyncHandle ();
success = rep.flags;
return success;
}
Bool XNVCTRLSetStringAttribute (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
char *ptr
){
return XNVCTRLSetTargetStringAttribute(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
screen, display_mask,
attribute, ptr);
}
static Bool XNVCTRLQueryValidTargetAttributeValues32 (
Display *dpy,
XExtDisplayInfo *info,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
){
xnvCtrlQueryValidAttributeValuesReply rep;
xnvCtrlQueryValidAttributeValuesReq *req;
Bool exists;
LockDisplay (dpy);
GetReq (nvCtrlQueryValidAttributeValues, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryValidAttributeValues;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
exists = rep.flags;
if (exists) {
values->type = rep.attr_type;
if (rep.attr_type == ATTRIBUTE_TYPE_RANGE) {
values->u.range.min = rep.min;
values->u.range.max = rep.max;
}
if (rep.attr_type == ATTRIBUTE_TYPE_INT_BITS) {
values->u.bits.ints = rep.bits;
}
values->permissions = rep.perms;
}
UnlockDisplay (dpy);
SyncHandle ();
return exists;
}
Bool XNVCTRLQueryValidTargetStringAttributeValues (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
){
XExtDisplayInfo *info = find_display(dpy);
Bool exists;
xnvCtrlQueryValidAttributeValuesReply rep;
xnvCtrlQueryValidAttributeValuesReq *req;
if (!values) return False;
if (!XextHasExtension(info))
return False;
XNVCTRLCheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq (nvCtrlQueryValidAttributeValues, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryValidStringAttributeValues;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
exists = rep.flags;
if (exists) {
values->type = rep.attr_type;
values->permissions = rep.perms;
}
UnlockDisplay(dpy);
SyncHandle();
return exists;
}
static Bool XNVCTRLQueryValidTargetAttributeValues64 (
Display *dpy,
XExtDisplayInfo *info,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
){
xnvCtrlQueryValidAttributeValues64Reply rep;
xnvCtrlQueryValidAttributeValuesReq *req;
Bool exists;
LockDisplay(dpy);
GetReq(nvCtrlQueryValidAttributeValues, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryValidAttributeValues64;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply(dpy, (xReply *)&rep,
sz_xnvCtrlQueryValidAttributeValues64Reply_extra,
xTrue)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
exists = rep.flags;
if (exists) {
values->type = rep.attr_type;
if (rep.attr_type == ATTRIBUTE_TYPE_RANGE) {
values->u.range.min = rep.min_64;
values->u.range.max = rep.max_64;
}
if (rep.attr_type == ATTRIBUTE_TYPE_INT_BITS) {
values->u.bits.ints = rep.bits_64;
}
values->permissions = rep.perms;
}
UnlockDisplay(dpy);
SyncHandle();
return exists;
}
Bool XNVCTRLQueryValidTargetAttributeValues (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
){
XExtDisplayInfo *info = find_display(dpy);
Bool exists;
uintptr_t flags;
if (!values) return False;
if (!XextHasExtension(info))
return False;
XNVCTRLCheckExtension(dpy, info, False);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
flags = version_flags(dpy,info);
if (!(flags & NVCTRL_EXT_EXISTS))
return False;
if (flags & NVCTRL_EXT_64_BIT_ATTRIBUTES) {
exists = XNVCTRLQueryValidTargetAttributeValues64(dpy, info,
target_type,
target_id,
display_mask,
attribute,
values);
} else {
exists = XNVCTRLQueryValidTargetAttributeValues32(dpy, info,
target_type,
target_id,
display_mask,
attribute,
values);
}
return exists;
}
Bool XNVCTRLQueryValidAttributeValues (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
){
return XNVCTRLQueryValidTargetAttributeValues(dpy,
NV_CTRL_TARGET_TYPE_X_SCREEN,
screen, display_mask,
attribute, values);
}
static Bool QueryAttributePermissionsInternal (
Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions,
unsigned int reqType
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryAttributePermissionsReply rep;
xnvCtrlQueryAttributePermissionsReq *req;
Bool exists;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay(dpy);
GetReq(nvCtrlQueryAttributePermissions, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = reqType;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle();
return False;
}
exists = rep.flags;
if (exists && permissions) {
permissions->type = rep.attr_type;
permissions->permissions = rep.perms;
}
UnlockDisplay(dpy);
SyncHandle();
return exists;
}
Bool XNVCTRLQueryAttributePermissions (
Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions
){
return QueryAttributePermissionsInternal(dpy,
attribute,
permissions,
X_nvCtrlQueryAttributePermissions);
}
Bool XNVCTRLQueryStringAttributePermissions (
Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions
){
return QueryAttributePermissionsInternal(dpy,
attribute,
permissions,
X_nvCtrlQueryStringAttributePermissions);
}
Bool XNVCTRLQueryBinaryDataAttributePermissions (
Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions
){
return QueryAttributePermissionsInternal(dpy,
attribute,
permissions,
X_nvCtrlQueryBinaryDataAttributePermissions);
}
Bool XNVCTRLQueryStringOperationAttributePermissions (
Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions
){
return QueryAttributePermissionsInternal(dpy,
attribute,
permissions,
X_nvCtrlQueryStringOperationAttributePermissions);
}
void XNVCTRLSetGvoColorConversion (
Display *dpy,
int screen,
float colorMatrix[3][3],
float colorOffset[3],
float colorScale[3]
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSetGvoColorConversionReq *req;
XNVCTRLSimpleCheckExtension (dpy, info);
LockDisplay (dpy);
GetReq (nvCtrlSetGvoColorConversion, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSetGvoColorConversion;
req->screen = screen;
req->cscMatrix_y_r = colorMatrix[0][0];
req->cscMatrix_y_g = colorMatrix[0][1];
req->cscMatrix_y_b = colorMatrix[0][2];
req->cscMatrix_cr_r = colorMatrix[1][0];
req->cscMatrix_cr_g = colorMatrix[1][1];
req->cscMatrix_cr_b = colorMatrix[1][2];
req->cscMatrix_cb_r = colorMatrix[2][0];
req->cscMatrix_cb_g = colorMatrix[2][1];
req->cscMatrix_cb_b = colorMatrix[2][2];
req->cscOffset_y = colorOffset[0];
req->cscOffset_cr = colorOffset[1];
req->cscOffset_cb = colorOffset[2];
req->cscScale_y = colorScale[0];
req->cscScale_cr = colorScale[1];
req->cscScale_cb = colorScale[2];
UnlockDisplay (dpy);
SyncHandle ();
}
Bool XNVCTRLQueryGvoColorConversion (
Display *dpy,
int screen,
float colorMatrix[3][3],
float colorOffset[3],
float colorScale[3]
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryGvoColorConversionReply rep;
xnvCtrlQueryGvoColorConversionReq *req;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlQueryGvoColorConversion, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryGvoColorConversion;
req->screen = screen;
if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
_XRead(dpy, (char *)(colorMatrix), 36);
_XRead(dpy, (char *)(colorOffset), 12);
_XRead(dpy, (char *)(colorScale), 12);
UnlockDisplay (dpy);
SyncHandle ();
return True;
}
Bool XNVCtrlSelectTargetNotify (
Display *dpy,
int target_type,
int target_id,
int notify_type,
Bool onoff
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSelectTargetNotifyReq *req;
if(!XextHasExtension (info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlSelectTargetNotify, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSelectTargetNotify;
req->target_type = target_type;
req->target_id = target_id;
req->notifyType = notify_type;
req->onoff = onoff;
UnlockDisplay (dpy);
SyncHandle ();
return True;
}
Bool XNVCtrlSelectNotify (
Display *dpy,
int screen,
int type,
Bool onoff
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSelectNotifyReq *req;
if(!XextHasExtension (info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
LockDisplay (dpy);
GetReq (nvCtrlSelectNotify, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSelectNotify;
req->screen = screen;
req->notifyType = type;
req->onoff = onoff;
UnlockDisplay (dpy);
SyncHandle ();
return True;
}
Bool XNVCTRLQueryTargetBinaryData (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
unsigned char **ptr,
int *len
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryBinaryDataReply rep;
xnvCtrlQueryBinaryDataReq *req;
Bool exists;
int length, numbytes, slop;
if (!ptr) return False;
if(!XextHasExtension(info))
return False;
XNVCTRLCheckExtension (dpy, info, False);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
LockDisplay (dpy);
GetReq (nvCtrlQueryBinaryData, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryBinaryData;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
length = rep.length;
numbytes = rep.n;
slop = numbytes & 3;
exists = rep.flags;
if (exists) {
*ptr = (unsigned char *) Xmalloc(numbytes);
}
if (!exists || !*ptr) {
_XEatData(dpy, length);
UnlockDisplay (dpy);
SyncHandle ();
return False;
} else {
_XRead(dpy, (char *) *ptr, numbytes);
if (slop) _XEatData(dpy, 4-slop);
}
if (len) *len = numbytes;
UnlockDisplay (dpy);
SyncHandle ();
return exists;
}
Bool XNVCTRLQueryBinaryData (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
unsigned char **ptr,
int *len
){
return XNVCTRLQueryTargetBinaryData(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN,
screen, display_mask,
attribute, ptr, len);
}
Bool XNVCTRLStringOperation (
Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
char *pIn,
char **ppOut
) {
XExtDisplayInfo *info = find_display(dpy);
xnvCtrlStringOperationReq *req;
xnvCtrlStringOperationReply rep;
Bool ret;
int inSize, outSize, length, slop;
if (!XextHasExtension(info))
return False;
if (!ppOut)
return False;
*ppOut = NULL;
XNVCTRLCheckExtension(dpy, info, False);
XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id);
if (pIn) {
inSize = strlen(pIn) + 1;
} else {
inSize = 0;
}
LockDisplay(dpy);
GetReq(nvCtrlStringOperation, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlStringOperation;
req->target_type = target_type;
req->target_id = target_id;
req->display_mask = display_mask;
req->attribute = attribute;
req->length += ((inSize + 3) & ~3) >> 2;
req->num_bytes = inSize;
if (pIn) {
Data(dpy, pIn, inSize);
}
if (!_XReply (dpy, (xReply *) &rep, 0, False)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
length = rep.length;
outSize = rep.num_bytes;
slop = outSize & 3;
if (outSize) *ppOut = (char *) Xmalloc(outSize);
if (!*ppOut) {
_XEatData(dpy, length);
} else {
_XRead(dpy, (char *) *ppOut, outSize);
if (slop) _XEatData(dpy, 4-slop);
}
ret = rep.ret;
UnlockDisplay(dpy);
SyncHandle();
return ret;
}
static Bool wire_to_event (Display *dpy, XEvent *host, xEvent *wire)
{
XExtDisplayInfo *info = find_display (dpy);
XNVCtrlEvent *re;
xnvctrlEvent *event;
XNVCtrlEventTarget *reTarget;
xnvctrlEventTarget *eventTarget;
XNVCtrlEventTargetAvailability *reTargetAvailability;
XNVCtrlStringEventTarget *reTargetString;
XNVCtrlBinaryEventTarget *reTargetBinary;
XNVCTRLCheckExtension (dpy, info, False);
switch ((wire->u.u.type & 0x7F) - info->codes->first_event) {
case ATTRIBUTE_CHANGED_EVENT:
re = (XNVCtrlEvent *) host;
event = (xnvctrlEvent *) wire;
re->attribute_changed.type = event->u.u.type & 0x7F;
re->attribute_changed.serial =
_XSetLastRequestRead(dpy, (xGenericReply*) event);
re->attribute_changed.send_event = ((event->u.u.type & 0x80) != 0);
re->attribute_changed.display = dpy;
re->attribute_changed.time = event->u.attribute_changed.time;
re->attribute_changed.screen = event->u.attribute_changed.screen;
re->attribute_changed.display_mask =
event->u.attribute_changed.display_mask;
re->attribute_changed.attribute = event->u.attribute_changed.attribute;
re->attribute_changed.value = event->u.attribute_changed.value;
break;
case TARGET_ATTRIBUTE_CHANGED_EVENT:
reTarget = (XNVCtrlEventTarget *) host;
eventTarget = (xnvctrlEventTarget *) wire;
reTarget->attribute_changed.type = eventTarget->u.u.type & 0x7F;
reTarget->attribute_changed.serial =
_XSetLastRequestRead(dpy, (xGenericReply*) eventTarget);
reTarget->attribute_changed.send_event =
((eventTarget->u.u.type & 0x80) != 0);
reTarget->attribute_changed.display = dpy;
reTarget->attribute_changed.time =
eventTarget->u.attribute_changed.time;
reTarget->attribute_changed.target_type =
eventTarget->u.attribute_changed.target_type;
reTarget->attribute_changed.target_id =
eventTarget->u.attribute_changed.target_id;
reTarget->attribute_changed.display_mask =
eventTarget->u.attribute_changed.display_mask;
reTarget->attribute_changed.attribute =
eventTarget->u.attribute_changed.attribute;
reTarget->attribute_changed.value =
eventTarget->u.attribute_changed.value;
break;
case TARGET_ATTRIBUTE_AVAILABILITY_CHANGED_EVENT:
reTargetAvailability = (XNVCtrlEventTargetAvailability *) host;
eventTarget = (xnvctrlEventTarget *) wire;
reTargetAvailability->attribute_changed.type =
eventTarget->u.u.type & 0x7F;
reTargetAvailability->attribute_changed.serial =
_XSetLastRequestRead(dpy, (xGenericReply*) eventTarget);
reTargetAvailability->attribute_changed.send_event =
((eventTarget->u.u.type & 0x80) != 0);
reTargetAvailability->attribute_changed.display = dpy;
reTargetAvailability->attribute_changed.time =
eventTarget->u.availability_changed.time;
reTargetAvailability->attribute_changed.target_type =
eventTarget->u.availability_changed.target_type;
reTargetAvailability->attribute_changed.target_id =
eventTarget->u.availability_changed.target_id;
reTargetAvailability->attribute_changed.display_mask =
eventTarget->u.availability_changed.display_mask;
reTargetAvailability->attribute_changed.attribute =
eventTarget->u.availability_changed.attribute;
reTargetAvailability->attribute_changed.availability =
eventTarget->u.availability_changed.availability;
reTargetAvailability->attribute_changed.value =
eventTarget->u.availability_changed.value;
break;
case TARGET_STRING_ATTRIBUTE_CHANGED_EVENT:
reTargetString = (XNVCtrlStringEventTarget *) host;
eventTarget = (xnvctrlEventTarget *) wire;
reTargetString->attribute_changed.type = eventTarget->u.u.type & 0x7F;
reTargetString->attribute_changed.serial =
_XSetLastRequestRead(dpy, (xGenericReply*) eventTarget);
reTargetString->attribute_changed.send_event =
((eventTarget->u.u.type & 0x80) != 0);
reTargetString->attribute_changed.display = dpy;
reTargetString->attribute_changed.time =
eventTarget->u.attribute_changed.time;
reTargetString->attribute_changed.target_type =
eventTarget->u.attribute_changed.target_type;
reTargetString->attribute_changed.target_id =
eventTarget->u.attribute_changed.target_id;
reTargetString->attribute_changed.display_mask =
eventTarget->u.attribute_changed.display_mask;
reTargetString->attribute_changed.attribute =
eventTarget->u.attribute_changed.attribute;
break;
case TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT:
reTargetBinary = (XNVCtrlBinaryEventTarget *) host;
eventTarget = (xnvctrlEventTarget *) wire;
reTargetBinary->attribute_changed.type = eventTarget->u.u.type & 0x7F;
reTargetBinary->attribute_changed.serial =
_XSetLastRequestRead(dpy, (xGenericReply*) eventTarget);
reTargetBinary->attribute_changed.send_event =
((eventTarget->u.u.type & 0x80) != 0);
reTargetBinary->attribute_changed.display = dpy;
reTargetBinary->attribute_changed.time =
eventTarget->u.attribute_changed.time;
reTargetBinary->attribute_changed.target_type =
eventTarget->u.attribute_changed.target_type;
reTargetBinary->attribute_changed.target_id =
eventTarget->u.attribute_changed.target_id;
reTargetBinary->attribute_changed.display_mask =
eventTarget->u.attribute_changed.display_mask;
reTargetBinary->attribute_changed.attribute =
eventTarget->u.attribute_changed.attribute;
break;
default:
return False;
}
return True;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Copyright (c) 2008 NVIDIA, Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __NVCTRLLIB_H
#define __NVCTRLLIB_H
#include "NVCtrl.h"
#if defined __cplusplus
extern "C" {
#endif
/*
* XNVCTRLQueryExtension -
*
* Returns True if the extension exists, returns False otherwise.
* event_basep and error_basep are the extension event and error
* bases. Currently, no extension specific errors or events are
* defined.
*/
Bool XNVCTRLQueryExtension(Display *dpy, int *event_basep, int *error_basep);
/*
* XNVCTRLQueryVersion -
*
* Returns True if the extension exists, returns False otherwise.
* major and minor are the extension's major and minor version
* numbers.
*/
Bool XNVCTRLQueryVersion(Display *dpy, int *major, int *minor);
/*
* XNVCTRLIsNvScreen
*
* Returns True is the specified screen is controlled by the NVIDIA
* driver. Returns False otherwise.
*/
Bool XNVCTRLIsNvScreen(Display *dpy, int screen);
/*
* XNVCTRLQueryTargetCount -
*
* Returns True if the target type exists. Returns False otherwise.
* If XNVCTRLQueryTargetCount returns True, value will contain the
* count of existing targets on the server of the specified target
* type.
*
* Please see "Attribute Targets" in NVCtrl.h for the list of valid
* target types.
*
* Possible errors:
* BadValue - The target doesn't exist.
*/
Bool XNVCTRLQueryTargetCount(Display *dpy, int target_type, int *value);
/*
* XNVCTRLSetAttribute -
*
* Sets the attribute to the given value. The attributes and their
* possible values are listed in NVCtrl.h.
*
* Not all attributes require the display_mask parameter; see
* NVCtrl.h for details.
*
* Calling this function is equivalent to calling XNVCTRLSetTargetAttribute()
* with the target_type set to NV_CTRL_TARGET_TYPE_X_SCREEN and
* target_id set to 'screen'.
*
* Possible errors:
* BadValue - The screen or attribute doesn't exist.
* BadMatch - The NVIDIA driver is not present on that screen.
*/
void XNVCTRLSetAttribute(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int value);
/*
* XNVCTRLSetTargetAttribute -
*
* Sets the attribute to the given value. The attributes and their
* possible values are listed in NVCtrl.h.
*
* Not all attributes require the display_mask parameter; see
* NVCtrl.h for details.
*
* Possible errors:
* BadValue - The target or attribute doesn't exist.
* BadMatch - The NVIDIA driver is not present on that target.
*/
void XNVCTRLSetTargetAttribute(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int value);
/*
* XNVCTRLSetAttributeAndGetStatus -
*
* Same as XNVCTRLSetAttribute().
* In addition, XNVCTRLSetAttributeAndGetStatus() returns
* True if the operation succeeds, False otherwise.
*
*/
Bool XNVCTRLSetAttributeAndGetStatus(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int value);
/*
* XNVCTRLSetTargetAttributeAndGetStatus -
*
* Same as XNVCTRLSetTargetAttribute().
* In addition, XNVCTRLSetTargetAttributeAndGetStatus() returns
* True if the operation succeeds, False otherwise.
*
*/
Bool XNVCTRLSetTargetAttributeAndGetStatus(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int value);
/*
* XNVCTRLQueryAttribute -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryAttribute returns True, value will contain the
* value of the specified attribute.
*
* Not all attributes require the display_mask parameter; see
* NVCtrl.h for details.
*
* Calling this function is equivalent to calling
* XNVCTRLQueryTargetAttribute() with the target_type set to
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
*
* Possible errors:
* BadValue - The screen doesn't exist.
* BadMatch - The NVIDIA driver is not present on that screen.
*/
Bool XNVCTRLQueryAttribute(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int *value);
/*
* XNVCTRLQueryTargetAttribute -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryTargetAttribute returns True, value will contain the
* value of the specified attribute.
*
* Not all attributes require the display_mask parameter; see
* NVCtrl.h for details.
*
* Possible errors:
* BadValue - The target doesn't exist.
* BadMatch - The NVIDIA driver does not control the target.
*/
Bool XNVCTRLQueryTargetAttribute(Display *dpy,
int target_Type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int *value);
/*
* XNVCTRLQueryTargetAttribute64 -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryTargetAttribute returns True, value will contain the
* value of the specified attribute.
*
* Not all attributes require the display_mask parameter; see
* NVCtrl.h for details.
*
* Note: this function behaves like XNVCTRLQueryTargetAttribute(),
* but supports 64-bit integer attributes.
*
* Possible errors:
* BadValue - The target doesn't exist.
* BadMatch - The NVIDIA driver does not control the target.
*/
Bool XNVCTRLQueryTargetAttribute64(Display *dpy,
int target_Type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
int64_t *value);
/*
* XNVCTRLQueryStringAttribute -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryStringAttribute returns True, *ptr will point to an
* allocated string containing the string attribute requested. It is
* the caller's responsibility to free the string when done.
*
* Calling this function is equivalent to calling
* XNVCTRLQueryTargetStringAttribute() with the target_type set to
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
*
* Possible errors:
* BadValue - The screen doesn't exist.
* BadMatch - The NVIDIA driver is not present on that screen.
* BadAlloc - Insufficient resources to fulfill the request.
*/
Bool XNVCTRLQueryStringAttribute(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
char **ptr);
/*
* XNVCTRLQueryTargetStringAttribute -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryTargetStringAttribute returns True, *ptr will point
* to an allocated string containing the string attribute requested.
* It is the caller's responsibility to free the string when done.
*
* Possible errors:
* BadValue - The target doesn't exist.
* BadMatch - The NVIDIA driver does not control the target.
* BadAlloc - Insufficient resources to fulfill the request.
*/
Bool XNVCTRLQueryTargetStringAttribute(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
char **ptr);
/*
* XNVCTRLSetStringAttribute -
*
* Returns True if the operation succeded. Returns False otherwise.
*
* Possible X errors:
* BadValue - The screen doesn't exist.
* BadMatch - The NVIDIA driver is not present on that screen.
* BadAlloc - Insufficient resources to fulfill the request.
*/
Bool XNVCTRLSetStringAttribute(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
char *ptr);
/*
* XNVCTRLSetTargetStringAttribute -
*
* Returns True if the operation succeded. Returns False otherwise.
*
* Possible X errors:
* BadValue - The screen doesn't exist.
* BadMatch - The NVIDIA driver is not present on that screen.
* BadAlloc - Insufficient resources to fulfill the request.
*/
Bool XNVCTRLSetTargetStringAttribute(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
char *ptr);
/*
* XNVCTRLQueryValidAttributeValues -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryValidAttributeValues returns True, values will indicate
* the valid values for the specified attribute; see the description
* of NVCTRLAttributeValidValues in NVCtrl.h.
*
* Calling this function is equivalent to calling
* XNVCTRLQueryValidTargetAttributeValues() with the target_type set to
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
*/
Bool XNVCTRLQueryValidAttributeValues(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values);
/*
* XNVCTRLQueryValidTargetAttributeValues -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryValidTargetAttributeValues returns True, values will indicate
* the valid values for the specified attribute.
*/
Bool XNVCTRLQueryValidTargetAttributeValues(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values);
/*
* XNVCTRLQueryValidTargetStringAttributeValues -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryValidTargetStringAttributeValues returns True, values will
* indicate the valid values for the specified attribute.
*/
Bool XNVCTRLQueryValidTargetStringAttributeValues(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values);
/*
* XNVCTRLQueryAttributePermissions -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryAttributePermissions returns True, permissions will
* indicate the permission flags for the attribute.
*/
Bool XNVCTRLQueryAttributePermissions(Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions);
/*
* XNVCTRLQueryStringAttributePermissions -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryStringAttributePermissions returns True, permissions will
* indicate the permission flags for the attribute.
*/
Bool XNVCTRLQueryStringAttributePermissions(Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions);
/*
* XNVCTRLQueryBinaryDataAttributePermissions -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryBinaryDataAttributePermissions returns True, permissions
* will indicate the permission flags for the attribute.
*/
Bool XNVCTRLQueryBinaryDataAttributePermissions(Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions);
/*
* XNVCTRLQueryStringOperationAttributePermissions -
*
* Returns True if the attribute exists. Returns False otherwise. If
* XNVCTRLQueryStringOperationAttributePermissions returns True,
* permissions will indicate the permission flags for the attribute.
*/
Bool XNVCTRLQueryStringOperationAttributePermissions(Display *dpy,
unsigned int attribute,
NVCTRLAttributePermissionsRec *permissions);
/*
* XNVCTRLSetGvoColorConversion -
*
* Sets the color conversion matrix, offset, and scale that should be
* used for GVO (Graphic to Video Out).
*
* The Color Space Conversion data is ordered like this:
*
* colorMatrix[0][0] // r.Y
* colorMatrix[0][1] // g.Y
* colorMatrix[0][2] // b.Y
*
* colorMatrix[1][0] // r.Cr
* colorMatrix[1][1] // g.Cr
* colorMatrix[1][2] // b.Cr
*
* colorMatrix[2][0] // r.Cb
* colorMatrix[2][1] // g.Cb
* colorMatrix[2][2] // b.Cb
*
* colorOffset[0] // Y
* colorOffset[1] // Cr
* colorOffset[2] // Cb
*
* colorScale[0] // Y
* colorScale[1] // Cr
* colorScale[2] // Cb
*
* where the data is used according to the following formulae:
*
* Y = colorOffset[0] + colorScale[0] *
* (R * colorMatrix[0][0] +
* G * colorMatrix[0][1] +
* B * colorMatrix[0][2]);
*
* Cr = colorOffset[1] + colorScale[1] *
* (R * colorMatrix[1][0] +
* G * colorMatrix[1][1] +
* B * colorMatrix[1][2]);
*
* Cb = colorOffset[2] + colorScale[2] *
* (R * colorMatrix[2][0] +
* G * colorMatrix[2][1] +
* B * colorMatrix[2][2]);
*
* Possible errors:
* BadMatch - The NVIDIA driver is not present on that screen.
* BadImplementation - GVO is not available on that screen.
*/
void XNVCTRLSetGvoColorConversion(Display *dpy,
int screen,
float colorMatrix[3][3],
float colorOffset[3],
float colorScale[3]);
/*
* XNVCTRLQueryGvoColorConversion -
*
* Retrieves the color conversion matrix and color offset
* that are currently being used for GVO (Graphic to Video Out).
*
* The values are ordered within the arrays according to the comments
* for XNVCTRLSetGvoColorConversion().
*
* Possible errors:
* BadMatch - The NVIDIA driver is not present on that screen.
* BadImplementation - GVO is not available on that screen.
*/
Bool XNVCTRLQueryGvoColorConversion(Display *dpy,
int screen,
float colorMatrix[3][3],
float colorOffset[3],
float colorScale[3]);
/*
* XNVCTRLQueryBinaryData -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryBinaryData returns True, *ptr will point to an
* allocated block of memory containing the binary data attribute
* requested. It is the caller's responsibility to free the data
* when done. len will list the length of the binary data.
*
* Calling this function is equivalent to calling
* XNVCTRLQueryTargetBinaryData() with the target_type set to
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
*
* Possible errors:
* BadValue - The screen doesn't exist.
* BadMatch - The NVIDIA driver is not present on that screen.
* BadAlloc - Insufficient resources to fulfill the request.
*/
Bool XNVCTRLQueryBinaryData(Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
unsigned char **ptr,
int *len);
/*
* XNVCTRLQueryTargetBinaryData -
*
* Returns True if the attribute exists. Returns False otherwise.
* If XNVCTRLQueryTargetBinaryData returns True, *ptr will point to an
* allocated block of memory containing the binary data attribute
* requested. It is the caller's responsibility to free the data
* when done. len will list the length of the binary data.
*
* Possible errors:
* BadValue - The target doesn't exist.
* BadMatch - The NVIDIA driver does not control the target.
* BadAlloc - Insufficient resources to fulfill the request.
*/
Bool XNVCTRLQueryTargetBinaryData(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
unsigned char **ptr,
int *len);
/*
* XNVCTRLStringOperation -
*
* Takes a string as input and returns a Xmalloc'ed string as output.
* Returns True on success and False on failure.
*/
Bool XNVCTRLStringOperation(Display *dpy,
int target_type,
int target_id,
unsigned int display_mask,
unsigned int attribute,
char *pIn,
char **ppOut);
/*
* XNVCtrlSelectNotify -
*
* This enables/disables receiving of NV-CONTROL events. The type
* specifies the type of event to enable (currently, the only
* type that can be requested per-screen with XNVCtrlSelectNotify()
* is ATTRIBUTE_CHANGED_EVENT); onoff controls whether receiving this
* type of event should be enabled (True) or disabled (False).
*
* Returns True if successful, or False if the screen is not
* controlled by the NVIDIA driver.
*/
Bool XNVCtrlSelectNotify(Display *dpy, int screen, int type, Bool onoff);
/*
* XNVCtrlSelectTargetNotify -
*
* This enables/disables receiving of NV-CONTROL events that happen on
* the specified target. The notify_type specifies the type of event to
* enable (currently, the only type that can be requested per-target with
* XNVCtrlSelectTargetNotify() is TARGET_ATTRIBUTE_CHANGED_EVENT); onoff
* controls whether receiving this type of event should be enabled (True)
* or disabled (False).
*
* Returns True if successful, or False if the target is not
* controlled by the NVIDIA driver.
*/
Bool XNVCtrlSelectTargetNotify(Display *dpy,
int target_type,
int target_id,
int notify_type,
Bool onoff);
/*
* XNVCtrlEvent structure
*/
typedef struct
{
int type;
unsigned long serial;
Bool send_event; /* always FALSE, we don't allow send_events */
Display *display;
Time time;
int screen;
unsigned int display_mask;
unsigned int attribute;
int value;
} XNVCtrlAttributeChangedEvent;
typedef union
{
int type;
XNVCtrlAttributeChangedEvent attribute_changed;
long pad[24];
} XNVCtrlEvent;
/*
* XNVCtrlEventTarget structure
*/
typedef struct
{
int type;
unsigned long serial;
Bool send_event; /* always FALSE, we don't allow send_events */
Display *display;
Time time;
int target_type;
int target_id;
unsigned int display_mask;
unsigned int attribute;
int value;
} XNVCtrlAttributeChangedEventTarget;
typedef union
{
int type;
XNVCtrlAttributeChangedEventTarget attribute_changed;
long pad[24];
} XNVCtrlEventTarget;
/*
* XNVCtrlEventTargetAvailability structure
*/
typedef struct
{
int type;
unsigned long serial;
Bool send_event; /* always FALSE, we don't allow send_events */
Display *display;
Time time;
int target_type;
int target_id;
unsigned int display_mask;
unsigned int attribute;
int value;
Bool availability;
} XNVCtrlAttributeChangedEventTargetAvailability;
typedef union
{
int type;
XNVCtrlAttributeChangedEventTargetAvailability attribute_changed;
long pad[24];
} XNVCtrlEventTargetAvailability;
/*
* XNVCtrlStringEventTarget structure
*/
typedef struct
{
int type;
unsigned long serial;
Bool send_event; /* always FALSE, we don't allow send_events */
Display *display;
Time time;
int target_type;
int target_id;
unsigned int display_mask;
unsigned int attribute;
} XNVCtrlStringAttributeChangedEventTarget;
typedef union
{
int type;
XNVCtrlStringAttributeChangedEventTarget attribute_changed;
long pad[24];
} XNVCtrlStringEventTarget;
/*
* XNVCtrlBinaryEventTarget structure
*/
typedef struct
{
int type;
unsigned long serial;
Bool send_event; /* always FALSE, we don't allow send_events */
Display *display;
Time time;
int target_type;
int target_id;
unsigned int display_mask;
unsigned int attribute;
} XNVCtrlBinaryAttributeChangedEventTarget;
typedef union
{
int type;
XNVCtrlBinaryAttributeChangedEventTarget attribute_changed;
long pad[24];
} XNVCtrlBinaryEventTarget;
#if defined __cplusplus
} /* extern "C" */
#endif
#endif /* __NVCTRLLIB_H */
Name: NVidia Control X Extension Library
Short Name: libXNVCtrl
URL: http://cgit.freedesktop.org/~aplattner/nvidia-settings/
Version: unknown
Date: 2008
License: MIT
Security Critical: no
Description:
This package provides access to NVidia Control X Extension. It is used to determine the version of the NVIDIA driver in use.
The current version is pulled from nvidia-settings-302.17.
Local Modifications:
# Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets':
[{
'target_name': 'libXNVCtrl',
'type': 'static_library',
'sources':
[
'NVCtrl.c',
'NVCtrl.h',
'NVCtrlLib.h',
'nv_control.h',
],
}],
}
/*
* Copyright (c) 2008 NVIDIA, Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
* NV-CONTROL Protocol Version History
*
* 1.0 - 1.5 NVIDIA Internal development versions
* 1.6 Initial public version
* 1.7 Added QueryBinaryData request
* 1.8 Added TargetTypes
* 1.9 Added QueryTargetCount request
* 1.10 Fixed target type/id byte ordering for compatibility with
* pre-1.8 NV-CONTROL clients
* 1.11 NVIDIA Internal development version
* 1.12 Added StringOperation request
* 1.13 NVIDIA Internal development version
* 1.14 Fixed an NV_CTRL_BINARY_DATA_MODELINES double scan modeline
* reporting bug (vsyncstart, vsyncend, and vtotal were incorrectly
* doubled)
* 1.15 Added AVAILABILITY_TARGET_ATTRIBUTE_CHANGED_EVENT
* 1.16 Added TARGET_STRING_ATTRIBUTE_CHANGED_EVENT
* 1.17 Added TARGET_BINARY_ATTRIBUTE_CHANGED_EVENT
* 1.18 Updated QueryTargetCount to return a count of 0, rather than
* BadMatch, if an unknown TargetType is specified
* 1.19 Added TargetType support for SetAttributeAndGetStatus and
* SetStringAttribute requests
* 1.20 Added COOLER TargetType
* 1.21 Added initial 64-bit integer attribute support (read-only)
* 1.22 Added X_nvCtrlQueryValidStringAttributeValues to check
* string attribute permissions.
* 1.23 Added SENSOR TargetType
* 1.24 Fixed a bug where SLI_MOSAIC_MODE_AVAILABLE attribute would
* report false positives via the GPU and X screen target types
* 1.25 Added 3D_VISION_PRO_TRANSCEIVER TargetType
* 1.26 Added XNVCTRLQueryXXXAttributePermissions.
* 1.27 Added DISPLAY TargetType
* 1.28 Added NV_CTRL_CURRENT_METAMODE_ID: clients should use this
* attribute to switch MetaModes, rather than pass the MetaMode ID
* through the RRSetScreenConfig protocol request.
*/
#ifndef __NVCONTROL_H
#define __NVCONTROL_H
#define NV_CONTROL_ERRORS 0
#define NV_CONTROL_EVENTS 5
#define NV_CONTROL_NAME "NV-CONTROL"
#define NV_CONTROL_MAJOR 1
#define NV_CONTROL_MINOR 28
#define X_nvCtrlQueryExtension 0
#define X_nvCtrlIsNv 1
#define X_nvCtrlQueryAttribute 2
#define X_nvCtrlSetAttribute 3
#define X_nvCtrlQueryStringAttribute 4
#define X_nvCtrlQueryValidAttributeValues 5
#define X_nvCtrlSelectNotify 6
#define X_nvCtrlSetGvoColorConversionDeprecated 7
#define X_nvCtrlQueryGvoColorConversionDeprecated 8
#define X_nvCtrlSetStringAttribute 9
/* STUB X_nvCtrlQueryDDCCILutSize 10 */
/* STUB X_nvCtrlQueryDDCCISinglePointLutOperation 11 */
/* STUB X_nvCtrlSetDDCCISinglePointLutOperation 12 */
/* STUB X_nvCtrlQueryDDCCIBlockLutOperation 13 */
/* STUB X_nvCtrlSetDDCCIBlockLutOperation 14 */
/* STUB X_nvCtrlSetDDCCIRemoteProcedureCall 15 */
/* STUB X_nvCtrlQueryDDCCIDisplayControllerType 16 */
/* STUB X_nvCtrlQueryDDCCICapabilities 17 */
/* STUB X_nvCtrlQueryDDCCITimingReport 18 */
#define X_nvCtrlSetAttributeAndGetStatus 19
#define X_nvCtrlQueryBinaryData 20
#define X_nvCtrlSetGvoColorConversion 21
#define X_nvCtrlQueryGvoColorConversion 22
#define X_nvCtrlSelectTargetNotify 23
#define X_nvCtrlQueryTargetCount 24
#define X_nvCtrlStringOperation 25
#define X_nvCtrlQueryValidAttributeValues64 26
#define X_nvCtrlQueryAttribute64 27
#define X_nvCtrlQueryValidStringAttributeValues 28
#define X_nvCtrlQueryAttributePermissions 29
#define X_nvCtrlQueryStringAttributePermissions 30
#define X_nvCtrlQueryBinaryDataAttributePermissions 31
#define X_nvCtrlQueryStringOperationAttributePermissions 32
#define X_nvCtrlLastRequest (X_nvCtrlQueryStringOperationAttributePermissions + 1)
/* Define 32 bit floats */
typedef float FLOAT32;
#ifndef F32
#define F32
#endif
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
} xnvCtrlQueryExtensionReq;
#define sz_xnvCtrlQueryExtensionReq 4
typedef struct
{
BYTE type; /* X_Reply */
CARD8 padb1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD16 major B16;
CARD16 minor B16;
CARD32 padl4 B32;
CARD32 padl5 B32;
CARD32 padl6 B32;
CARD32 padl7 B32;
CARD32 padl8 B32;
} xnvCtrlQueryExtensionReply;
#define sz_xnvCtrlQueryExtensionReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
} xnvCtrlIsNvReq;
#define sz_xnvCtrlIsNvReq 8
typedef struct
{
BYTE type; /* X_Reply */
CARD8 padb1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 isnv B32;
CARD32 padl4 B32;
CARD32 padl5 B32;
CARD32 padl6 B32;
CARD32 padl7 B32;
CARD32 padl8 B32;
} xnvCtrlIsNvReply;
#define sz_xnvCtrlIsNvReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 target_type B32;
} xnvCtrlQueryTargetCountReq;
#define sz_xnvCtrlQueryTargetCountReq 8
typedef struct
{
BYTE type; /* X_Reply */
CARD8 padb1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 count B32;
CARD32 padl4 B32;
CARD32 padl5 B32;
CARD32 padl6 B32;
CARD32 padl7 B32;
CARD32 padl8 B32;
} xnvCtrlQueryTargetCountReply;
#define sz_xnvCtrlQueryTargetCountReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16; /* X screen number or GPU number */
CARD16 target_type B16; /* X screen or GPU */
CARD32 display_mask B32;
CARD32 attribute B32;
} xnvCtrlQueryAttributeReq;
#define sz_xnvCtrlQueryAttributeReq 16
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
INT32 value B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xnvCtrlQueryAttributeReply;
#define sz_xnvCtrlQueryAttributeReply 32
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
CARD32 pad3 B32;
int64_t value_64;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xnvCtrlQueryAttribute64Reply;
#define sz_xnvCtrlQueryAttribute64Reply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16;
CARD16 target_type B16;
CARD32 display_mask B32;
CARD32 attribute B32;
INT32 value B32;
} xnvCtrlSetAttributeReq;
#define sz_xnvCtrlSetAttributeReq 20
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16;
CARD16 target_type B16;
CARD32 display_mask B32;
CARD32 attribute B32;
INT32 value B32;
} xnvCtrlSetAttributeAndGetStatusReq;
#define sz_xnvCtrlSetAttributeAndGetStatusReq 20
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xnvCtrlSetAttributeAndGetStatusReply;
#define sz_xnvCtrlSetAttributeAndGetStatusReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16; /* X screen number or GPU number */
CARD16 target_type B16; /* X screen or GPU */
CARD32 display_mask B32;
CARD32 attribute B32;
} xnvCtrlQueryStringAttributeReq;
#define sz_xnvCtrlQueryStringAttributeReq 16
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
CARD32 n B32; /* Length of string */
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xnvCtrlQueryStringAttributeReply;
#define sz_xnvCtrlQueryStringAttributeReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16;
CARD16 target_type B16;
CARD32 display_mask B32;
CARD32 attribute B32;
CARD32 num_bytes B32;
} xnvCtrlSetStringAttributeReq;
#define sz_xnvCtrlSetStringAttributeReq 20
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xnvCtrlSetStringAttributeReply;
#define sz_xnvCtrlSetStringAttributeReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16; /* X screen number or GPU number */
CARD16 target_type B16; /* X screen or GPU */
CARD32 display_mask B32;
CARD32 attribute B32;
} xnvCtrlQueryValidAttributeValuesReq;
#define sz_xnvCtrlQueryValidAttributeValuesReq 16
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
INT32 attr_type B32;
INT32 min B32;
INT32 max B32;
CARD32 bits B32;
CARD32 perms B32;
} xnvCtrlQueryValidAttributeValuesReply;
#define sz_xnvCtrlQueryValidAttributeValuesReply 32
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
INT32 attr_type B32;
int64_t min_64;
int64_t max_64;
CARD64 bits_64;
CARD32 perms B32;
CARD32 pad1 B32;
} xnvCtrlQueryValidAttributeValues64Reply;
#define sz_xnvCtrlQueryValidAttributeValues64Reply 48
#define sz_xnvCtrlQueryValidAttributeValues64Reply_extra ((48 - 32) >> 2)
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 attribute B32;
} xnvCtrlQueryAttributePermissionsReq;
#define sz_xnvCtrlQueryAttributePermissionsReq 8
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
INT32 attr_type B32;
CARD32 perms B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
} xnvCtrlQueryAttributePermissionsReply;
#define sz_xnvCtrlQueryAttributePermissionsReply 32
/* Set GVO Color Conversion request (deprecated) */
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
FLOAT32 row1_col1 F32;
FLOAT32 row1_col2 F32;
FLOAT32 row1_col3 F32;
FLOAT32 row1_col4 F32;
FLOAT32 row2_col1 F32;
FLOAT32 row2_col2 F32;
FLOAT32 row2_col3 F32;
FLOAT32 row2_col4 F32;
FLOAT32 row3_col1 F32;
FLOAT32 row3_col2 F32;
FLOAT32 row3_col3 F32;
FLOAT32 row3_col4 F32;
} xnvCtrlSetGvoColorConversionDeprecatedReq;
#define sz_xnvCtrlSetGvoColorConversionDeprecatedReq 56
/* Query GVO Color Conversion request (deprecated) */
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
} xnvCtrlQueryGvoColorConversionDeprecatedReq;
#define sz_xnvCtrlQueryGvoColorConversionDeprecatedReq 8
/* Query GVO Color Conversion reply (deprecated) */
typedef struct
{
BYTE type; /* X_Reply */
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
} xnvCtrlQueryGvoColorConversionDeprecatedReply;
#define sz_xnvCtrlQueryGvoColorConversionDeprecatedReply 32
/* Set GVO Color Conversion request */
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
FLOAT32 cscMatrix_y_r F32;
FLOAT32 cscMatrix_y_g F32;
FLOAT32 cscMatrix_y_b F32;
FLOAT32 cscMatrix_cr_r F32;
FLOAT32 cscMatrix_cr_g F32;
FLOAT32 cscMatrix_cr_b F32;
FLOAT32 cscMatrix_cb_r F32;
FLOAT32 cscMatrix_cb_g F32;
FLOAT32 cscMatrix_cb_b F32;
FLOAT32 cscOffset_y F32;
FLOAT32 cscOffset_cr F32;
FLOAT32 cscOffset_cb F32;
FLOAT32 cscScale_y F32;
FLOAT32 cscScale_cr F32;
FLOAT32 cscScale_cb F32;
} xnvCtrlSetGvoColorConversionReq;
#define sz_xnvCtrlSetGvoColorConversionReq 68
/* Query GVO Color Conversion request */
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
} xnvCtrlQueryGvoColorConversionReq;
#define sz_xnvCtrlQueryGvoColorConversionReq 8
/* Query GVO Color Conversion reply */
typedef struct
{
BYTE type; /* X_Reply */
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
} xnvCtrlQueryGvoColorConversionReply;
#define sz_xnvCtrlQueryGvoColorConversionReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16; /* X screen number or GPU number */
CARD16 target_type B16; /* X screen or GPU */
CARD32 display_mask B32;
CARD32 attribute B32;
} xnvCtrlQueryBinaryDataReq;
#define sz_xnvCtrlQueryBinaryDataReq 16
typedef struct
{
BYTE type;
BYTE pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 flags B32;
CARD32 n B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xnvCtrlQueryBinaryDataReply;
#define sz_xnvCtrlQueryBinaryDataReply 32
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
CARD16 notifyType B16;
CARD16 onoff B16;
} xnvCtrlSelectNotifyReq;
#define sz_xnvCtrlSelectNotifyReq 12
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_id B16; /* X screen number or GPU number */
CARD16 target_type B16; /* X screen or GPU */
CARD32 display_mask B32;
CARD32 attribute B32;
CARD32 num_bytes B32; /* Length of string */
} xnvCtrlStringOperationReq;
#define sz_xnvCtrlStringOperationReq 20
typedef struct
{
BYTE type; /* X_Reply */
CARD8 padb1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 ret B32;
CARD32 num_bytes B32; /* Length of string */
CARD32 padl4 B32;
CARD32 padl5 B32;
CARD32 padl6 B32;
CARD32 padl7 B32;
} xnvCtrlStringOperationReply;
#define sz_xnvCtrlStringOperationReply 32
typedef struct
{
union
{
struct
{
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
} u;
struct
{
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
CARD32 time B32;
CARD32 screen B32;
CARD32 display_mask B32;
CARD32 attribute B32;
CARD32 value B32;
CARD32 pad0 B32;
CARD32 pad1 B32;
} attribute_changed;
} u;
} xnvctrlEvent;
/*
* Leave target_type before target_id for the
* xnvCtrlSelectTargetNotifyReq and xnvctrlEventTarget
* structures, even though other request protocol structures
* store target_id in the bottom 16-bits of the second DWORD of the
* structures. The event-related structures were added in version
* 1.8, and so there is no prior version with which to maintain
* compatibility.
*/
typedef struct
{
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD16 target_type B16; /* Don't swap these */
CARD16 target_id B16;
CARD16 notifyType B16;
CARD16 onoff B16;
} xnvCtrlSelectTargetNotifyReq;
#define sz_xnvCtrlSelectTargetNotifyReq 12
typedef struct
{
union
{
struct
{
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
} u;
struct
{
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
CARD32 time B32;
CARD16 target_type B16; /* Don't swap these */
CARD16 target_id B16;
CARD32 display_mask B32;
CARD32 attribute B32;
CARD32 value B32;
CARD32 pad0 B32;
CARD32 pad1 B32;
} attribute_changed;
struct
{
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
CARD32 time B32;
CARD16 target_type B16; /* Don't swap these */
CARD16 target_id B16;
CARD32 display_mask B32;
CARD32 attribute B32;
CARD32 value B32;
CARD8 availability;
CARD8 pad0;
CARD16 pad1 B16;
CARD32 pad2 B32;
} availability_changed;
} u;
} xnvctrlEventTarget;
#endif /* __NVCONTROL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment