summaryrefslogtreecommitdiff
path: root/src/libXNVCtrl/NVCtrlLib.h
blob: cc4599facbdc1d31038bae7cee7b80ae0f55762c (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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
#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
);


/*
 *  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
);


/*
 *  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
);

/*
 *  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
);

/*
 * 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
);


/*
 *  XNVCTRLSetGvoColorConversion -
 *
 *  Sets the color conversion matrix and color offset
 *  that should be used for GVO (Graphic to Video Out).
 *
 *  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]
);


/*
 *  XNVCTRLQueryGvoColorConversion -
 *
 *  Retrieves the color conversion matrix and color offset
 *  that are currently being used for GVO (Graphic to Video Out).
 *
 *  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]
);

/* SPECIAL HANDLING OF VCP CODES 
 *
 * XNVCTRLQueryDDCCILutSize
 * XNVCTRLQueryDDCCISinglePointLutOperation
 * XNVCTRLSetDDCCISinglePointLutOperation
 * XNVCTRLQueryDDCCIBlockLutOperation
 * XNVCTRLSetDDCCIBlockLutOperation
 * XNVCTRLSetDDCCIRemoteProcedureCall
 * XNVCTRLQueryDDCCIDisplayControllerType
 
 * Some of DDC/CI VCP codes handle multiple values,
 * therefore they need their own NV_CONTROL structure 
 */
 
/* XNVCTRLQueryDDCCILutSize
 * Provides the size (number of entries and number of bits / entry)
 * for the Red / Green and Blue LUT in the display
 *
 * red_entries: Number of Red LUT entries
 * green_entries: Number of Green LUT entries
 * blue_entries: Number of Blue LUT entries
 * red_bits_per_entries: Number of bits / entry in Red LUT
 * green_bits_per_entries: Number of bits / entry in Green LUT
 * blue_bits_per_entries: Number of bits / entry in Blue LUT
 * Returns TRUE on success
 */
Bool XNVCTRLQueryDDCCILutSize (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int *red_entries,
    unsigned int *green_entries,
    unsigned int *blue_entries,
    unsigned int *red_bits_per_entries,
    unsigned int *green_bits_per_entries,
    unsigned int *blue_bits_per_entries
);

/* XNVCTRLQueryDDCCISinglePointLutOperation
 * Allows a single point within a display's color LUT to be read
 * Input:
 *  offset: Offset into the LUT
 * Output:
 *  red_value: Red LUT value read
 *  green_value: Green LUT value read
 *  blue_value: Blue LUT value read
 * Returns TRUE on success
 */
Bool XNVCTRLQueryDDCCISinglePointLutOperation (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int offset,
    unsigned int *red_value,
    unsigned int *green_value,
    unsigned int *blue_value
);

/* XNVCTRLSetDDCCISinglePointLutOperation
 * Allows a single point within a display's color LUT (look up table)
 * to be loaded.
 * offset: Offset into the LUT
 * red_value: Red LUT value to be loaded
 * green_value: Green LUT value to be loaded
 * blue_value: Blue LUT value to be loaded
 * Note: If display LUT cannot store 16 bit values then least significant
 * bits are discarded
 * Returns TRUE on success
 */
Bool XNVCTRLSetDDCCISinglePointLutOperation (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int offset,
    unsigned int red_value,
    unsigned int green_value,
    unsigned int blue_value
);

/* XNVCTRLQueryDDCCIBlockLutOperation
 * Provides an efficient method for reading multiple values from a display's LUT
 * color: is one of NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, 
 *  NV_CTRL_DDCCI_BLUE_LUT. Color to be read.
 * size: Number of values to be read
 * offset: Offset into Red or Green or Blue LUT
 * value: Red or Green or Blue LUT contents. Needs to be freed when done.
 * Returns TRUE on success
 */           
Bool XNVCTRLQueryDDCCIBlockLutOperation (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int color, 
    unsigned int size,
    unsigned int offset,
    unsigned int **value
);

/* XNVCTRLSetDDCCIBlockLutOperation
 * Provides an efficient method for loading multiple values into a display's LUT
 * size: Number of values to be loaded
 * offset: Offset into Red or Green or Blue LUT
 * value: R or G or B LUT values to be loaded
 * color: NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, NV_CTRL_DDCCI_BLUE_LUT
 * Note: If display LUT cannot store 16 bit values then least significant
 * bits are discarded
 * Returns TRUE on success
 */   
#define NV_CTRL_DDCCI_RED_LUT 1
#define NV_CTRL_DDCCI_GREEN_LUT 2
#define NV_CTRL_DDCCI_BLUE_LUT 3     
Bool XNVCTRLSetDDCCIBlockLutOperation (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int color, 
    unsigned int offset,
    unsigned int size,
    unsigned int *value
);

/* XNVCTRLSetDDCCIRemoteProcedureCall
 * Allows initiation of a routine / macro resident in the display. Only
 * one RPC is defined at this time:
 * A spline curve routine applied to the data (supplied in format
 * below) and the resulting data used to derive a full set of values 
 * for the display color LUT which shall then be loaded.
 * offset: Offset into the LUT
 * size: Number of values to be loaded
 * red_lut: Red LUT values
 * green_lut: Green LUT value
 * blue_lut: Blue LUT value
 * increment: Increment to next LUT entry
 *  Values of E0h  FFh inclusive are reserved for manufacturer
 * specific routines / macros.
 * All other values are reserved and shall be ignored.
 * Returns TRUE on success
 */
Bool XNVCTRLSetDDCCIRemoteProcedureCall (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int offset,
    unsigned int size,
    unsigned int *red_lut,
    unsigned int *green_lut,
    unsigned int *blue_lut,
    unsigned int *increment
);

/* XNVCTRLQueryDDCCIDisplayControllerType:
 * Provides the host with knowledge of the controller type being used by a 
 * particular display 
 * controller_manufacturer: Indicates controller manufacturer. (This string 
 * needs to be freed when done) (XXX This will be changed to a static string)
 * controller_type: Provide a numeric indication of controller type
 * Return TRUE on success
 */
Bool XNVCTRLQueryDDCCIDisplayControllerType (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned char **controller_manufacturer,
    unsigned int *controller_type
);

/* NVCTRLQueryDDCCICapabilities:
 * Gets the capabilities of the display as a VCP string
 * Returns :
 * nvctrl_vcp_supported: a table of 0 (not supported) and 1 (supported)
 *   which index is the NV_CTRL_DDCI* values 
 * possible_value_offset; contains the offsets in the table 
 *   nvctrl_vcp_possible_values. Index is the NV_CTRL_DDCI* values.
 *  -1 means no possible values are available.
 * possible_value_size; contains the count in the table 
 *  nvctrl_vcp_possible_values. Index is the NV_CTRL_DDCI* values.
 *  -1 means no possible values are available.
 * nvctrl_vcp_possible_values: a table of possible values for the non
 *   continuous values. 
 * nvctrl_string_vcp_supported: a table or 0 (not supported) and 1 (supported)
 *   which index is the NV_CTRL_STRING_DDCI* values.
 *
 * Returns TRUE on success
 */
Bool NVCTRLQueryDDCCICapabilities (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int **nvctrl_vcp_supported,    // Size is NV_CTRL_DDCCI_LAST_VCP+1
    unsigned int **possible_values_offset,  // Size is NV_CTRL_DDCCI_LAST_VCP+1
    unsigned int **possible_values_size,    // Size is NV_CTRL_DDCCI_LAST_VCP+1
    unsigned int **nvctrl_vcp_possible_values, 
    unsigned int **nvctrl_string_vcp_supported // Size is NV_CTRL_STRING_LAST_ATTRIBUTE+1
);

/* XNVCTRLQueryDDCCITimingReport
 * Queries the currently operating video signal timing report data.
 * - is_sync_freq_out_range: Sync. Freq. out of range          (TRUE/FALSE)
 * - is_unstable_count:      Unstable Count                    (TRUE/FALSE)
 * - is_positive_h_sync:     Positive Horizontal sync polarity (TRUE/FALSE)
 * - is_positive_v_sync:     Positive Vertical sync polarity   (TRUE/FALSE)
 * - h_freq:                 Horizontal Frequency
 * - v_freq:                 Vertical Frequency.
 *
 * Returns TRUE on success
 */           
Bool XNVCTRLQueryDDCCITimingReport (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int *sync_freq_out_range, 
    unsigned int *unstable_count,
    unsigned int *positive_h_sync,
    unsigned int *positive_v_sync,
    unsigned int *h_freq,
    unsigned int *v_freq
);


/*
 *  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.
 *
 *  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
);


/*
 * 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 */