summaryrefslogtreecommitdiff
path: root/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h
blob: 294cad2fac96f75113a5b1884cad261535df9bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
 * and Linux systems.
 *
 * Copyright (C) 2004 NVIDIA Corporation.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of Version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program 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 Version 2
 * of the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the:
 *
 *           Free Software Foundation, Inc.
 *           59 Temple Place - Suite 330
 *           Boston, MA 02111-1307, USA
 *
 */

#ifndef __NVCTRL_ATTRIBUTES_PRIVATE__
#define __NVCTRL_ATTRIBUTES_PRIVATE__

#include "NvCtrlAttributes.h"
#include "NVCtrl.h"
#include <GL/glx.h> /* GLX #defines */
#include <X11/extensions/Xrandr.h> /* Xrandr */


#define EXTENSION_NV_CONTROL  0x1
#define EXTENSION_XF86VIDMODE 0x2
#define EXTENSION_XVIDEO      0x4
#define EXTENSION_GLX         0x8
#define EXTENSION_XRANDR      0x10

/* caps bits */

#define NV_XF86VM_NUM_BITS      1
#define NV_CTRL_NUM_BITS        (NV_CTRL_LAST_ATTRIBUTE + 1)
#define NV_CTRL_STRING_NUM_BITS (NV_CTRL_STRING_LAST_ATTRIBUTE + 1)


#define NV_XF86VM_CAPS_OFFSET      0
#define NV_CTRL_CAPS_OFFSET        NV_XF86VM_NUM_BITS
#define NV_CTRL_STRING_CAPS_OFFSET (NV_XF86VM_NUM_BITS + NV_CTRL_NUM_BITS)




#define CAPS_XF86VM_GAMMA       (1 << (0x1 + NV_XF86VM_CAPS_OFFSET))


/* minimum required version for the NV-CONTROL extension */

#define NV_MINMAJOR 1
#define NV_MINMINOR 6

/* minimum required version for the XF86VidMode extension */

#define VM_MINMAJOR 2
#define VM_MINMINOR 1

/* minimum required version for the XVideo extension */

#define XV_MINMAJOR 2
#define XV_MINMINOR 0


typedef struct __NvCtrlAttributes NvCtrlAttributes;
typedef struct __NvCtrlVidModeAttributes NvCtrlVidModeAttributes;
typedef struct __NvCtrlAttributePrivateHandle NvCtrlAttributePrivateHandle;
typedef struct __NvCtrlNvControlAttributes NvCtrlNvControlAttributes;
typedef struct __NvCtrlXvOverlayAttributes NvCtrlXvOverlayAttributes;
typedef struct __NvCtrlXvTextureAttributes NvCtrlXvTextureAttributes;
typedef struct __NvCtrlXvBlitterAttributes NvCtrlXvBlitterAttributes;
typedef struct __NvCtrlXvAttribute NvCtrlXvAttribute;
typedef struct __NvCtrlGlxAttributes NvCtrlGlxAttributes;
typedef struct __NvCtrlXrandrAttributes NvCtrlXrandrAttributes;

struct __NvCtrlNvControlAttributes {
    int event_base;
    int error_base;
};

struct __NvCtrlVidModeAttributes {
    int n;
    int sigbits;
    unsigned short *lut[3];
    float brightness[3];
    float contrast[3];
    float gamma[3];
};

struct __NvCtrlXvAttribute {
    Atom atom;
    NVCTRLAttributeValidValuesRec range;
};

struct __NvCtrlXvOverlayAttributes {
    unsigned int port;
    NvCtrlXvAttribute *saturation;
    NvCtrlXvAttribute *contrast;
    NvCtrlXvAttribute *brightness;
    NvCtrlXvAttribute *hue;
    NvCtrlXvAttribute *defaults;
};

struct __NvCtrlXvTextureAttributes {
    unsigned int port;
    NvCtrlXvAttribute *sync_to_vblank;
    NvCtrlXvAttribute *defaults;
};

struct __NvCtrlXvBlitterAttributes {
    unsigned int port;
    NvCtrlXvAttribute *sync_to_vblank;
    NvCtrlXvAttribute *defaults;
};

struct __NvCtrlGlxAttributes {

    /* Private display connection for the GLX information ext. */
    Display *dpy;

    /* libGL.so library handle */
    void *libGL; 
 
    /* OpenGL functions used */
    const GLubyte * (* glGetString)              (GLenum);

    /* GLX functions used */
    const char *    (* glXQueryServerString)     (Display *, int, int);
    const char *    (* glXGetClientString)       (Display *, int);
    const char *    (* glXQueryExtensionsString) (Display *, int);

    Bool            (* glXIsDirect)              (Display *, GLXContext);
    Bool            (* glXMakeCurrent)           (Display *, GLXDrawable,
                                                  GLXContext);
    GLXContext      (* glXCreateContext)         (Display *, XVisualInfo *,
                                                  GLXContext, Bool);
    void            (* glXDestroyContext)        (Display *, GLXContext);
    XVisualInfo *   (* glXChooseVisual)          (Display *, int, int *);
#ifdef GLX_VERSION_1_3
    GLXFBConfig *   (* glXGetFBConfigs)          (Display *, int, int *);
    int             (* glXGetFBConfigAttrib)     (Display *, GLXFBConfig,
                                                  int, int *);
    XVisualInfo *   (* glXGetVisualFromFBConfig) (Display *, GLXFBConfig);
#endif /* GLX_VERSION_1_3 */
};

struct __NvCtrlXrandrAttributes {

    /* libXrandr.so library handle */
    void     *libXrandr;
    int       event_base; /* XRandR extension event base */
    int       error_base;
    Rotation  rotations; /* Valid rotations */
    int       nsizes;    /* Valid sizes */
   
    /* XRandR functions used */
    Bool  (* XRRQueryExtension) (Display *dpy,
                                 int *event_base,
                                 int *error_base);
    void  (* XRRSelectInput)    (Display *dpy, Window window,
                                 int mask);

    SizeID (* XRRConfigCurrentConfiguration) (XRRScreenConfiguration *config, 
                                              Rotation *rotation);

    XRRScreenConfiguration * (* XRRGetScreenInfo) (Display *dpy, Drawable draw);

    Rotation (* XRRConfigRotations) (XRRScreenConfiguration *config, 
                                     Rotation *rotation);

    void   (* XRRFreeScreenConfigInfo)  (XRRScreenConfiguration *);
    
    Rotation       (* XRRRotations)  (Display *dpy, int screen, Rotation *current_rotation);
    XRRScreenSize *(* XRRSizes)  (Display *dpy, int screen, int *nsizes); 

    Status (* XRRSetScreenConfig) (Display *dpy, 
                                   XRRScreenConfiguration *config,
                                   Drawable draw,
                                   int size_index,
                                   Rotation rotation,
                                   Time timestamp);
};

struct __NvCtrlAttributePrivateHandle {
    Display *dpy;                  /* display connection */
    int screen;                    /* the screen that this handle controls */
    NvCtrlNvControlAttributes *nv; /* NV-CONTROL extension info */
    NvCtrlVidModeAttributes *vm;   /* XF86VidMode extension info */    
    NvCtrlXvOverlayAttributes *xv_overlay; /* XVideo info (overlay) */
    NvCtrlXvTextureAttributes *xv_texture; /* XVideo info (texture) */
    NvCtrlXvBlitterAttributes *xv_blitter; /* XVideo info (blitter) */
    NvCtrlGlxAttributes *glx;       /* GLX extension info */
    NvCtrlXrandrAttributes *xrandr; /* XRandR extension info */
};

NvCtrlNvControlAttributes *
NvCtrlInitNvControlAttributes (NvCtrlAttributePrivateHandle *);

NvCtrlVidModeAttributes *
NvCtrlInitVidModeAttributes (NvCtrlAttributePrivateHandle *);

void NvCtrlInitXvOverlayAttributes (NvCtrlAttributePrivateHandle *);


/* GLX extension attribute functions */

NvCtrlGlxAttributes *
NvCtrlInitGlxAttributes (NvCtrlAttributePrivateHandle *h);

void
NvCtrlGlxAttributesClose (NvCtrlAttributePrivateHandle *h);

ReturnStatus
NvCtrlGlxGetVoidAttribute (NvCtrlAttributePrivateHandle *,
                           unsigned int,
                           int, void **);

ReturnStatus
NvCtrlGlxGetStringAttribute (NvCtrlAttributePrivateHandle *,
                             unsigned int,
                             int, char **);


/* XRandR extension attribute functions */

NvCtrlXrandrAttributes *
NvCtrlInitXrandrAttributes (NvCtrlAttributePrivateHandle *h);

void
NvCtrlXrandrAttributesClose (NvCtrlAttributePrivateHandle *h);

ReturnStatus
NvCtrlXrandrGetAttribute (NvCtrlAttributePrivateHandle *h,
                          int attr, int *val);

ReturnStatus
NvCtrlXrandrSetAttribute (NvCtrlAttributePrivateHandle *h,
                          int attr, int val);


/* Generic attribute functions */

ReturnStatus
NvCtrlNvControlGetAttribute (NvCtrlAttributePrivateHandle *, unsigned int,
                             int, int *);

ReturnStatus
NvCtrlNvControlSetAttribute (NvCtrlAttributePrivateHandle *, unsigned int,
                             int, int);

ReturnStatus
NvCtrlNvControlGetValidAttributeValues (NvCtrlAttributePrivateHandle *,
                                        unsigned int, int,
                                        NVCTRLAttributeValidValuesRec *);
ReturnStatus
NvCtrlNvControlGetStringAttribute (NvCtrlAttributePrivateHandle *,
                                   unsigned int, int, char **);

ReturnStatus
NvCtrlXvGetAttribute (NvCtrlAttributePrivateHandle *, int, int *);

ReturnStatus
NvCtrlXvSetAttribute (NvCtrlAttributePrivateHandle *, int, int);

ReturnStatus
NvCtrlXvGetValidAttributeValues (NvCtrlAttributePrivateHandle *, int,
                                 NVCTRLAttributeValidValuesRec *);

#endif /* __NVCTRL_ATTRIBUTES_PRIVATE__ */