Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/third_party/libXNVCtrl/NVCtrlLib.h
1693 views
1
/*
2
* Copyright (c) 2008 NVIDIA, Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
* SOFTWARE.
22
*/
23
24
#ifndef __NVCTRLLIB_H
25
#define __NVCTRLLIB_H
26
27
#include "NVCtrl.h"
28
29
#if defined __cplusplus
30
extern "C" {
31
#endif
32
33
/*
34
* XNVCTRLQueryExtension -
35
*
36
* Returns True if the extension exists, returns False otherwise.
37
* event_basep and error_basep are the extension event and error
38
* bases. Currently, no extension specific errors or events are
39
* defined.
40
*/
41
42
Bool XNVCTRLQueryExtension(Display *dpy, int *event_basep, int *error_basep);
43
44
/*
45
* XNVCTRLQueryVersion -
46
*
47
* Returns True if the extension exists, returns False otherwise.
48
* major and minor are the extension's major and minor version
49
* numbers.
50
*/
51
52
Bool XNVCTRLQueryVersion(Display *dpy, int *major, int *minor);
53
54
/*
55
* XNVCTRLIsNvScreen
56
*
57
* Returns True is the specified screen is controlled by the NVIDIA
58
* driver. Returns False otherwise.
59
*/
60
61
Bool XNVCTRLIsNvScreen(Display *dpy, int screen);
62
63
/*
64
* XNVCTRLQueryTargetCount -
65
*
66
* Returns True if the target type exists. Returns False otherwise.
67
* If XNVCTRLQueryTargetCount returns True, value will contain the
68
* count of existing targets on the server of the specified target
69
* type.
70
*
71
* Please see "Attribute Targets" in NVCtrl.h for the list of valid
72
* target types.
73
*
74
* Possible errors:
75
* BadValue - The target doesn't exist.
76
*/
77
78
Bool XNVCTRLQueryTargetCount(Display *dpy, int target_type, int *value);
79
80
/*
81
* XNVCTRLSetAttribute -
82
*
83
* Sets the attribute to the given value. The attributes and their
84
* possible values are listed in NVCtrl.h.
85
*
86
* Not all attributes require the display_mask parameter; see
87
* NVCtrl.h for details.
88
*
89
* Calling this function is equivalent to calling XNVCTRLSetTargetAttribute()
90
* with the target_type set to NV_CTRL_TARGET_TYPE_X_SCREEN and
91
* target_id set to 'screen'.
92
*
93
* Possible errors:
94
* BadValue - The screen or attribute doesn't exist.
95
* BadMatch - The NVIDIA driver is not present on that screen.
96
*/
97
98
void XNVCTRLSetAttribute(Display *dpy,
99
int screen,
100
unsigned int display_mask,
101
unsigned int attribute,
102
int value);
103
104
/*
105
* XNVCTRLSetTargetAttribute -
106
*
107
* Sets the attribute to the given value. The attributes and their
108
* possible values are listed in NVCtrl.h.
109
*
110
* Not all attributes require the display_mask parameter; see
111
* NVCtrl.h for details.
112
*
113
* Possible errors:
114
* BadValue - The target or attribute doesn't exist.
115
* BadMatch - The NVIDIA driver is not present on that target.
116
*/
117
118
void XNVCTRLSetTargetAttribute(Display *dpy,
119
int target_type,
120
int target_id,
121
unsigned int display_mask,
122
unsigned int attribute,
123
int value);
124
125
/*
126
* XNVCTRLSetAttributeAndGetStatus -
127
*
128
* Same as XNVCTRLSetAttribute().
129
* In addition, XNVCTRLSetAttributeAndGetStatus() returns
130
* True if the operation succeeds, False otherwise.
131
*
132
*/
133
134
Bool XNVCTRLSetAttributeAndGetStatus(Display *dpy,
135
int screen,
136
unsigned int display_mask,
137
unsigned int attribute,
138
int value);
139
140
/*
141
* XNVCTRLSetTargetAttributeAndGetStatus -
142
*
143
* Same as XNVCTRLSetTargetAttribute().
144
* In addition, XNVCTRLSetTargetAttributeAndGetStatus() returns
145
* True if the operation succeeds, False otherwise.
146
*
147
*/
148
149
Bool XNVCTRLSetTargetAttributeAndGetStatus(Display *dpy,
150
int target_type,
151
int target_id,
152
unsigned int display_mask,
153
unsigned int attribute,
154
int value);
155
156
/*
157
* XNVCTRLQueryAttribute -
158
*
159
* Returns True if the attribute exists. Returns False otherwise.
160
* If XNVCTRLQueryAttribute returns True, value will contain the
161
* value of the specified attribute.
162
*
163
* Not all attributes require the display_mask parameter; see
164
* NVCtrl.h for details.
165
*
166
* Calling this function is equivalent to calling
167
* XNVCTRLQueryTargetAttribute() with the target_type set to
168
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
169
*
170
* Possible errors:
171
* BadValue - The screen doesn't exist.
172
* BadMatch - The NVIDIA driver is not present on that screen.
173
*/
174
175
Bool XNVCTRLQueryAttribute(Display *dpy,
176
int screen,
177
unsigned int display_mask,
178
unsigned int attribute,
179
int *value);
180
181
/*
182
* XNVCTRLQueryTargetAttribute -
183
*
184
* Returns True if the attribute exists. Returns False otherwise.
185
* If XNVCTRLQueryTargetAttribute returns True, value will contain the
186
* value of the specified attribute.
187
*
188
* Not all attributes require the display_mask parameter; see
189
* NVCtrl.h for details.
190
*
191
* Possible errors:
192
* BadValue - The target doesn't exist.
193
* BadMatch - The NVIDIA driver does not control the target.
194
*/
195
196
Bool XNVCTRLQueryTargetAttribute(Display *dpy,
197
int target_Type,
198
int target_id,
199
unsigned int display_mask,
200
unsigned int attribute,
201
int *value);
202
203
/*
204
* XNVCTRLQueryTargetAttribute64 -
205
*
206
* Returns True if the attribute exists. Returns False otherwise.
207
* If XNVCTRLQueryTargetAttribute returns True, value will contain the
208
* value of the specified attribute.
209
*
210
* Not all attributes require the display_mask parameter; see
211
* NVCtrl.h for details.
212
*
213
* Note: this function behaves like XNVCTRLQueryTargetAttribute(),
214
* but supports 64-bit integer attributes.
215
*
216
* Possible errors:
217
* BadValue - The target doesn't exist.
218
* BadMatch - The NVIDIA driver does not control the target.
219
*/
220
221
Bool XNVCTRLQueryTargetAttribute64(Display *dpy,
222
int target_Type,
223
int target_id,
224
unsigned int display_mask,
225
unsigned int attribute,
226
int64_t *value);
227
228
/*
229
* XNVCTRLQueryStringAttribute -
230
*
231
* Returns True if the attribute exists. Returns False otherwise.
232
* If XNVCTRLQueryStringAttribute returns True, *ptr will point to an
233
* allocated string containing the string attribute requested. It is
234
* the caller's responsibility to free the string when done.
235
*
236
* Calling this function is equivalent to calling
237
* XNVCTRLQueryTargetStringAttribute() with the target_type set to
238
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
239
*
240
* Possible errors:
241
* BadValue - The screen doesn't exist.
242
* BadMatch - The NVIDIA driver is not present on that screen.
243
* BadAlloc - Insufficient resources to fulfill the request.
244
*/
245
246
Bool XNVCTRLQueryStringAttribute(Display *dpy,
247
int screen,
248
unsigned int display_mask,
249
unsigned int attribute,
250
char **ptr);
251
252
/*
253
* XNVCTRLQueryTargetStringAttribute -
254
*
255
* Returns True if the attribute exists. Returns False otherwise.
256
* If XNVCTRLQueryTargetStringAttribute returns True, *ptr will point
257
* to an allocated string containing the string attribute requested.
258
* It is the caller's responsibility to free the string when done.
259
*
260
* Possible errors:
261
* BadValue - The target doesn't exist.
262
* BadMatch - The NVIDIA driver does not control the target.
263
* BadAlloc - Insufficient resources to fulfill the request.
264
*/
265
266
Bool XNVCTRLQueryTargetStringAttribute(Display *dpy,
267
int target_type,
268
int target_id,
269
unsigned int display_mask,
270
unsigned int attribute,
271
char **ptr);
272
273
/*
274
* XNVCTRLSetStringAttribute -
275
*
276
* Returns True if the operation succeded. Returns False otherwise.
277
*
278
* Possible X errors:
279
* BadValue - The screen doesn't exist.
280
* BadMatch - The NVIDIA driver is not present on that screen.
281
* BadAlloc - Insufficient resources to fulfill the request.
282
*/
283
284
Bool XNVCTRLSetStringAttribute(Display *dpy,
285
int screen,
286
unsigned int display_mask,
287
unsigned int attribute,
288
char *ptr);
289
290
/*
291
* XNVCTRLSetTargetStringAttribute -
292
*
293
* Returns True if the operation succeded. Returns False otherwise.
294
*
295
* Possible X errors:
296
* BadValue - The screen doesn't exist.
297
* BadMatch - The NVIDIA driver is not present on that screen.
298
* BadAlloc - Insufficient resources to fulfill the request.
299
*/
300
301
Bool XNVCTRLSetTargetStringAttribute(Display *dpy,
302
int target_type,
303
int target_id,
304
unsigned int display_mask,
305
unsigned int attribute,
306
char *ptr);
307
308
/*
309
* XNVCTRLQueryValidAttributeValues -
310
*
311
* Returns True if the attribute exists. Returns False otherwise. If
312
* XNVCTRLQueryValidAttributeValues returns True, values will indicate
313
* the valid values for the specified attribute; see the description
314
* of NVCTRLAttributeValidValues in NVCtrl.h.
315
*
316
* Calling this function is equivalent to calling
317
* XNVCTRLQueryValidTargetAttributeValues() with the target_type set to
318
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
319
*/
320
321
Bool XNVCTRLQueryValidAttributeValues(Display *dpy,
322
int screen,
323
unsigned int display_mask,
324
unsigned int attribute,
325
NVCTRLAttributeValidValuesRec *values);
326
327
/*
328
* XNVCTRLQueryValidTargetAttributeValues -
329
*
330
* Returns True if the attribute exists. Returns False otherwise. If
331
* XNVCTRLQueryValidTargetAttributeValues returns True, values will indicate
332
* the valid values for the specified attribute.
333
*/
334
335
Bool XNVCTRLQueryValidTargetAttributeValues(Display *dpy,
336
int target_type,
337
int target_id,
338
unsigned int display_mask,
339
unsigned int attribute,
340
NVCTRLAttributeValidValuesRec *values);
341
342
/*
343
* XNVCTRLQueryValidTargetStringAttributeValues -
344
*
345
* Returns True if the attribute exists. Returns False otherwise. If
346
* XNVCTRLQueryValidTargetStringAttributeValues returns True, values will
347
* indicate the valid values for the specified attribute.
348
*/
349
350
Bool XNVCTRLQueryValidTargetStringAttributeValues(Display *dpy,
351
int target_type,
352
int target_id,
353
unsigned int display_mask,
354
unsigned int attribute,
355
NVCTRLAttributeValidValuesRec *values);
356
357
/*
358
* XNVCTRLQueryAttributePermissions -
359
*
360
* Returns True if the attribute exists. Returns False otherwise. If
361
* XNVCTRLQueryAttributePermissions returns True, permissions will
362
* indicate the permission flags for the attribute.
363
*/
364
365
Bool XNVCTRLQueryAttributePermissions(Display *dpy,
366
unsigned int attribute,
367
NVCTRLAttributePermissionsRec *permissions);
368
369
/*
370
* XNVCTRLQueryStringAttributePermissions -
371
*
372
* Returns True if the attribute exists. Returns False otherwise. If
373
* XNVCTRLQueryStringAttributePermissions returns True, permissions will
374
* indicate the permission flags for the attribute.
375
*/
376
377
Bool XNVCTRLQueryStringAttributePermissions(Display *dpy,
378
unsigned int attribute,
379
NVCTRLAttributePermissionsRec *permissions);
380
381
/*
382
* XNVCTRLQueryBinaryDataAttributePermissions -
383
*
384
* Returns True if the attribute exists. Returns False otherwise. If
385
* XNVCTRLQueryBinaryDataAttributePermissions returns True, permissions
386
* will indicate the permission flags for the attribute.
387
*/
388
389
Bool XNVCTRLQueryBinaryDataAttributePermissions(Display *dpy,
390
unsigned int attribute,
391
NVCTRLAttributePermissionsRec *permissions);
392
393
/*
394
* XNVCTRLQueryStringOperationAttributePermissions -
395
*
396
* Returns True if the attribute exists. Returns False otherwise. If
397
* XNVCTRLQueryStringOperationAttributePermissions returns True,
398
* permissions will indicate the permission flags for the attribute.
399
*/
400
401
Bool XNVCTRLQueryStringOperationAttributePermissions(Display *dpy,
402
unsigned int attribute,
403
NVCTRLAttributePermissionsRec *permissions);
404
405
/*
406
* XNVCTRLSetGvoColorConversion -
407
*
408
* Sets the color conversion matrix, offset, and scale that should be
409
* used for GVO (Graphic to Video Out).
410
*
411
* The Color Space Conversion data is ordered like this:
412
*
413
* colorMatrix[0][0] // r.Y
414
* colorMatrix[0][1] // g.Y
415
* colorMatrix[0][2] // b.Y
416
*
417
* colorMatrix[1][0] // r.Cr
418
* colorMatrix[1][1] // g.Cr
419
* colorMatrix[1][2] // b.Cr
420
*
421
* colorMatrix[2][0] // r.Cb
422
* colorMatrix[2][1] // g.Cb
423
* colorMatrix[2][2] // b.Cb
424
*
425
* colorOffset[0] // Y
426
* colorOffset[1] // Cr
427
* colorOffset[2] // Cb
428
*
429
* colorScale[0] // Y
430
* colorScale[1] // Cr
431
* colorScale[2] // Cb
432
*
433
* where the data is used according to the following formulae:
434
*
435
* Y = colorOffset[0] + colorScale[0] *
436
* (R * colorMatrix[0][0] +
437
* G * colorMatrix[0][1] +
438
* B * colorMatrix[0][2]);
439
*
440
* Cr = colorOffset[1] + colorScale[1] *
441
* (R * colorMatrix[1][0] +
442
* G * colorMatrix[1][1] +
443
* B * colorMatrix[1][2]);
444
*
445
* Cb = colorOffset[2] + colorScale[2] *
446
* (R * colorMatrix[2][0] +
447
* G * colorMatrix[2][1] +
448
* B * colorMatrix[2][2]);
449
*
450
* Possible errors:
451
* BadMatch - The NVIDIA driver is not present on that screen.
452
* BadImplementation - GVO is not available on that screen.
453
*/
454
455
void XNVCTRLSetGvoColorConversion(Display *dpy,
456
int screen,
457
float colorMatrix[3][3],
458
float colorOffset[3],
459
float colorScale[3]);
460
461
/*
462
* XNVCTRLQueryGvoColorConversion -
463
*
464
* Retrieves the color conversion matrix and color offset
465
* that are currently being used for GVO (Graphic to Video Out).
466
*
467
* The values are ordered within the arrays according to the comments
468
* for XNVCTRLSetGvoColorConversion().
469
*
470
* Possible errors:
471
* BadMatch - The NVIDIA driver is not present on that screen.
472
* BadImplementation - GVO is not available on that screen.
473
*/
474
475
Bool XNVCTRLQueryGvoColorConversion(Display *dpy,
476
int screen,
477
float colorMatrix[3][3],
478
float colorOffset[3],
479
float colorScale[3]);
480
481
/*
482
* XNVCTRLQueryBinaryData -
483
*
484
* Returns True if the attribute exists. Returns False otherwise.
485
* If XNVCTRLQueryBinaryData returns True, *ptr will point to an
486
* allocated block of memory containing the binary data attribute
487
* requested. It is the caller's responsibility to free the data
488
* when done. len will list the length of the binary data.
489
*
490
* Calling this function is equivalent to calling
491
* XNVCTRLQueryTargetBinaryData() with the target_type set to
492
* NV_CTRL_TARGET_TYPE_X_SCREEN and target_id set to 'screen'.
493
*
494
* Possible errors:
495
* BadValue - The screen doesn't exist.
496
* BadMatch - The NVIDIA driver is not present on that screen.
497
* BadAlloc - Insufficient resources to fulfill the request.
498
*/
499
500
Bool XNVCTRLQueryBinaryData(Display *dpy,
501
int screen,
502
unsigned int display_mask,
503
unsigned int attribute,
504
unsigned char **ptr,
505
int *len);
506
507
/*
508
* XNVCTRLQueryTargetBinaryData -
509
*
510
* Returns True if the attribute exists. Returns False otherwise.
511
* If XNVCTRLQueryTargetBinaryData returns True, *ptr will point to an
512
* allocated block of memory containing the binary data attribute
513
* requested. It is the caller's responsibility to free the data
514
* when done. len will list the length of the binary data.
515
*
516
* Possible errors:
517
* BadValue - The target doesn't exist.
518
* BadMatch - The NVIDIA driver does not control the target.
519
* BadAlloc - Insufficient resources to fulfill the request.
520
*/
521
522
Bool XNVCTRLQueryTargetBinaryData(Display *dpy,
523
int target_type,
524
int target_id,
525
unsigned int display_mask,
526
unsigned int attribute,
527
unsigned char **ptr,
528
int *len);
529
530
/*
531
* XNVCTRLStringOperation -
532
*
533
* Takes a string as input and returns a Xmalloc'ed string as output.
534
* Returns True on success and False on failure.
535
*/
536
537
Bool XNVCTRLStringOperation(Display *dpy,
538
int target_type,
539
int target_id,
540
unsigned int display_mask,
541
unsigned int attribute,
542
char *pIn,
543
char **ppOut);
544
545
/*
546
* XNVCtrlSelectNotify -
547
*
548
* This enables/disables receiving of NV-CONTROL events. The type
549
* specifies the type of event to enable (currently, the only
550
* type that can be requested per-screen with XNVCtrlSelectNotify()
551
* is ATTRIBUTE_CHANGED_EVENT); onoff controls whether receiving this
552
* type of event should be enabled (True) or disabled (False).
553
*
554
* Returns True if successful, or False if the screen is not
555
* controlled by the NVIDIA driver.
556
*/
557
558
Bool XNVCtrlSelectNotify(Display *dpy, int screen, int type, Bool onoff);
559
560
/*
561
* XNVCtrlSelectTargetNotify -
562
*
563
* This enables/disables receiving of NV-CONTROL events that happen on
564
* the specified target. The notify_type specifies the type of event to
565
* enable (currently, the only type that can be requested per-target with
566
* XNVCtrlSelectTargetNotify() is TARGET_ATTRIBUTE_CHANGED_EVENT); onoff
567
* controls whether receiving this type of event should be enabled (True)
568
* or disabled (False).
569
*
570
* Returns True if successful, or False if the target is not
571
* controlled by the NVIDIA driver.
572
*/
573
574
Bool XNVCtrlSelectTargetNotify(Display *dpy,
575
int target_type,
576
int target_id,
577
int notify_type,
578
Bool onoff);
579
580
/*
581
* XNVCtrlEvent structure
582
*/
583
584
typedef struct
585
{
586
int type;
587
unsigned long serial;
588
Bool send_event; /* always FALSE, we don't allow send_events */
589
Display *display;
590
Time time;
591
int screen;
592
unsigned int display_mask;
593
unsigned int attribute;
594
int value;
595
} XNVCtrlAttributeChangedEvent;
596
597
typedef union
598
{
599
int type;
600
XNVCtrlAttributeChangedEvent attribute_changed;
601
long pad[24];
602
} XNVCtrlEvent;
603
604
/*
605
* XNVCtrlEventTarget structure
606
*/
607
608
typedef struct
609
{
610
int type;
611
unsigned long serial;
612
Bool send_event; /* always FALSE, we don't allow send_events */
613
Display *display;
614
Time time;
615
int target_type;
616
int target_id;
617
unsigned int display_mask;
618
unsigned int attribute;
619
int value;
620
} XNVCtrlAttributeChangedEventTarget;
621
622
typedef union
623
{
624
int type;
625
XNVCtrlAttributeChangedEventTarget attribute_changed;
626
long pad[24];
627
} XNVCtrlEventTarget;
628
629
/*
630
* XNVCtrlEventTargetAvailability structure
631
*/
632
633
typedef struct
634
{
635
int type;
636
unsigned long serial;
637
Bool send_event; /* always FALSE, we don't allow send_events */
638
Display *display;
639
Time time;
640
int target_type;
641
int target_id;
642
unsigned int display_mask;
643
unsigned int attribute;
644
int value;
645
Bool availability;
646
} XNVCtrlAttributeChangedEventTargetAvailability;
647
648
typedef union
649
{
650
int type;
651
XNVCtrlAttributeChangedEventTargetAvailability attribute_changed;
652
long pad[24];
653
} XNVCtrlEventTargetAvailability;
654
655
/*
656
* XNVCtrlStringEventTarget structure
657
*/
658
659
typedef struct
660
{
661
int type;
662
unsigned long serial;
663
Bool send_event; /* always FALSE, we don't allow send_events */
664
Display *display;
665
Time time;
666
int target_type;
667
int target_id;
668
unsigned int display_mask;
669
unsigned int attribute;
670
} XNVCtrlStringAttributeChangedEventTarget;
671
672
typedef union
673
{
674
int type;
675
XNVCtrlStringAttributeChangedEventTarget attribute_changed;
676
long pad[24];
677
} XNVCtrlStringEventTarget;
678
679
/*
680
* XNVCtrlBinaryEventTarget structure
681
*/
682
683
typedef struct
684
{
685
int type;
686
unsigned long serial;
687
Bool send_event; /* always FALSE, we don't allow send_events */
688
Display *display;
689
Time time;
690
int target_type;
691
int target_id;
692
unsigned int display_mask;
693
unsigned int attribute;
694
} XNVCtrlBinaryAttributeChangedEventTarget;
695
696
typedef union
697
{
698
int type;
699
XNVCtrlBinaryAttributeChangedEventTarget attribute_changed;
700
long pad[24];
701
} XNVCtrlBinaryEventTarget;
702
703
#if defined __cplusplus
704
} /* extern "C" */
705
#endif
706
707
#endif /* __NVCTRLLIB_H */
708
709