Port Linux GLimp to SDL

Use SDL to set video modes, get a GL context and detect the
amount of VRAM.
As with the Linux GLimp implementation, sys_videoRam can be used
in case the SDL detection fails.
This commit is contained in:
dhewg 2011-12-29 19:19:57 +01:00
parent 1ecf98416c
commit 502aaa6fe2
14 changed files with 277 additions and 2774 deletions

View file

@ -98,7 +98,6 @@ include_directories(${SDL_INCLUDE_DIR})
if (UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
add_definitions(-DXTHREADS)
include_directories(${X11_INCLUDE_DIR})
if (os MATCHES ".*bsd" OR os STREQUAL "dragonfly")
@ -685,10 +684,9 @@ else()
set(src_sys_core
${src_stub_util}
sys/glimp.cpp
sys/posix/posix_input.cpp
sys/linux/glimp.cpp
sys/linux/input.cpp
sys/linux/libXNVCtrl/NVCtrl.c
)
endif()

View file

@ -279,8 +279,6 @@ BASECPPFLAGS.append( '-pipe' )
# warn all
BASECPPFLAGS.append( '-Wall' )
BASECPPFLAGS.append( '-Wno-unknown-pragmas' )
# this define is necessary to make sure threading support is enabled in X
CORECPPFLAGS.append( '-DXTHREADS' )
# gcc 4.x option only - only export what we mean to from the game SO
BASECPPFLAGS.append( '-fvisibility=hidden' )

View file

@ -2797,7 +2797,8 @@ idCommonLocal::Init
=================
*/
void idCommonLocal::Init( int argc, char **argv ) {
SDL_Init(SDL_INIT_TIMER);
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO))
Sys_Error("Error while initializing SDL: %s", SDL_GetError());
Sys_InitThreads();
@ -2899,7 +2900,7 @@ void idCommonLocal::Init( int argc, char **argv ) {
async_timer = SDL_AddTimer(USERCMD_MSEC, AsyncTimer, NULL);
if (!async_timer)
Sys_Error("Error while starting the async timer");
Sys_Error("Error while starting the async timer: %s", SDL_GetError());
}

268
neo/sys/glimp.cpp Normal file
View file

@ -0,0 +1,268 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include <SDL.h>
#include <SDL_syswm.h>
#include "sys/platform.h"
#include "framework/Licensee.h"
#include "renderer/tr_local.h"
idCVar sys_videoRam("sys_videoRam", "0", CVAR_SYSTEM | CVAR_ARCHIVE | CVAR_INTEGER, "Texture memory on the video card (in megabytes) - 0: autodetect", 0, 512);
#ifdef __unix__
// workaround until events are ported to sdl
Display *dpy = NULL;
Window win = 0;
bool dga_found = false;
#endif
/*
===================
GLimp_Init
===================
*/
bool GLimp_Init(glimpParms_t parms) {
common->Printf("Initializing OpenGL subsystem\n");
assert(SDL_WasInit(SDL_INIT_VIDEO));
Uint32 flags = SDL_OPENGL;
if (parms.fullScreen)
flags |= SDL_FULLSCREEN;
SDL_Surface *surf = NULL;
int colorbits = 24;
int depthbits = 24;
int stencilbits = 8;
for (int i = 0; i < 16; i++) {
// 0 - default
// 1 - minus colorbits
// 2 - minus depthbits
// 3 - minus stencil
if ((i % 4) == 0 && i) {
// one pass, reduce
switch (i / 4) {
case 2 :
if (colorbits == 24)
colorbits = 16;
break;
case 1 :
if (depthbits == 24)
depthbits = 16;
else if (depthbits == 16)
depthbits = 8;
case 3 :
if (stencilbits == 24)
stencilbits = 16;
else if (stencilbits == 16)
stencilbits = 8;
}
}
int tcolorbits = colorbits;
int tdepthbits = depthbits;
int tstencilbits = stencilbits;
if ((i % 4) == 3) {
// reduce colorbits
if (tcolorbits == 24)
tcolorbits = 16;
}
if ((i % 4) == 2) {
// reduce depthbits
if (tdepthbits == 24)
tdepthbits = 16;
else if (tdepthbits == 16)
tdepthbits = 8;
}
if ((i % 4) == 1) {
// reduce stencilbits
if (tstencilbits == 24)
tstencilbits = 16;
else if (tstencilbits == 16)
tstencilbits = 8;
else
tstencilbits = 0;
}
int channelcolorbits = 4;
if (tcolorbits == 24)
channelcolorbits = 8;
SDL_WM_SetCaption(GAME_NAME, GAME_NAME);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, channelcolorbits);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, channelcolorbits);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, channelcolorbits);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, channelcolorbits);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, tdepthbits);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, tstencilbits);
SDL_GL_SetAttribute(SDL_GL_STEREO, parms.stereo ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, parms.multiSamples ? 1 : 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, parms.multiSamples);
surf = SDL_SetVideoMode(parms.width, parms.height, colorbits, flags);
if (!surf) {
common->DPrintf("Couldn't set GL mode %d/%d/%d: %s",
channelcolorbits, tdepthbits, tstencilbits, SDL_GetError());
continue;
}
common->Printf("Using %d color bits, %d depth, %d stencil display\n",
channelcolorbits, tdepthbits, tstencilbits);
glConfig.colorBits = tcolorbits;
glConfig.depthBits = tdepthbits;
glConfig.stencilBits = tstencilbits;
glConfig.vidWidth = surf->w;
glConfig.vidHeight = surf->h;
glConfig.isFullscreen = (surf->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN;
glConfig.displayFrequency = 0;
break;
}
if (!surf) {
common->Warning("No usable GL mode found: %s", SDL_GetError());
return false;
}
glConfig.wgl_extensions_string = "";
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info)) {
#if defined(__unix__)
// workaround until events are ported to sdl
if (info.subsystem == SDL_SYSWM_X11) {
dpy = info.info.x11.display;
win = info.info.x11.window;
}
#endif
}
return true;
}
/*
===================
GLimp_SetScreenParms
===================
*/
bool GLimp_SetScreenParms(glimpParms_t parms) {
common->DPrintf("TODO: GLimp_ActivateContext\n");
return true;
}
/*
===================
GLimp_Shutdown
===================
*/
void GLimp_Shutdown() {
common->Printf("Shutting down OpenGL subsystem\n");
}
/*
===================
GLimp_SwapBuffers
===================
*/
void GLimp_SwapBuffers() {
SDL_GL_SwapBuffers();
}
/*
=================
GLimp_SetGamma
=================
*/
void GLimp_SetGamma(unsigned short red[256], unsigned short green[256], unsigned short blue[256]) {
if (SDL_SetGammaRamp(red, green, blue))
common->Warning("Couldn't set gamma ramp: %s", SDL_GetError());
}
/*
=================
GLimp_ActivateContext
=================
*/
void GLimp_ActivateContext() {
common->DPrintf("TODO: GLimp_ActivateContext\n");
}
/*
=================
GLimp_DeactivateContext
=================
*/
void GLimp_DeactivateContext() {
common->DPrintf("TODO: GLimp_DeactivateContext\n");
}
/*
===================
GLimp_ExtensionPointer
===================
*/
GLExtension_t GLimp_ExtensionPointer(const char *name) {
assert(SDL_WasInit(SDL_INIT_VIDEO));
return (GLExtension_t)SDL_GL_GetProcAddress(name);
}
/*
================
Sys_GetVideoRam
================
*/
int Sys_GetVideoRam() {
assert(SDL_WasInit(SDL_INIT_VIDEO));
if (sys_videoRam.GetInteger())
return sys_videoRam.GetInteger();
common->Printf("guessing video ram (use +set sys_videoRam to force)\n");
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
return vi->video_mem;
}

View file

@ -67,10 +67,3 @@ returns in megabytes
int Sys_GetVideoRam( void ) {
return 64;
}
/*
==========
GL
==========
*/
bool GLimp_SetScreenParms( glimpParms_t parms ) { return true; }

View file

@ -1,662 +0,0 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <X11/Xlib.h>
extern "C" {
# include "libXNVCtrl/NVCtrlLib.h"
}
#include "sys/platform.h"
#include "framework/Licensee.h"
#include "renderer/tr_local.h"
#include "sys/linux/local.h"
idCVar sys_videoRam( "sys_videoRam", "0", CVAR_SYSTEM | CVAR_ARCHIVE | CVAR_INTEGER, "Texture memory on the video card (in megabytes) - 0: autodetect", 0, 512 );
Display *dpy = NULL;
static int scrnum = 0;
Window win = 0;
bool dga_found = false;
static GLXContext ctx = NULL;
static bool vidmode_ext = false;
static int vidmode_MajorVersion = 0, vidmode_MinorVersion = 0; // major and minor of XF86VidExtensions
static XF86VidModeModeInfo **vidmodes;
static int num_vidmodes;
static bool vidmode_active = false;
// backup gamma ramp
static int save_rampsize = 0;
static unsigned short *save_red, *save_green, *save_blue;
void GLimp_ActivateContext() {
assert( dpy );
assert( ctx );
qglXMakeCurrent( dpy, win, ctx );
}
void GLimp_DeactivateContext() {
assert( dpy );
qglXMakeCurrent( dpy, None, NULL );
}
/*
=================
GLimp_SaveGamma
save and restore the original gamma of the system
=================
*/
void GLimp_SaveGamma() {
if ( save_rampsize ) {
return;
}
assert( dpy );
XF86VidModeGetGammaRampSize( dpy, scrnum, &save_rampsize);
save_red = (unsigned short *)malloc(save_rampsize*sizeof(unsigned short));
save_green = (unsigned short *)malloc(save_rampsize*sizeof(unsigned short));
save_blue = (unsigned short *)malloc(save_rampsize*sizeof(unsigned short));
XF86VidModeGetGammaRamp( dpy, scrnum, save_rampsize, save_red, save_green, save_blue);
}
/*
=================
GLimp_RestoreGamma
save and restore the original gamma of the system
=================
*/
void GLimp_RestoreGamma() {
if (!save_rampsize)
return;
XF86VidModeSetGammaRamp( dpy, scrnum, save_rampsize, save_red, save_green, save_blue);
free(save_red); free(save_green); free(save_blue);
save_rampsize = 0;
}
/*
=================
GLimp_SetGamma
gamma ramp is generated by the renderer from r_gamma and r_brightness for 256 elements
the size of the gamma ramp can not be changed on X (I need to confirm this)
=================
*/
void GLimp_SetGamma(unsigned short red[256], unsigned short green[256], unsigned short blue[256]) {
if ( dpy ) {
int size;
GLimp_SaveGamma();
XF86VidModeGetGammaRampSize( dpy, scrnum, &size);
common->DPrintf("XF86VidModeGetGammaRampSize: %d\n", size);
if ( size > 256 ) {
// silly generic resample
int i;
unsigned short *l_red, *l_green, *l_blue;
l_red = (unsigned short *)malloc(size*sizeof(unsigned short));
l_green = (unsigned short *)malloc(size*sizeof(unsigned short));
l_blue = (unsigned short *)malloc(size*sizeof(unsigned short));
//int r_size = 256;
int r_i; float r_f;
for(i=0; i<size-1; i++) {
r_f = (float)i*255.0f/(float)(size-1);
r_i = (int)floor(r_f);
r_f -= (float)r_i;
l_red[i] = (int)round((1.0f-r_f)*(float)red[r_i]+r_f*(float)red[r_i+1]);
l_green[i] = (int)round((1.0f-r_f)*(float)green[r_i]+r_f*(float)green[r_i+1]);
l_blue[i] = (int)round((1.0f-r_f)*(float)blue[r_i]+r_f*(float)blue[r_i+1]);
}
l_red[size-1] = red[255]; l_green[size-1] = green[255]; l_blue[size-1] = blue[255];
XF86VidModeSetGammaRamp( dpy, scrnum, size, l_red, l_green, l_blue );
free(l_red); free(l_green); free(l_blue);
} else {
XF86VidModeSetGammaRamp( dpy, scrnum, size, red, green, blue );
}
}
}
void GLimp_Shutdown() {
if ( dpy ) {
Sys_XUninstallGrabs();
GLimp_RestoreGamma();
qglXDestroyContext( dpy, ctx );
XDestroyWindow( dpy, win );
if ( vidmode_active ) {
XF86VidModeSwitchToMode( dpy, scrnum, vidmodes[0] );
}
// FIXME: that's going to crash
//XFlush( dpy );
//XCloseDisplay( dpy );
vidmode_active = false;
dpy = NULL;
win = 0;
ctx = NULL;
}
}
void GLimp_SwapBuffers() {
assert( dpy );
qglXSwapBuffers( dpy, win );
}
/*
GLX_TestDGA
Check for DGA - update in_dgamouse if needed
*/
void GLX_TestDGA() {
#if defined( ID_ENABLE_DGA )
int dga_MajorVersion = 0, dga_MinorVersion = 0;
assert( dpy );
if ( !XF86DGAQueryVersion( dpy, &dga_MajorVersion, &dga_MinorVersion ) ) {
// unable to query, probalby not supported
common->Printf( "Failed to detect DGA DirectVideo Mouse\n" );
cvarSystem->SetCVarBool( "in_dgamouse", false );
dga_found = false;
} else {
common->Printf( "DGA DirectVideo Mouse (Version %d.%d) initialized\n",
dga_MajorVersion, dga_MinorVersion );
dga_found = true;
}
#else
dga_found = false;
#endif
}
/*
** XErrorHandler
** the default X error handler exits the application
** I found out that on some hosts some operations would raise X errors (GLXUnsupportedPrivateRequest)
** but those don't seem to be fatal .. so the default would be to just ignore them
** our implementation mimics the default handler behaviour (not completely cause I'm lazy)
*/
int idXErrorHandler(Display * l_dpy, XErrorEvent * ev) {
char buf[1024];
common->Printf( "Fatal X Error:\n" );
common->Printf( " Major opcode of failed request: %d\n", ev->request_code );
common->Printf( " Minor opcode of failed request: %d\n", ev->minor_code );
common->Printf( " Serial number of failed request: %lu\n", ev->serial );
XGetErrorText( l_dpy, ev->error_code, buf, 1024 );
common->Printf( "%s\n", buf );
return 0;
}
bool GLimp_OpenDisplay( void ) {
if ( dpy ) {
return true;
}
if ( cvarSystem->GetCVarInteger( "net_serverDedicated" ) == 1 ) {
common->DPrintf( "not opening the display: dedicated server\n" );
return false;
}
common->Printf( "Setup X display connection\n" );
// that should be the first call into X
if ( !XInitThreads() ) {
common->Printf("XInitThreads failed\n");
return false;
}
// set up our custom error handler for X failures
XSetErrorHandler( &idXErrorHandler );
if ( !( dpy = XOpenDisplay(NULL) ) ) {
common->Printf( "Couldn't open the X display\n" );
return false;
}
scrnum = DefaultScreen( dpy );
return true;
}
/*
===============
GLX_Init
===============
*/
int GLX_Init(glimpParms_t a) {
int attrib[] = {
GLX_RGBA, // 0
GLX_RED_SIZE, 8, // 1, 2
GLX_GREEN_SIZE, 8, // 3, 4
GLX_BLUE_SIZE, 8, // 5, 6
GLX_DOUBLEBUFFER, // 7
GLX_DEPTH_SIZE, 24, // 8, 9
GLX_STENCIL_SIZE, 8, // 10, 11
GLX_ALPHA_SIZE, 8, // 12, 13
None
};
// these match in the array
#define ATTR_RED_IDX 2
#define ATTR_GREEN_IDX 4
#define ATTR_BLUE_IDX 6
#define ATTR_DEPTH_IDX 9
#define ATTR_STENCIL_IDX 11
#define ATTR_ALPHA_IDX 13
Window root;
XVisualInfo *visinfo;
XSetWindowAttributes attr;
XSizeHints sizehints;
unsigned long mask;
int colorbits, depthbits, stencilbits;
int tcolorbits, tdepthbits, tstencilbits;
int actualWidth, actualHeight;
int i;
const char *glstring;
if ( !GLimp_OpenDisplay() ) {
return false;
}
common->Printf( "Initializing OpenGL display\n" );
root = RootWindow( dpy, scrnum );
actualWidth = glConfig.vidWidth;
actualHeight = glConfig.vidHeight;
// Get video mode list
if ( !XF86VidModeQueryVersion( dpy, &vidmode_MajorVersion, &vidmode_MinorVersion ) ) {
vidmode_ext = false;
common->Printf("XFree86-VidModeExtension not available\n");
} else {
vidmode_ext = true;
common->Printf("Using XFree86-VidModeExtension Version %d.%d\n",
vidmode_MajorVersion, vidmode_MinorVersion);
}
GLX_TestDGA();
if ( vidmode_ext ) {
int best_fit, best_dist, dist, x, y;
XF86VidModeGetAllModeLines( dpy, scrnum, &num_vidmodes, &vidmodes );
// Are we going fullscreen? If so, let's change video mode
if ( a.fullScreen ) {
best_dist = 9999999;
best_fit = -1;
for (i = 0; i < num_vidmodes; i++) {
if (a.width > vidmodes[i]->hdisplay ||
a.height > vidmodes[i]->vdisplay)
continue;
x = a.width - vidmodes[i]->hdisplay;
y = a.height - vidmodes[i]->vdisplay;
dist = (x * x) + (y * y);
if (dist < best_dist) {
best_dist = dist;
best_fit = i;
}
}
if (best_fit != -1) {
actualWidth = vidmodes[best_fit]->hdisplay;
actualHeight = vidmodes[best_fit]->vdisplay;
// change to the mode
XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[best_fit]);
vidmode_active = true;
// Move the viewport to top left
// FIXME: center?
XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
common->Printf( "Free86-VidModeExtension Activated at %dx%d\n", actualWidth, actualHeight );
} else {
a.fullScreen = false;
common->Printf( "Free86-VidModeExtension: No acceptable modes found\n" );
}
} else {
common->Printf( "XFree86-VidModeExtension: not fullscreen, ignored\n" );
}
}
// color, depth and stencil
colorbits = 24;
depthbits = 24;
stencilbits = 8;
for (i = 0; i < 16; i++) {
// 0 - default
// 1 - minus colorbits
// 2 - minus depthbits
// 3 - minus stencil
if ((i % 4) == 0 && i) {
// one pass, reduce
switch (i / 4) {
case 2:
if (colorbits == 24)
colorbits = 16;
break;
case 1:
if (depthbits == 24)
depthbits = 16;
else if (depthbits == 16)
depthbits = 8;
case 3:
if (stencilbits == 24)
stencilbits = 16;
else if (stencilbits == 16)
stencilbits = 8;
}
}
tcolorbits = colorbits;
tdepthbits = depthbits;
tstencilbits = stencilbits;
if ((i % 4) == 3) { // reduce colorbits
if (tcolorbits == 24)
tcolorbits = 16;
}
if ((i % 4) == 2) { // reduce depthbits
if (tdepthbits == 24)
tdepthbits = 16;
else if (tdepthbits == 16)
tdepthbits = 8;
}
if ((i % 4) == 1) { // reduce stencilbits
if (tstencilbits == 24)
tstencilbits = 16;
else if (tstencilbits == 16)
tstencilbits = 8;
else
tstencilbits = 0;
}
if (tcolorbits == 24) {
attrib[ATTR_RED_IDX] = 8;
attrib[ATTR_GREEN_IDX] = 8;
attrib[ATTR_BLUE_IDX] = 8;
} else {
// must be 16 bit
attrib[ATTR_RED_IDX] = 4;
attrib[ATTR_GREEN_IDX] = 4;
attrib[ATTR_BLUE_IDX] = 4;
}
attrib[ATTR_DEPTH_IDX] = tdepthbits; // default to 24 depth
attrib[ATTR_STENCIL_IDX] = tstencilbits;
visinfo = qglXChooseVisual(dpy, scrnum, attrib);
if (!visinfo) {
continue;
}
common->Printf( "Using %d/%d/%d Color bits, %d Alpha bits, %d depth, %d stencil display.\n",
attrib[ATTR_RED_IDX], attrib[ATTR_GREEN_IDX],
attrib[ATTR_BLUE_IDX], attrib[ATTR_ALPHA_IDX],
attrib[ATTR_DEPTH_IDX],
attrib[ATTR_STENCIL_IDX]);
glConfig.colorBits = tcolorbits;
glConfig.depthBits = tdepthbits;
glConfig.stencilBits = tstencilbits;
break;
}
if (!visinfo) {
common->Printf("Couldn't get a visual\n");
return false;
}
// window attributes
attr.background_pixel = BlackPixel(dpy, scrnum);
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = X_MASK;
if (vidmode_active) {
mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore |
CWEventMask | CWOverrideRedirect;
attr.override_redirect = True;
attr.backing_store = NotUseful;
attr.save_under = False;
} else {
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
}
win = XCreateWindow(dpy, root, 0, 0,
actualWidth, actualHeight,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
XStoreName(dpy, win, GAME_NAME);
// don't let the window be resized
// FIXME: allow resize (win32 does)
sizehints.flags = PMinSize | PMaxSize;
sizehints.min_width = sizehints.max_width = actualWidth;
sizehints.min_height = sizehints.max_height = actualHeight;
XSetWMNormalHints(dpy, win, &sizehints);
XMapWindow( dpy, win );
if ( vidmode_active ) {
XMoveWindow( dpy, win, 0, 0 );
}
XFlush(dpy);
XSync(dpy, False);
ctx = qglXCreateContext(dpy, visinfo, NULL, True);
XSync(dpy, False);
// Free the visinfo after we're done with it
XFree(visinfo);
qglXMakeCurrent(dpy, win, ctx);
glstring = (const char *) qglGetString(GL_RENDERER);
common->Printf("GL_RENDERER: %s\n", glstring);
glstring = (const char *) qglGetString(GL_EXTENSIONS);
common->Printf("GL_EXTENSIONS: %s\n", glstring);
// FIXME: here, software GL test
glConfig.isFullscreen = a.fullScreen;
if ( glConfig.isFullscreen ) {
Sys_GrabMouseCursor( true );
}
return true;
}
/*
===================
GLimp_Init
This is the platform specific OpenGL initialization function. It
is responsible for loading OpenGL, initializing it,
creating a window of the appropriate size, doing
fullscreen manipulations, etc. Its overall responsibility is
to make sure that a functional OpenGL subsystem is operating
when it returns to the ref.
If there is any failure, the renderer will revert back to safe
parameters and try again.
===================
*/
bool GLimp_Init( glimpParms_t a ) {
if ( !GLimp_OpenDisplay() ) {
return false;
}
if (!GLX_Init(a)) {
return false;
}
return true;
}
/*
===================
GLimp_SetScreenParms
===================
*/
bool GLimp_SetScreenParms( glimpParms_t parms ) {
return true;
}
/*
================
Sys_GetVideoRam
returns in megabytes
open your own display connection for the query and close it
using the one shared with GLimp_Init is not stable
================
*/
int Sys_GetVideoRam( void ) {
static int run_once = 0;
int major, minor, value;
Display *l_dpy;
int l_scrnum;
if ( run_once ) {
return run_once;
}
if ( sys_videoRam.GetInteger() ) {
run_once = sys_videoRam.GetInteger();
return sys_videoRam.GetInteger();
}
// try a few strategies to guess the amount of video ram
common->Printf( "guessing video ram ( use +set sys_videoRam to force ) ..\n" );
if ( !GLimp_OpenDisplay( ) ) {
run_once = 64;
return run_once;
}
l_dpy = dpy;
l_scrnum = scrnum;
// go for nvidia ext first
if ( XNVCTRLQueryVersion( l_dpy, &major, &minor ) ) {
common->Printf( "found XNVCtrl extension %d.%d\n", major, minor );
if ( XNVCTRLIsNvScreen( l_dpy, l_scrnum ) ) {
if ( XNVCTRLQueryAttribute( l_dpy, l_scrnum, 0, NV_CTRL_VIDEO_RAM, &value ) ) {
run_once = value / 1024;
return run_once;
} else {
common->Printf( "XNVCtrlQueryAttribute NV_CTRL_VIDEO_RAM failed\n" );
}
} else {
common->Printf( "default screen %d is not controlled by NVIDIA driver\n", l_scrnum );
}
}
// try ATI /proc read ( for the lack of a better option )
int fd;
if ( ( fd = open( "/proc/dri/0/umm", O_RDONLY ) ) != -1 ) {
int len;
char umm_buf[ 1024 ];
char *line;
if ( ( len = read( fd, umm_buf, 1024 ) ) != -1 ) {
// should be way enough to get the full file
// grab "free LFB = " line and "free Inv = " lines
umm_buf[ len-1 ] = '\0';
line = umm_buf;
line = strtok( umm_buf, "\n" );
int total = 0;
while ( line ) {
if ( strlen( line ) >= 13 && strstr( line, "max LFB =" ) == line ) {
total += atoi( line + 12 );
} else if ( strlen( line ) >= 13 && strstr( line, "max Inv =" ) == line ) {
total += atoi( line + 12 );
}
line = strtok( NULL, "\n" );
}
if ( total ) {
run_once = total / 1048576;
// round to the lower 16Mb
run_once &= ~15;
return run_once;
}
} else {
common->Printf( "read /proc/dri/0/umm failed: %s\n", strerror( errno ) );
}
}
common->Printf( "guess failed, return default low-end VRAM setting ( 64MB VRAM )\n" );
run_once = 64;
return run_once;
}
/*
===================
GLimp_ExtensionPointer
===================
*/
static void StubFunction( void ) { }
GLExtension_t GLimp_ExtensionPointer( const char *name ) {
if ( strstr( name, "wgl" ) == name ) {
common->DPrintf( "WARNING: GLimp_ExtensionPointer for '%s'\n", name );
}
#ifdef ID_DEDICATED
common->Printf("GLimp_ExtensionPointer %s\n", name);
return StubFunction;
#else
GLExtension_t ret;
#if defined(__unix__)
// for some reason glXGetProcAddressARB doesn't work on RH9?
ret = qglXGetProcAddressARB((const GLubyte *) name);
if ( !ret ) {
common->Printf("glXGetProcAddressARB failed: \"%s\"\n", name);
return StubFunction;
}
#else
#error Need OS define
#endif
return ret;
#endif
}

View file

@ -1,385 +0,0 @@
NV-CONTROL X Extension - API specificiation v 1.6
1. INTRODUCTION
The NV-CONTROL X extension provides a mechanism for X clients to
query and set configuration parameters of the NVIDIA X driver.
State set by the NV-CONTROL X extension is assumed to be persistent
only for the current server generation.
Attributes are configurable on a per X screen basis, and some
attributes are also configurable on a per display device basis.
Addtionally, some attributes can only be queried, though most can
be both queried and modified. The NV-CONTROL extension provides
a mechanism to determine what values are valid for an attribute,
if an attribute is read-only, if it can be read and written, if it
requires a display device qualifier, and if the the attribute is
available on the specified X screen.
Finally, NV-CONTROL clients may also request to be notified when an
attribute is changed by any other NV-CONTROL client.
2. DISPLAY DEVICES
A "Display Device" refers to some piece of hardware capable of
displaying an image. Display devices are separated into the three
general categories: analog CRTs, digital flatpanels, and TVs.
Note that analog flatpanels fall under the category of analog CRTs.
The NVIDIA X driver allows multiple display devices to display
portions of the same X screen; this is configured through the
TwinView feature of the NVIDIA X driver. TwinView is described in
the Appendix on TwinView in the NVIDIA Linux driver text README file.
A consequence of TwinView is that an X screen does not necessarily
uniquely identify a display device.
While most attributes controlled by the NV-CONTROL X extension
apply to an entire X screen, some attributes can be controlled per
display device. When querying and assigning such attributes, the
particular display device is specified via a display device mask.
A "display device mask" is an unsigned 32 bit value that identifies
one or more display devices: the first 8 bits each identify a CRT, the
next 8 bits each identify a TV, and the next 8 each identify a DFP.
For example, 0x1 refers to CRT-0, 0x3 refers to CRT-0 and CRT-1,
0x10001 refers to CRT-0 and DFP-0, etc.
3. QUERYING THE EXTENSION
NV-CONTROL clients can query for the existence of the NV-CONTROL X
extension with:
Bool XNVCTRLQueryExtension (Display *dpy,
int *event_basep, int *error_basep);
This function returns True if the extension exists, and returns False
if the extension does not. It also returns the error and event bases.
The arguments are:
dpy - The connection to the X server.
event_basep - The returned event base. Currently, only one
extension specific event is defined.
error_basep - The returned error base. Currently, no extension
specific errors are defined.
The version of the NV-CONTROL extension can be queried with:
Bool XNVCTRLQueryVersion (Display *dpy, int *major, int *minor);
This function returns True if the extension exists, and returns
False if it does not. It also returns the major and minor version
numbers of the extension. The arguments are:
dpy - The connection to the X server.
major - The returned major version number of the extension.
minor - The returned minor version number of the extension.
You can determine if a particular X screen is controlled by the
NVIDIA X driver (and thus supports the NV-CONTROL X extension) with:
Bool XNVCTRLIsNvScreen (Display *dpy, int screen);
This function returns True if the specified screen is controlled by
the NVIDIA driver, and thus supports the NV-CONTROL X extension.
It returns False if the specified screen does not support the
NV-CONTROL X extension. The arguments are:
dpy - The connection to the X server.
screen - the X screen to query.
4. QUERYING VALID ATTRIBUTE VALUES
NV-CONTROL clients can query the valid values for any integer
attribute with:
Bool XNVCTRLQueryValidAttributeValues (Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec
*values);
This function returns True if the attribute exists on the specified
X screen, or False if the attribute is not available on the specified
X screen.
The arguments are:
dpy - The connection to the X server.
screen - the X screen to query.
display_mask - for attributes that can be controlled on a per
display device basis, the display_mask should
uniquely identify a single display device.
This argument is ignored for attributes that
apply to the entire X screen.
attribute - the integer attribute to query
values - the returned NVCTRLAttributeValidValuesRec structure.
The NVCTRLAttributeValidValuesRec structure is defined as:
typedef struct _NVCTRLAttributeValidValues {
int type;
union {
struct {
int min;
int max;
} range;
struct {
unsigned int ints;
} bits;
} u;
unsigned int permissions;
} NVCTRLAttributeValidValuesRec;
Where type can be one of:
#define ATTRIBUTE_TYPE_UNKNOWN 0
#define ATTRIBUTE_TYPE_INTEGER 1
#define ATTRIBUTE_TYPE_BITMASK 2
#define ATTRIBUTE_TYPE_BOOL 3
#define ATTRIBUTE_TYPE_RANGE 4
#define ATTRIBUTE_TYPE_INT_BITS 5
ATTRIBUTE_TYPE_INTEGER indicates that the attribute is an integer
value; any integer may be specified when setting this attribute.
ATTRIBUTE_TYPE_BITMASK indicates that the attribute is an integer
value, interpretted as a bitmask. This is the type, for example,
of the NV_CTRL_CONNECTED_DISPLAYS attribute.
ATTRIBUTE_TYPE_BOOL indicates that the attribute is a boolean;
valid values are 1 (on/true) and 0 (off/false).
ATTRIBUTE_TYPE_RANGE indicates that the attribute can have any
integer value between NVCTRLAttributeValidValues.u.range.min and
NVCTRLAttributeValidValues.u.range.max (inclusive).
ATTRIBUTE_TYPE_INT_BITS indicates that the attribute can
only have certain integer values, indicated by which bits in
NVCTRLAttributeValidValues.u.bits.ints are on (for example: if bit
0 is on, then 0 is a valid value; if bit 5 is on, then 5 is a valid
value, etc). This is the type, for example, of NV_CTRL_FSAA_MODE.
The permissions field in NVCTRLAttributeValidValuesRec is a bitmask
that can contain any of:
#define ATTRIBUTE_TYPE_READ 0x1
#define ATTRIBUTE_TYPE_WRITE 0x2
#define ATTRIBUTE_TYPE_DISPLAY 0x4
ATTRIBUTE_TYPE_READ indicates that the attribute is readable; in
general, all attributes will be readable.
ATTRIBUTE_TYPE_WRITE indicates that the attribute is writable;
attributes may not be writable for various reasons: they represent
static system information, they can only be changed by changing an
XF86Config option, etc.
ATTRIBUTE_TYPE_DISPLAY indicates that the attribute can be
controlled on a per display device basis, and thus
XNVCTRLQueryAttribute() and XNVCTRLSetAttribute() require that a
display device be specified.
The XNVCTRLQueryValidAttributeValues() function can cause the
following X protocol errors:
BadValue - The screen does not exist.
BadMatch - The NVIDIA driver is not present on that screen.
5. QUERYING ATTRIBUTE VALUES
NV-CONTROL clients can query the current value of an integer
attribute with:
Bool XNVCTRLQueryAttribute (Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int *value);
This function returns True if the attribute exists, and stores the
current attribute value in the memory pointed to by the value
argument. False is returned if the attribute does not exist on the
specified X screen.
The arguments are:
dpy - The connection to the X server.
screen - the X screen to query.
display_mask - if the attribute requires a display device,
then this indicates the display device to query;
this field is ignored if the attribute is not
display device specific. You can determine
if an attribute is display device specific by
querying the valid values and checking for the
ATTRIBUTE_TYPE_DISPLAY bit in the permissions
field.
attribute - the attribute to query.
value - the returned attribute value.
This function can cause the following X protocol errors:
BadValue - The screen does not exist.
BadMatch - The NVIDIA driver is not present on that screen.
NV-CONTROL clients can query the read-only string attributes with:
Bool XNVCTRLQueryStringAttribute (Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
char **ptr);
This function returns True if the string attribute exists;
or it returns False if the string attribute does not exist. 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 with XFree().
The arguments are:
dpy - The connection to the X server.
screen - the X screen to query.
display_mask - if the attribute requires a display device,
then this indicates the display device to query;
this field is ignored if the attribute is not
display device specific.
attribute - the string attribute to query
ptr - the returned allocated string
This function can cause the following X protocol errors:
BadValue - The screen does not exist.
BadMatch - The NVIDIA driver is not present on that screen.
BadAlloc - Insufficient resources to fulfill the request.
See NVCtrl.h (distributed in the src/libXNVCtrl/ directory of
the nvidia-settings source package) for a list of possible string
attributes.
6. ASSIGNING ATTRIBUTE VALUES
An integer attribute can be assigned a value with:
void XNVCTRLSetAttribute (Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int value);
This function sets the attribute to the given value. This function
does not have a return value. Note that, because it does not
return a value, XNVCTRLSetAttribute() only queues the request in
the X command stream. The command will not actually be sent to
the server until an X command that flushes the X command stream
(such as XFlush(), or any API command that queries a value from the
server) is called.
The arguments are:
dpy - The connection to the X server.
screen - the X screen to query.
display_mask - if the attribute requires a display device,
then this indicates the display device to set;
this field is ignored if the attribute is not
display device specific. You can determine
if an attribute is display device specific by
querying the valid values and checking for the
ATTRIBUTE_TYPE_DISPLAY bit in the permissions
field.
attribute - the attribute to set.
value - the value the attribute should be set to.
See NVCtrl.h (distributed in the src/libXNVCtrl/ directory of
the nvidia-settings source package) for a list of possible integer
attributes.
This function can cause the following X protocol errors:
BadMatch - The NVIDIA driver is not present on that screen.
BadValue - The screen does not exist, or an invalid value is
specified, or the attribute does not exist on the
specified X screen, or the attribute requires a
display device and display_mask does not uniquely
identify a display device.
Before calling XNVCTRLSetAttribute(), an NV-CONTROL client should
use XNVCTRLQueryAttribute() or XNVCTRLQueryValidAttributeValues()
to determine if the attribute exists on the specified X screen;
if the attribute does not exist and XNVCTRLSetAttribute()
is called for that attribute, then a BadValue X protocol error will
be triggered.
7. SELECTING EVENT NOTIFICATION
NV-CONTROL clients can enable NV-CONTROL events with:
Bool XNVCtrlSelectNotify (Display *dpy,
int screen,
int type,
Bool onoff);
This function returns True if the extension exists, or False if the
extension does not exist. The arguments are:
dpy - The connection to the X server.
screen - the X screen on which to enable events.
type - the type of event to enable; currently, the only NV-CONTROL
event type is ATTRIBUTE_CHANGED_EVENT.
onoff - whether to enable (True) or disable (False) receiving
this event type.
This function can cause the following X protocol errors:
BadValue - The screen does not exist.
BadMatch - The NVIDIA driver is not present on that screen.
When an NV-CONTROL client changes an integer attribute value, all
other NV-CONTROL clients with ATTRIBUTE_CHANGED_EVENT notificaion
enabled will receive an XEvent where XEvent.type is equal to:
event_base + ATTRIBUTE_CHANGED_EVENT
where event_base is the event base returned by
XNVCTRLQueryExtension(). The XEvent can then be cast as an
XNVCtrlAttributeChangedEvent 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;
The screen, display_mask, attribute, and value fields correspond to
the arguments passed to XNVCTRLSetAttribute().
8. NV-CONTROL EXTENSION HISTORY
1.0 - 1.5 NVIDIA Internal development versions
1.6 Initial public version

View file

@ -1,339 +0,0 @@
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xext.h>
#include "extutil.h"
#include "NVCtrlLib.h"
#include "nv_control.h"
#if !defined(XTHREADS)
#warning XTHREADS not defined -- this libXNVCtrl.a will not be thread safe!
#endif
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 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, NULL)
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info)
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;
}
}
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;
}
void XNVCTRLSetAttribute (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
int value
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlSetAttributeReq *req;
XNVCTRLSimpleCheckExtension (dpy, info);
LockDisplay (dpy);
GetReq (nvCtrlSetAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlSetAttribute;
req->screen = screen;
req->display_mask = display_mask;
req->attribute = attribute;
req->value = value;
UnlockDisplay (dpy);
SyncHandle ();
}
Bool XNVCTRLQueryAttribute (
Display *dpy,
int screen,
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);
LockDisplay (dpy);
GetReq (nvCtrlQueryAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryAttribute;
req->screen = screen;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
if (value) *value = rep.value;
exists = rep.flags;
UnlockDisplay (dpy);
SyncHandle ();
return exists;
}
Bool XNVCTRLQueryStringAttribute (
Display *dpy,
int screen,
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);
LockDisplay (dpy);
GetReq (nvCtrlQueryStringAttribute, req);
req->reqType = info->codes->major_opcode;
req->nvReqType = X_nvCtrlQueryStringAttribute;
req->screen = screen;
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;
*ptr = (char *) Xmalloc(numbytes);
if (! *ptr) {
_XEatData(dpy, length);
UnlockDisplay (dpy);
SyncHandle ();
return False;
} else {
_XRead(dpy, (char *) *ptr, numbytes);
if (slop) _XEatData(dpy, 4-slop);
}
exists = rep.flags;
UnlockDisplay (dpy);
SyncHandle ();
return exists;
}
Bool XNVCTRLQueryValidAttributeValues (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
){
XExtDisplayInfo *info = find_display (dpy);
xnvCtrlQueryValidAttributeValuesReply rep;
xnvCtrlQueryValidAttributeValuesReq *req;
Bool exists;
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_nvCtrlQueryValidAttributeValues;
req->screen = screen;
req->display_mask = display_mask;
req->attribute = attribute;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return False;
}
exists = rep.flags;
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 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;
}
static Bool wire_to_event (Display *dpy, XEvent *host, xEvent *wire)
{
XExtDisplayInfo *info = find_display (dpy);
XNVCtrlEvent *re = (XNVCtrlEvent *) host;
xnvctrlEvent *event = (xnvctrlEvent *) wire;
XNVCTRLCheckExtension (dpy, info, False);
switch ((event->u.u.type & 0x7F) - info->codes->first_event) {
case ATTRIBUTE_CHANGED_EVENT:
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;
default:
return False;
}
return True;
}

View file

@ -1,786 +0,0 @@
#ifndef __NVCTRL_H
#define __NVCTRL_H
/**************************************************************************/
/*
* Integer attributes; these are settable/gettable via
* XNVCTRLSetAttribute() and XNVCTRLQueryAttribute, respectively.
* Some attributes may only be read; some may require a display_mask
* argument. This information is encoded in the "permission" comment
* after each attribute #define, and can be queried at run time with
* XNVCTRLQueryValidAttributeValues().
*
* Key to Integer Attribute "Permissions":
*
* R: The attribute is readable (in general, all attributes will be
* readable)
*
* W: The attribute is writable (attributes may not be writable for
* various reasons: they represent static system information, they
* can only be changed by changing an XF86Config option, etc).
*
* D: The attribute requires the display mask argument. The
* attributes NV_CTRL_CONNECTED_DISPLAYS and NV_CTRL_ENABLED_DISPLAYS
* will be a bitmask of what display devices are connected and what
* display devices are enabled for use in X, respectively. Each bit
* in the bitmask represents a display device; it is these bits which
* should be used as the display_mask when dealing with attributes
* designated with "D" below. For attributes that do not require the
* display mask, the argument is ignored.
*/
/**************************************************************************/
/*
* NV_CTRL_FLATPANEL_SCALING - the current flatpanel scaling state;
* possible values are:
*
* 0: default (the driver will use whatever state is current)
* 1: native (the driver will use the panel's scaler, if possible)
* 2: scaled (the driver will use the GPU's scaler, if possible)
* 3: centered (the driver will center the image)
* 4: aspect scaled (scale with the GPU's scaler, but keep the aspect
* ratio correct)
*/
#define NV_CTRL_FLATPANEL_SCALING 2 /* RWD */
#define NV_CTRL_FLATPANEL_SCALING_DEFAULT 0
#define NV_CTRL_FLATPANEL_SCALING_NATIVE 1
#define NV_CTRL_FLATPANEL_SCALING_SCALED 2
#define NV_CTRL_FLATPANEL_SCALING_CENTERED 3
#define NV_CTRL_FLATPANEL_SCALING_ASPECT_SCALED 4
/*
* NV_CTRL_FLATPANEL_DITHERING - the current flatpanel dithering
* state; possible values are:
*
* 0: default (the driver will decide when to dither)
* 1: enabled (the driver will always dither when possible)
* 2: disabled (the driver will never dither)
*/
#define NV_CTRL_FLATPANEL_DITHERING 3 /* RWD */
#define NV_CTRL_FLATPANEL_DITHERING_DEFAULT 0
#define NV_CTRL_FLATPANEL_DITHERING_ENABLED 1
#define NV_CTRL_FLATPANEL_DITHERING_DISABLED 2
/*
* NV_CTRL_DIGITAL_VIBRANCE - sets the digital vibrance level for the
* specified display device.
*/
#define NV_CTRL_DIGITAL_VIBRANCE 4 /* RWD */
/*
* NV_CTRL_BUS_TYPE - returns the Bus type through which the GPU
* driving the specified X screen is connected to the computer.
*/
#define NV_CTRL_BUS_TYPE 5 /* R-- */
#define NV_CTRL_BUS_TYPE_AGP 0
#define NV_CTRL_BUS_TYPE_PCI 1
#define NV_CTRL_BUS_TYPE_PCI_EXPRESS 2
/*
* NV_CTRL_VIDEO_RAM - returns the amount of video ram on the GPU
* driving the specified X screen.
*/
#define NV_CTRL_VIDEO_RAM 6 /* R-- */
/*
* NV_CTRL_IRQ - returns the interrupt request line used by the GPU
* driving the specified X screen.
*/
#define NV_CTRL_IRQ 7 /* R-- */
/*
* NV_CTRL_OPERATING_SYSTEM - returns the operating system on which
* the X server is running.
*/
#define NV_CTRL_OPERATING_SYSTEM 8 /* R-- */
#define NV_CTRL_OPERATING_SYSTEM_LINUX 0
#define NV_CTRL_OPERATING_SYSTEM_FREEBSD 1
/*
* NV_CTRL_SYNC_TO_VBLANK - enables sync to vblank for OpenGL clients.
* This setting is only applied to OpenGL clients that are started
* after this setting is applied.
*/
#define NV_CTRL_SYNC_TO_VBLANK 9 /* RW- */
#define NV_CTRL_SYNC_TO_VBLANK_OFF 0
#define NV_CTRL_SYNC_TO_VBLANK_ON 1
/*
* NV_CTRL_LOG_ANISO - enables anisotropic filtering for OpenGL
* clients; on some NVIDIA hardware, this can only be enabled or
* disabled; on other hardware different levels of anisotropic
* filtering can be specified. This setting is only applied to OpenGL
* clients that are started after this setting is applied.
*/
#define NV_CTRL_LOG_ANISO 10 /* RW- */
/*
* NV_CTRL_FSAA_MODE - the FSAA setting for OpenGL clients; possible
* FSAA modes:
*
* NV_CTRL_FSAA_MODE_2x "2x Bilinear Multisampling"
* NV_CTRL_FSAA_MODE_2x_5t "2x Quincunx Multisampling"
* NV_CTRL_FSAA_MODE_15x15 "1.5 x 1.5 Supersampling"
* NV_CTRL_FSAA_MODE_2x2 "2 x 2 Supersampling"
* NV_CTRL_FSAA_MODE_4x "4x Bilinear Multisampling"
* NV_CTRL_FSAA_MODE_4x_9t "4x Gaussian Multisampling"
* NV_CTRL_FSAA_MODE_8x "2x Bilinear Multisampling by 4x Supersampling"
* NV_CTRL_FSAA_MODE_16x "4x Bilinear Multisampling by 4x Supersampling"
*
* This setting is only applied to OpenGL clients that are started
* after this setting is applied.
*/
#define NV_CTRL_FSAA_MODE 11 /* RW- */
#define NV_CTRL_FSAA_MODE_NONE 0
#define NV_CTRL_FSAA_MODE_2x 1
#define NV_CTRL_FSAA_MODE_2x_5t 2
#define NV_CTRL_FSAA_MODE_15x15 3
#define NV_CTRL_FSAA_MODE_2x2 4
#define NV_CTRL_FSAA_MODE_4x 5
#define NV_CTRL_FSAA_MODE_4x_9t 6
#define NV_CTRL_FSAA_MODE_8x 7
#define NV_CTRL_FSAA_MODE_16x 8
/*
* NV_CTRL_TEXTURE_SHARPEN - enables texture sharpening for OpenGL
* clients. This setting is only applied to OpenGL clients that are
* started after this setting is applied.
*/
#define NV_CTRL_TEXTURE_SHARPEN 12 /* RW- */
#define NV_CTRL_TEXTURE_SHARPEN_OFF 0
#define NV_CTRL_TEXTURE_SHARPEN_ON 1
/*
* NV_CTRL_UBB - returns whether UBB is enabled for the specified X
* screen.
*/
#define NV_CTRL_UBB 13 /* R-- */
#define NV_CTRL_UBB_OFF 0
#define NV_CTRL_UBB_ON 1
/*
* NV_CTRL_OVERLAY - returns whether the RGB overlay is enabled for
* the specified X screen.
*/
#define NV_CTRL_OVERLAY 14 /* R-- */
#define NV_CTRL_OVERLAY_OFF 0
#define NV_CTRL_OVERLAY_ON 1
/*
* NV_CTRL_STEREO - returns whether stereo (and what type) is enabled
* for the specified X screen.
*/
#define NV_CTRL_STEREO 16 /* R-- */
#define NV_CTRL_STEREO_OFF 0
#define NV_CTRL_STEREO_DDC 1
#define NV_CTRL_STEREO_BLUELINE 2
#define NV_CTRL_STEREO_DIN 3
#define NV_CTRL_STEREO_TWINVIEW 4
/*
* NV_CTRL_EMULATE - controls OpenGL software emulation of future
* NVIDIA GPUs.
*/
#define NV_CTRL_EMULATE 17 /* RW- */
#define NV_CTRL_EMULATE_NONE 0
/*
* NV_CTRL_TWINVIEW - returns whether TwinView is enabled for the
* specified X screen.
*/
#define NV_CTRL_TWINVIEW 18 /* R-- */
#define NV_CTRL_TWINVIEW_NOT_ENABLED 0
#define NV_CTRL_TWINVIEW_ENABLED 1
/*
* NV_CTRL_CONNECTED_DISPLAYS - returns a display mask indicating what
* display devices are connected to the GPU driving the specified X
* screen.
*/
#define NV_CTRL_CONNECTED_DISPLAYS 19 /* R-- */
/*
* NV_CTRL_ENABLED_DISPLAYS - returns a display mask indicating what
* display devices are enabled for use on the specified X screen.
*/
#define NV_CTRL_ENABLED_DISPLAYS 20 /* R-- */
/**************************************************************************/
/*
* Integer attributes specific to configuring FrameLock on boards that
* support it.
*/
/*
* NV_CTRL_FRAMELOCK - returns whether this X screen supports
* FrameLock. All of the other FrameLock attributes are only
* applicable if NV_CTRL_FRAMELOCK is _SUPPORTED.
*/
#define NV_CTRL_FRAMELOCK 21 /* R-- */
#define NV_CTRL_FRAMELOCK_NOT_SUPPORTED 0
#define NV_CTRL_FRAMELOCK_SUPPORTED 1
/*
* NV_CTRL_FRAMELOCK_MASTER - get/set whether this X screen is the
* FrameLock master for the entire sync group. Note that only one
* node in the sync group should be configured as the master.
*/
#define NV_CTRL_FRAMELOCK_MASTER 22 /* RW- */
#define NV_CTRL_FRAMELOCK_MASTER_FALSE 0
#define NV_CTRL_FRAMELOCK_MASTER_TRUE 1
/*
* NV_CTRL_FRAMELOCK_POLARITY - sync either to the rising edge of the
* framelock pulse, or both the rising and falling edges of the
* framelock pulse.
*/
#define NV_CTRL_FRAMELOCK_POLARITY 23 /* RW- */
#define NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE 0x1
#define NV_CTRL_FRAMELOCK_POLARITY_BOTH_EDGES 0x3
/*
* NV_CTRL_FRAMELOCK_SYNC_DELAY - delay between the framelock pulse
* and the GPU sync. This is an 11 bit value which is multipled by
* 7.81 to determine the sync delay in microseconds.
*/
#define NV_CTRL_FRAMELOCK_SYNC_DELAY 24 /* RW- */
#define NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX 2047
#define NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR 7.81
/*
* NV_CTRL_FRAMELOCK_SYNC_INTERVAL - how many house sync pulses
* between the FrameLock sync generation (0 == sync every house sync);
* this only applies to the master when receiving house sync.
*/
#define NV_CTRL_FRAMELOCK_SYNC_INTERVAL 25 /* RW- */
/*
* NV_CTRL_FRAMELOCK_PORT0_STATUS - status of the rj45 port0.
*/
#define NV_CTRL_FRAMELOCK_PORT0_STATUS 26 /* R-- */
#define NV_CTRL_FRAMELOCK_PORT0_STATUS_INPUT 0
#define NV_CTRL_FRAMELOCK_PORT0_STATUS_OUTPUT 1
/*
* NV_CTRL_FRAMELOCK_PORT1_STATUS - status of the rj45 port1.
*/
#define NV_CTRL_FRAMELOCK_PORT1_STATUS 27 /* R-- */
#define NV_CTRL_FRAMELOCK_PORT1_STATUS_INPUT 0
#define NV_CTRL_FRAMELOCK_PORT1_STATUS_OUTPUT 1
/*
* NV_CTRL_FRAMELOCK_HOUSE_STATUS - status of the house input (the BNC
* connector).
*/
#define NV_CTRL_FRAMELOCK_HOUSE_STATUS 28 /* R-- */
#define NV_CTRL_FRAMELOCK_HOUSE_STATUS_NOT_DETECTED 0
#define NV_CTRL_FRAMELOCK_HOUSE_STATUS_DETECTED 1
/*
* NV_CTRL_FRAMELOCK_SYNC - enable/disable the syncing of the
* specified display devices to the FrameLock pulse.
*/
#define NV_CTRL_FRAMELOCK_SYNC 29 /* RWD */
#define NV_CTRL_FRAMELOCK_SYNC_DISABLE 0
#define NV_CTRL_FRAMELOCK_SYNC_ENABLE 1
/*
* NV_CTRL_FRAMELOCK_SYNC_READY - reports whether a slave FrameLock
* board is receiving sync (regardless of whether or not any display
* devices are using the sync).
*/
#define NV_CTRL_FRAMELOCK_SYNC_READY 30 /* R-- */
#define NV_CTRL_FRAMELOCK_SYNC_READY_FALSE 0
#define NV_CTRL_FRAMELOCK_SYNC_READY_TRUE 1
/*
* NV_CTRL_FRAMELOCK_STEREO_SYNC - this indicates that the GPU stereo
* signal is in sync with the framelock stereo signal.
*/
#define NV_CTRL_FRAMELOCK_STEREO_SYNC 31 /* R-- */
#define NV_CTRL_FRAMELOCK_STEREO_SYNC_FALSE 0
#define NV_CTRL_FRAMELOCK_STEREO_SYNC_TRUE 1
/*
* NV_CTRL_FRAMELOCK_TEST_SIGNAL - to test the connections in the sync
* group, tell the master to enable a test signal, then query port[01]
* status and sync_ready on all slaves. When done, tell the master to
* disable the test signal. Test signal should only be manipulated
* while NV_CTRL_FRAMELOCK_SYNC is enabled.
*
* The TEST_SIGNAL is also used to reset the Universal Frame Count (as
* returned by the glXQueryFrameCountNV() function in the
* GLX_NV_swap_group extension). Note: for best accuracy of the
* Universal Frame Count, it is recommended to toggle the TEST_SIGNAL
* on and off after enabling FrameLock.
*/
#define NV_CTRL_FRAMELOCK_TEST_SIGNAL 32 /* RW- */
#define NV_CTRL_FRAMELOCK_TEST_SIGNAL_DISABLE 0
#define NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE 1
/*
* NV_CTRL_FRAMELOCK_ETHERNET_DETECTED - The FrameLock boards are
* cabled together using regular cat5 cable, connecting to rj45 ports
* on the backplane of the card. There is some concern that users may
* think these are ethernet ports and connect them to a
* router/hub/etc. The hardware can detect this and will shut off to
* prevent damage (either to itself or to the router).
* NV_CTRL_FRAMELOCK_ETHERNET_DETECTED may be called to find out if
* ethernet is connected to one of the rj45 ports. An appropriate
* error message should then be displayed. The _PORT0 and PORT1
* values may be or'ed together.
*/
#define NV_CTRL_FRAMELOCK_ETHERNET_DETECTED 33 /* R-- */
#define NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_NONE 0
#define NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT0 0x1
#define NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT1 0x2
/*
* NV_CTRL_FRAMELOCK_VIDEO_MODE - get/set the video mode of the house
* input.
*/
#define NV_CTRL_FRAMELOCK_VIDEO_MODE 34 /* RW- */
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_NONE 0
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_TTL 1
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_NTSCPALSECAM 2
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_HDTV 3
/*
* During FRAMELOCK bring-up, the above values were redefined to
* these:
*/
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_AUTO 0
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_TTL 1
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_BI_LEVEL 2
#define NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_TRI_LEVEL 3
/*
* NV_CTRL_FRAMELOCK_SYNC_RATE - this is the refresh rate that the
* framelock board is sending to the GPU, in milliHz.
*/
#define NV_CTRL_FRAMELOCK_SYNC_RATE 35 /* R-- */
/**************************************************************************/
/*
* NV_CTRL_FORCE_GENERIC_CPU - inhibit the use of CPU specific
* features such as MMX, SSE, or 3DNOW! for OpenGL clients; this
* option may result in performance loss, but may be useful in
* conjunction with software such as the Valgrind memory debugger.
* This setting is only applied to OpenGL clients that are started
* after this setting is applied.
*/
#define NV_CTRL_FORCE_GENERIC_CPU 37 /* RW- */
#define NV_CTRL_FORCE_GENERIC_CPU_DISABLE 0
#define NV_CTRL_FORCE_GENERIC_CPU_ENABLE 1
/*
* NV_CTRL_OPENGL_AA_LINE_GAMMA - for OpenGL clients, allow
* Gamma-corrected antialiased lines to consider variances in the
* color display capabilities of output devices when rendering smooth
* lines. Only available on recent Quadro GPUs. This setting is only
* applied to OpenGL clients that are started after this setting is
* applied.
*/
#define NV_CTRL_OPENGL_AA_LINE_GAMMA 38 /* RW- */
#define NV_CTRL_OPENGL_AA_LINE_GAMMA_DISABLE 0
#define NV_CTRL_OPENGL_AA_LINE_GAMMA_ENABLE 1
/*
* NV_CTRL_FRAMELOCK_TIMING - this is TRUE when the framelock board is
* receiving timing input.
*/
#define NV_CTRL_FRAMELOCK_TIMING 39 /* RW- */
#define NV_CTRL_FRAMELOCK_TIMING_FALSE 0
#define NV_CTRL_FRAMELOCK_TIMING_TRUE 1
/*
* NV_CTRL_FLIPPING_ALLOWED - when TRUE, OpenGL will swap by flipping
* when possible; when FALSE, OpenGL will alway swap by blitting. XXX
* can this be enabled dynamically?
*/
#define NV_CTRL_FLIPPING_ALLOWED 40 /* RW- */
#define NV_CTRL_FLIPPING_ALLOWED_FALSE 0
#define NV_CTRL_FLIPPING_ALLOWED_TRUE 1
/*
* NV_CTRL_ARCHITECTURE - returns the architecture on which the X server is
* running.
*/
#define NV_CTRL_ARCHITECTURE 41 /* R-- */
#define NV_CTRL_ARCHITECTURE_X86 0
#define NV_CTRL_ARCHITECTURE_X86_64 1
#define NV_CTRL_ARCHITECTURE_IA64 2
/*
* NV_CTRL_TEXTURE_CLAMPING - texture clamping mode in OpenGL. By
* default, NVIDIA's OpenGL implementation uses CLAMP_TO_EDGE, which
* is not strictly conformant, but some applications rely on the
* non-conformant behavior, and not all GPUs support conformant
* texture clamping in hardware. _SPEC forces OpenGL texture clamping
* to be conformant, but may introduce slower performance on older
* GPUS, or incorrect texture clamping in certain applications.
*/
#define NV_CTRL_TEXTURE_CLAMPING 42 /* RW- */
#define NV_CTRL_TEXTURE_CLAMPING_EDGE 0
#define NV_CTRL_TEXTURE_CLAMPING_SPEC 1
#define NV_CTRL_CURSOR_SHADOW 43 /* RW- */
#define NV_CTRL_CURSOR_SHADOW_DISABLE 0
#define NV_CTRL_CURSOR_SHADOW_ENABLE 1
#define NV_CTRL_CURSOR_SHADOW_ALPHA 44 /* RW- */
#define NV_CTRL_CURSOR_SHADOW_RED 45 /* RW- */
#define NV_CTRL_CURSOR_SHADOW_GREEN 46 /* RW- */
#define NV_CTRL_CURSOR_SHADOW_BLUE 47 /* RW- */
#define NV_CTRL_CURSOR_SHADOW_X_OFFSET 48 /* RW- */
#define NV_CTRL_CURSOR_SHADOW_Y_OFFSET 49 /* RW- */
/*
* When Application Control for FSAA is enabled, then what the
* application requests is used, and NV_CTRL_FSAA_MODE is ignored. If
* this is disabled, then any application setting is overridden with
* NV_CTRL_FSAA_MODE
*/
#define NV_CTRL_FSAA_APPLICATION_CONTROLLED 50 /* RW- */
#define NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED 1
#define NV_CTRL_FSAA_APPLICATION_CONTROLLED_DISABLED 0
/*
* When Application Control for LogAniso is enabled, then what the
* application requests is used, and NV_CTRL_LOG_ANISO is ignored. If
* this is disabled, then any application setting is overridden with
* NV_CTRL_LOG_ANISO
*/
#define NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED 51 /* RW- */
#define NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_ENABLED 1
#define NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_DISABLED 0
/*
* IMAGE_SHARPENING adjusts the sharpness of the display's image
* quality by amplifying high frequency content. Valid values will
* normally be in the range [0,32). Only available on GeForceFX or
* newer.
*/
#define NV_CTRL_IMAGE_SHARPENING 52 /* RWD */
/*
* NV_CTRL_TV_OVERSCAN adjusts the amount of overscan on the specified
* display device.
*/
#define NV_CTRL_TV_OVERSCAN 53 /* RWD */
/*
* NV_CTRL_TV_FLICKER_FILTER adjusts the amount of flicker filter on
* the specified display device.
*/
#define NV_CTRL_TV_FLICKER_FILTER 54 /* RWD */
/*
* NV_CTRL_TV_BRIGHTNESS adjusts the amount of brightness on the
* specified display device.
*/
#define NV_CTRL_TV_BRIGHTNESS 55 /* RWD */
/*
* NV_CTRL_TV_HUE adjusts the amount of hue on the specified display
* device.
*/
#define NV_CTRL_TV_HUE 56 /* RWD */
/*
* NV_CTRL_TV_CONTRAST adjusts the amount of contrast on the specified
* display device.
*/
#define NV_CTRL_TV_CONTRAST 57 /* RWD */
/*
* NV_CTRL_TV_SATURATION adjusts the amount of saturation on the
* specified display device.
*/
#define NV_CTRL_TV_SATURATION 58 /* RWD */
/*
* NV_CTRL_TV_RESET_SETTINGS - this write-only attribute can be used
* to request that all TV Settings be reset to their default values;
* typical usage would be that this attribute be sent, and then all
* the TV attributes be queried to retrieve their new values.
*/
#define NV_CTRL_TV_RESET_SETTINGS 59 /* -WD */
/*
* NV_CTRL_GPU_CORE_TEMPERATURE reports the current core temperature
* of the GPU driving the X screen.
*/
#define NV_CTRL_GPU_CORE_TEMPERATURE 60 /* R-- */
/*
* NV_CTRL_GPU_CORE_THRESHOLD reports the current GPU core slowdown
* threshold temperature, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD and
* NV_CTRL_GPU_MAX_CORE_THRESHOLD report the default and MAX core
* slowdown threshold temperatures.
*
* NV_CTRL_GPU_CORE_THRESHOLD reflects the temperature at which the
* GPU is throttled to prevent overheating.
*/
#define NV_CTRL_GPU_CORE_THRESHOLD 61 /* R-- */
#define NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD 62 /* R-- */
#define NV_CTRL_GPU_MAX_CORE_THRESHOLD 63 /* R-- */
/*
* NV_CTRL_AMBIENT_TEMPERATURE reports the current temperature in the
* immediate neighbourhood of the GPU driving the X screen.
*/
#define NV_CTRL_AMBIENT_TEMPERATURE 64 /* R-- */
/*
* NV_CTRL_PBUFFER_SCANOUT_SUPPORTED - returns whether this X screen
* supports scanout of FP pbuffers;
*
* if this screen does not support PBUFFER_SCANOUT, then all other
* PBUFFER_SCANOUT attributes are unavailable.
*/
#define NV_CTRL_PBUFFER_SCANOUT_SUPPORTED 65 /* R-- */
#define NV_CTRL_PBUFFER_SCANOUT_FALSE 0
#define NV_CTRL_PBUFFER_SCANOUT_TRUE 1
/*
* NV_CTRL_PBUFFER_SCANOUT_XID indicates the XID of the pbuffer used for
* scanout.
*/
#define NV_CTRL_PBUFFER_SCANOUT_XID 66 /* RW- */
#define NV_CTRL_LAST_ATTRIBUTE NV_CTRL_PBUFFER_SCANOUT_XID
/**************************************************************************/
/*
* String Attributes:
*/
/*
* NV_CTRL_STRING_PRODUCT_NAME - the GPU product name on which the
* specified X screen is running.
*/
#define NV_CTRL_STRING_PRODUCT_NAME 0 /* R-- */
/*
* NV_CTRL_STRING_VBIOS_VERSION - the video bios version on the GPU on
* which the specified X screen is running.
*/
#define NV_CTRL_STRING_VBIOS_VERSION 1 /* R-- */
/*
* NV_CTRL_STRING_NVIDIA_DRIVER_VERSION - string representation of the
* NVIDIA driver version number for the NVIDIA X driver in use.
*/
#define NV_CTRL_STRING_NVIDIA_DRIVER_VERSION 3 /* R-- */
/*
* NV_CTRL_STRING_DISPLAY_DEVICE_NAME - name of the display device
* specified in the display_mask argument.
*/
#define NV_CTRL_STRING_DISPLAY_DEVICE_NAME 4 /* R-D */
/*
* NV_CTRL_STRING_TV_ENCODER_NAME - name of the TV encoder used by the
* specified display device; only valid if the display device is a TV.
*/
#define NV_CTRL_STRING_TV_ENCODER_NAME 5 /* R-D */
#define NV_CTRL_STRING_LAST_ATTRIBUTE NV_CTRL_STRING_TV_ENCODER_NAME
/**************************************************************************/
/*
* CTRLAttributeValidValuesRec -
*
* structure and related defines used by
* XNVCTRLQueryValidAttributeValues() to describe the valid values of
* a particular attribute. The type field will be one of:
*
* ATTRIBUTE_TYPE_INTEGER : the attribute is an integer value; there
* is no fixed range of valid values.
*
* ATTRIBUTE_TYPE_BITMASK : the attribute is an integer value,
* interpretted as a bitmask.
*
* ATTRIBUTE_TYPE_BOOL : the attribute is a boolean, valid values are
* either 1 (on/true) or 0 (off/false).
*
* ATTRIBUTE_TYPE_RANGE : the attribute can have any integer value
* between NVCTRLAttributeValidValues.u.range.min and
* NVCTRLAttributeValidValues.u.range.max (inclusive).
*
* ATTRIBUTE_TYPE_INT_BITS : the attribute can only have certain
* integer values, indicated by which bits in
* NVCTRLAttributeValidValues.u.bits.ints are on (for example: if bit
* 0 is on, then 0 is a valid value; if bit 5 is on, then 5 is a valid
* value, etc). This is useful for attributes like NV_CTRL_FSAA_MODE,
* which can only have certain values, depending on GPU.
*
*
* The permissions field of NVCTRLAttributeValidValuesRec is a bitmask
* that may contain:
*
* ATTRIBUTE_TYPE_READ
* ATTRIBUTE_TYPE_WRITE
* ATTRIBUTE_TYPE_DISPLAY
*
* See 'Key to Integer Attribute "Permissions"' at the top of this
* file for a description of what these three permission bits mean.
*/
#define ATTRIBUTE_TYPE_UNKNOWN 0
#define ATTRIBUTE_TYPE_INTEGER 1
#define ATTRIBUTE_TYPE_BITMASK 2
#define ATTRIBUTE_TYPE_BOOL 3
#define ATTRIBUTE_TYPE_RANGE 4
#define ATTRIBUTE_TYPE_INT_BITS 5
#define ATTRIBUTE_TYPE_READ 0x1
#define ATTRIBUTE_TYPE_WRITE 0x2
#define ATTRIBUTE_TYPE_DISPLAY 0x4
typedef struct _NVCTRLAttributeValidValues {
int type;
union {
struct {
int min;
int max;
} range;
struct {
unsigned int ints;
} bits;
} u;
unsigned int permissions;
} NVCTRLAttributeValidValuesRec;
#define ATTRIBUTE_CHANGED_EVENT 0
#endif /* __NVCTRL_H */

View file

@ -1,177 +0,0 @@
#ifndef __NVCTRLLIB_H
#define __NVCTRLLIB_H
#include "NVCtrl.h"
/*
* 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
);
/*
* 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.
*
* 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
);
/*
* 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.
*
* 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
);
/*
* 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.
*
* 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
);
/*
* 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.
*/
Bool XNVCTRLQueryValidAttributeValues (
Display *dpy,
int screen,
unsigned int display_mask,
unsigned int attribute,
NVCTRLAttributeValidValuesRec *values
);
/*
* XNVCtrlSelectNotify -
*
* This enables/disables receiving of NV-CONTROL events. The type
* specifies the type of event to enable (currently, the only type 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
);
/*
* 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;
#endif /* __NVCTRLLIB_H */

View file

@ -1,224 +0,0 @@
/*
* $Xorg: extutil.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $
*
Copyright 1989, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice 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
OPEN GROUP 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.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Author: Jim Fulton, MIT The Open Group
*
* Xlib Extension-Writing Utilities
*
* This package contains utilities for writing the client API for various
* protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
* ARE SUBJECT TO CHANGE!
*/
/* $XFree86: xc/include/extensions/extutil.h,v 1.9 2001/12/14 19:53:28 dawes Exp $ */
#ifndef _EXTUTIL_H_
#define _EXTUTIL_H_
#include <X11/extensions/Xext.h>
/*
* We need to keep a list of open displays since the Xlib display list isn't
* public. We also have to per-display info in a separate block since it isn't
* stored directly in the Display structure.
*/
typedef struct _XExtDisplayInfo {
struct _XExtDisplayInfo *next; /* keep a linked list */
Display *display; /* which display this is */
XExtCodes *codes; /* the extension protocol codes */
XPointer data; /* extra data for extension to use */
} XExtDisplayInfo;
typedef struct _XExtensionInfo {
XExtDisplayInfo *head; /* start of list */
XExtDisplayInfo *cur; /* most recently used */
int ndisplays; /* number of displays */
} XExtensionInfo;
typedef struct _XExtensionHooks {
int (*create_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*copy_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*flush_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*free_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*create_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*free_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*close_display)(
#if NeedNestedPrototypes
Display* /* display */,
XExtCodes* /* codes */
#endif
);
Bool (*wire_to_event)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
Status (*event_to_wire)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
int (*error)(
#if NeedNestedPrototypes
Display* /* display */,
xError* /* err */,
XExtCodes* /* codes */,
int* /* ret_code */
#endif
);
char *(*error_string)(
#if NeedNestedPrototypes
Display* /* display */,
int /* code */,
XExtCodes* /* codes */,
char* /* buffer */,
int /* nbytes */
#endif
);
} XExtensionHooks;
extern XExtensionInfo *XextCreateExtension(
#if NeedFunctionPrototypes
void
#endif
);
extern void XextDestroyExtension(
#if NeedFunctionPrototypes
XExtensionInfo* /* info */
#endif
);
extern XExtDisplayInfo *XextAddDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */,
char* /* ext_name */,
XExtensionHooks* /* hooks */,
int /* nevents */,
XPointer /* data */
#endif
);
extern int XextRemoveDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
extern XExtDisplayInfo *XextFindDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
#define XextHasExtension(i) ((i) && ((i)->codes))
#define XextCheckExtension(dpy,i,name,val) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
#define XextSimpleCheckExtension(dpy,i,name) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
/*
* helper macros to generate code that is common to all extensions; caller
* should prefix it with static if extension source is in one file; this
* could be a utility function, but have to stack 6 unused arguments for
* something that is called many, many times would be bad.
*/
#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
XExtDisplayInfo *proc (Display *dpy) \
{ \
XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \
}
#define XEXT_FIND_DISPLAY_PROTO(proc) \
XExtDisplayInfo *proc(Display *dpy)
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \
{ \
return XextRemoveDisplay (extinfo, dpy); \
}
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
int proc(Display *dpy, XExtCodes *codes)
#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
{ \
code -= codes->first_error; \
if (code >= 0 && code < nerr) { \
char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \
XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \
} \
return (char *)0; \
}
#define XEXT_ERROR_STRING_PROTO(proc) \
char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
#endif

View file

@ -1,184 +0,0 @@
#ifndef __NVCONTROL_H
#define __NVCONTROL_H
#define NV_CONTROL_ERRORS 0
#define NV_CONTROL_EVENTS 1
#define NV_CONTROL_NAME "NV-CONTROL"
#define NV_CONTROL_MAJOR 1
#define NV_CONTROL_MINOR 6
#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_nvCtrlLastRequest (X_nvCtrlSelectNotify + 1)
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 screen B32;
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 {
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
CARD32 display_mask B32;
CARD32 attribute B32;
INT32 value B32;
} xnvCtrlSetAttributeReq;
#define sz_xnvCtrlSetAttributeReq 20
typedef struct {
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
CARD32 display_mask B32;
CARD32 attribute B32;
} xnvCtrlQueryStringAttributeReq;
#define sz_xnvCtrlQueryStringAttributeReq 16
/*
* CtrlQueryStringAttribute reply struct
* n indicates the length of the string.
*/
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;
} xnvCtrlQueryStringAttributeReply;
#define sz_xnvCtrlQueryStringAttributeReply 32
typedef struct {
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
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 {
CARD8 reqType;
CARD8 nvReqType;
CARD16 length B16;
CARD32 screen B32;
CARD16 notifyType B16;
CARD16 onoff B16;
} xnvCtrlSelectNotifyReq;
#define sz_xnvCtrlSelectNotifyReq 12
typedef struct {
union {
struct {
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
} u;
struct {
BYTE type;
BYTE detail;
CARD16 sequenceNumber B16;
Time 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;
#endif /* __NVCONTROL_H */

View file

@ -203,10 +203,9 @@ sys_string = ' \
if ( local_dedicated == 0 ):
sys_string += ' \
linux/glimp.cpp \
glimp.cpp \
posix/posix_input.cpp \
linux/input.cpp \
linux/libXNVCtrl/NVCtrl.c'
linux/input.cpp'
else:
sys_string += ' \
stub/stub_gl.cpp \

View file

@ -382,5 +382,8 @@ GLExtension_t GLimp_ExtensionPointer( const char *a) { return StubFunction; };
bool GLimp_Init(glimpParms_t a) {return true;};
void GLimp_SetGamma(unsigned short*a, unsigned short*b, unsigned short*c) {};
bool GLimp_SetScreenParms(glimpParms_t parms) { return true; };
void GLimp_Shutdown() {};
void GLimp_SwapBuffers() {};
void GLimp_ActivateContext() {};
void GLimp_DeactivateContext() {};