-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathnvcontrol.py
More file actions
5383 lines (4572 loc) · 182 KB
/
Copy pathnvcontrol.py
File metadata and controls
5383 lines (4572 loc) · 182 KB
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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Xlib.ext.nvcontrol -- NV-CONTROL extension module
#
# Copyright (C) 2019 Roberto Leinardi <roberto@leinardi.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# This library 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
"""NV-CONTROL - provide access to the NV-CONTROL extension information."""
from Xlib.protocol import rq
extname = 'NV-CONTROL'
def query_target_count(self, target):
"""Return the target count"""
reply = NVCtrlQueryTargetCountReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_type=target.type())
return int(reply._data.get('count'))
def query_int_attribute(self, target, display_mask, attr):
"""Return the value of an integer attribute"""
reply = NVCtrlQueryAttributeReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_id=target.id(),
target_type=target.type(),
display_mask=display_mask,
attr=attr)
if not reply._data.get('flags'):
return None
return int(reply._data.get('value'))
def set_int_attribute(self, target, display_mask, attr, value):
"""Set the value of an integer attribute"""
reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_id=target.id(),
target_type=target.type(),
display_mask=display_mask,
attr=attr,
value=value)
return reply._data.get('flags') != 0
def query_string_attribute(self, target, display_mask, attr):
"""Return the value of a string attribute"""
reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_id=target.id(),
target_type=target.type(),
display_mask=display_mask,
attr=attr)
if not reply._data.get('flags'):
return None
return str(reply._data.get('string')).strip('\0')
def query_valid_attr_values(self, target, display_mask, attr):
"""Return the value of an integer attribute"""
reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_id=target.id(),
target_type=target.type(),
display_mask=display_mask,
attr=attr)
if not reply._data.get('flags'):
return None
return int(reply._data.get('min')), int(reply._data.get('max'))
def query_binary_data(self, target, display_mask, attr):
"""Return binary data"""
reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_id=target.id(),
target_type=target.type(),
display_mask=display_mask,
attr=attr)
if not reply._data.get('flags'):
return None
return reply._data.get('data')
def get_coolers_used_by_gpu(self, target):
reply = NVCtrlQueryListCard32ReplyRequest(display=self.display,
opcode=self.display.get_extension_major(extname),
target_id=target.id(),
target_type=target.type(),
display_mask=0,
attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU)
if not reply._data.get('flags'):
return None
fans = reply._data.get('list')
if len(fans) > 1:
return fans[1:]
else:
return None
def get_gpu_count(self):
"""Return the number of GPU's present in the system."""
return int(query_target_count(self, Gpu()))
def get_name(self, target):
"""Return the GPU product name on which the specified X screen is running"""
return query_string_attribute(self, target, 0, NV_CTRL_STRING_PRODUCT_NAME)
def get_driver_version(self, target):
"""Return the NVIDIA (kernel level) driver version for the specified screen or GPU"""
return query_string_attribute(self, target, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION)
def get_vbios_version(self, target):
"""Return the version of the VBIOS for the specified screen or GPU"""
return query_string_attribute(self, target, 0, NV_CTRL_STRING_VBIOS_VERSION)
def get_gpu_uuid(self, target):
return query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UUID)
def get_utilization_rates(self, target):
string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UTILIZATION)
result = {}
if string is not None and string != '':
for line in string.split(','):
[key, value] = line.split('=')[:2]
result[key.strip()] = int(value) if value.isdigit() else value
return result
def get_performance_modes(self, target):
string = query_string_attribute(self, target, 0, NV_CTRL_STRING_PERFORMANCE_MODES)
result = []
if string is not None and string != '':
for perf in string.split(';'):
perf_dict = {}
for line in perf.split(','):
[key, value] = line.split('=')[:2]
perf_dict[key.strip()] = int(value) if value.isdigit() else value
result.append(perf_dict)
return result
def get_clock_info(self, target):
string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS)
result = {}
if string is not None and string != '':
for line in string.split(','):
[key, value] = line.split('=')[:2]
result[key.strip()] = int(value) if value.isdigit() else value
return result
def get_vram(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_RAM)
def get_irq(self, target):
"""Return the interrupt request line used by the GPU driving the screen"""
return query_int_attribute(self, target, 0, NV_CTRL_IRQ)
def supports_framelock(self, target):
"""Return whether the underlying GPU supports Frame Lock.
All of the other frame lock attributes are only applicable if this returns True.
"""
return query_int_attribute(self, target, 0, NV_CTRL_FRAMELOCK) == 1
def gvo_supported(self, screen):
"""Return whether this X screen supports GVO
If this screen does not support GVO output, then all other GVO attributes are unavailable.
"""
return query_int_attribute(self, screen, [], NV_CTRL_GVO_SUPPORTED)
def get_core_temp(self, target):
"""Return the current core temperature of the GPU driving the X screen."""
return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_TEMPERATURE)
def get_core_threshold(self, target):
"""Return the current GPU core slowdown threshold temperature.
It reflects the temperature at which the GPU is throttled to prevent overheating.
"""
return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_THRESHOLD)
def get_default_core_threshold(self, target):
"""Return the default core threshold temperature."""
return query_int_attribute(self, target, 0, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD)
def get_max_core_threshold(self, target):
"""Return the maximum core threshold temperature."""
return query_int_attribute(self, target, 0, NV_CTRL_GPU_MAX_CORE_THRESHOLD)
def get_ambient_temp(self, target):
"""Return the current temperature in the immediate neighbourhood of the GPU driving the X screen."""
return query_int_attribute(self, target, 0, NV_CTRL_AMBIENT_TEMPERATURE)
def get_cuda_cores(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORES)
def get_memory_bus_width(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_MEMORY_BUS_WIDTH)
def get_total_dedicated_gpu_memory(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY)
def get_used_dedicated_gpu_memory(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_USED_DEDICATED_GPU_MEMORY)
def get_curr_pcie_link_width(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH)
def get_max_pcie_link_width(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH)
def get_curr_pcie_link_generation(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_GENERATION)
def get_encoder_utilization(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_ENCODER_UTILIZATION)
def get_decoder_utilization(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_DECODER_UTILIZATION)
def get_current_performance_level(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL)
def get_gpu_nvclock_offset(self, target, perf_level):
return query_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET)
def set_gpu_nvclock_offset(self, target, perf_level, offset):
return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET, offset)
def get_gpu_nvclock_offset_range(self, target, perf_level):
return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET)
def get_mem_transfer_rate_offset(self, target, perf_level):
return query_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET)
def set_mem_transfer_rate_offset(self, target, perf_level, offset):
return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET, offset)
def get_mem_transfer_rate_offset_range(self, target, perf_level):
return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET)
def get_cooler_manual_control_enabled(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL)
def set_cooler_manual_control_enabled(self, target, enabled):
return set_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1
def get_fan_duty(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL)
def set_fan_duty(self, cooler, speed):
return set_int_attribute(self, cooler, 0, NV_CTRL_THERMAL_COOLER_LEVEL, speed)
def get_fan_rpm(self, target):
return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_SPEED)
def get_max_displays(self, target):
"""Return the maximum number of display devices that can be driven simultaneously on a GPU.
Note that this does not indicate the maximum number of bits that can be set in
NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be connected than are actively
in use.
"""
return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS)
def _displaystr2num(st):
"""Return a display number from a string"""
num = None
for s, n in [('DFP-', 16), ('TV-', 8), ('CRT-', 0)]:
if st.startswith(s):
try:
curnum = int(st[len(s):])
if 0 <= curnum <= 7:
num = n + curnum
break
except Exception:
pass
if num is not None:
return num
else:
raise ValueError('Unrecognised display name: ' + st)
def _displays2mask(displays):
"""Return a display mask from an array of display numbers."""
mask = 0
for d in displays:
mask += (1 << _displaystr2num(d))
return mask
def init(disp, info):
disp.extension_add_method('display', 'nvcontrol_query_target_count', query_target_count)
disp.extension_add_method('display', 'nvcontrol_query_int_attribute', query_int_attribute)
disp.extension_add_method('display', 'nvcontrol_query_string_attribute', query_string_attribute)
disp.extension_add_method('display', 'nvcontrol_query_valid_attr_values', query_valid_attr_values)
disp.extension_add_method('display', 'nvcontrol_query_binary_data', query_binary_data)
disp.extension_add_method('display', 'nvcontrol_get_gpu_count', get_gpu_count)
disp.extension_add_method('display', 'nvcontrol_get_vram', get_vram)
disp.extension_add_method('display', 'nvcontrol_get_irq', get_irq)
disp.extension_add_method('display', 'nvcontrol_supports_framelock', supports_framelock)
disp.extension_add_method('display', 'nvcontrol_get_core_temp', get_core_temp)
disp.extension_add_method('display', 'nvcontrol_get_core_threshold', get_core_threshold)
disp.extension_add_method('display', 'nvcontrol_get_default_core_threshold', get_default_core_threshold)
disp.extension_add_method('display', 'nvcontrol_get_max_core_threshold', get_max_core_threshold)
disp.extension_add_method('display', 'nvcontrol_get_ambient_temp', get_ambient_temp)
disp.extension_add_method('display', 'nvcontrol_get_cuda_cores', get_cuda_cores)
disp.extension_add_method('display', 'nvcontrol_get_memory_bus_width', get_memory_bus_width)
disp.extension_add_method('display', 'nvcontrol_get_total_dedicated_gpu_memory', get_total_dedicated_gpu_memory)
disp.extension_add_method('display', 'nvcontrol_get_used_dedicated_gpu_memory', get_used_dedicated_gpu_memory)
disp.extension_add_method('display', 'nvcontrol_get_curr_pcie_link_width', get_curr_pcie_link_width)
disp.extension_add_method('display', 'nvcontrol_get_max_pcie_link_width', get_max_pcie_link_width)
disp.extension_add_method('display', 'nvcontrol_get_curr_pcie_link_generation', get_curr_pcie_link_generation)
disp.extension_add_method('display', 'nvcontrol_get_encoder_utilization', get_encoder_utilization)
disp.extension_add_method('display', 'nvcontrol_get_decoder_utilization', get_decoder_utilization)
disp.extension_add_method('display', 'nvcontrol_get_current_performance_level', get_current_performance_level)
disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset', get_gpu_nvclock_offset)
disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset', set_gpu_nvclock_offset)
disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset', get_mem_transfer_rate_offset)
disp.extension_add_method('display', 'nvcontrol_set_mem_transfer_rate_offset', set_mem_transfer_rate_offset)
disp.extension_add_method('display', 'nvcontrol_get_cooler_manual_control_enabled',
get_cooler_manual_control_enabled)
disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty)
disp.extension_add_method('display', 'nvcontrol_set_fan_duty', set_fan_duty)
disp.extension_add_method('display', 'nvcontrol_get_fan_rpm', get_fan_rpm)
disp.extension_add_method('display', 'nvcontrol_get_coolers_used_by_gpu', get_coolers_used_by_gpu)
disp.extension_add_method('display', 'nvcontrol_get_max_displays', get_max_displays)
disp.extension_add_method('display', 'nvcontrol_get_name', get_name)
disp.extension_add_method('display', 'nvcontrol_get_driver_version', get_driver_version)
disp.extension_add_method('display', 'nvcontrol_get_vbios_version', get_vbios_version)
disp.extension_add_method('display', 'nvcontrol_get_gpu_uuid', get_gpu_uuid)
disp.extension_add_method('display', 'nvcontrol_get_utilization_rates', get_utilization_rates)
disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes)
disp.extension_add_method('display', 'nvcontrol_get_clock_info', get_clock_info)
disp.extension_add_method('display', 'nvcontrol_set_cooler_manual_control_enabled',
set_cooler_manual_control_enabled)
disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset_range',
get_gpu_nvclock_offset_range)
disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset_range',
get_mem_transfer_rate_offset_range)
############################################################################
#
# Attributes
#
# Some attributes may only be read; some may require a display_mask
# argument and others may be valid only for specific target types.
# This information is encoded in the "permission" comment after each
# attribute #define, and can be queried at run time with
# XNVCTRLQueryValidAttributeValues() and/or
# XNVCTRLQueryValidTargetAttributeValues()
#
# 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.
#
# Alternatively, NV-CONTROL versions 1.27 and greater allow these
# attributes to be accessed via display target types, in which case
# the display_mask is ignored.
#
# G: The attribute may be queried using an NV_CTRL_TARGET_TYPE_GPU
# target type via XNVCTRLQueryTargetAttribute().
#
# F: The attribute may be queried using an NV_CTRL_TARGET_TYPE_FRAMELOCK
# target type via XNVCTRLQueryTargetAttribute().
#
# X: When Xinerama is enabled, this attribute is kept consistent across
# all Physical X Screens; assignment of this attribute will be
# broadcast by the NVIDIA X Driver to all X Screens.
#
# V: The attribute may be queried using an NV_CTRL_TARGET_TYPE_VCSC
# target type via XNVCTRLQueryTargetAttribute().
#
# I: The attribute may be queried using an NV_CTRL_TARGET_TYPE_GVI target type
# via XNVCTRLQueryTargetAttribute().
#
# Q: The attribute is a 64-bit integer attribute; use the 64-bit versions
# of the appropriate query interfaces.
#
# C: The attribute may be queried using an NV_CTRL_TARGET_TYPE_COOLER target
# type via XNVCTRLQueryTargetAttribute().
#
# S: The attribute may be queried using an NV_CTRL_TARGET_TYPE_THERMAL_SENSOR
# target type via XNVCTRLQueryTargetAttribute().
#
# T: The attribute may be queried using an
# NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER target type
# via XNVCTRLQueryTargetAttribute().
#
# NOTE: Unless mentioned otherwise, all attributes may be queried using
# an NV_CTRL_TARGET_TYPE_X_SCREEN target type via
# XNVCTRLQueryTargetAttribute().
#
############################################################################
#
# Integer attributes:
#
# Integer attributes can be queried through the XNVCTRLQueryAttribute() and
# XNVCTRLQueryTargetAttribute() function calls.
#
# Integer attributes can be set through the XNVCTRLSetAttribute() and
# XNVCTRLSetTargetAttribute() function calls.
#
# Unless otherwise noted, all integer attributes can be queried/set
# using an NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot
# take an NV_CTRL_TARGET_TYPE_X_SCREEN also cannot be queried/set through
# XNVCTRLQueryAttribute()/XNVCTRLSetAttribute() (Since these assume
# an X Screen target).
#
#
# NV_CTRL_FLATPANEL_SCALING - not supported
#
NV_CTRL_FLATPANEL_SCALING = 2 # not supported
NV_CTRL_FLATPANEL_SCALING_DEFAULT = 0 # not supported
NV_CTRL_FLATPANEL_SCALING_NATIVE = 1 # not supported
NV_CTRL_FLATPANEL_SCALING_SCALED = 2 # not supported
NV_CTRL_FLATPANEL_SCALING_CENTERED = 3 # not supported
NV_CTRL_FLATPANEL_SCALING_ASPECT_SCALED = 4 # not supported
#
# NV_CTRL_FLATPANEL_DITHERING - not supported
#
# NV_CTRL_DITHERING should be used instead.
#
NV_CTRL_FLATPANEL_DITHERING = 3 # not supported
NV_CTRL_FLATPANEL_DITHERING_DEFAULT = 0 # not supported
NV_CTRL_FLATPANEL_DITHERING_ENABLED = 1 # not supported
NV_CTRL_FLATPANEL_DITHERING_DISABLED = 2 # not supported
#
# NV_CTRL_DITHERING - the requested dithering configuration;
# possible values are:
#
# 0: auto (the driver will decide when to dither)
# 1: enabled (the driver will always dither when possible)
# 2: disabled (the driver will never dither)
#
NV_CTRL_DITHERING = 3 # RWDG
NV_CTRL_DITHERING_AUTO = 0
NV_CTRL_DITHERING_ENABLED = 1
NV_CTRL_DITHERING_DISABLED = 2
#
# NV_CTRL_DIGITAL_VIBRANCE - sets the digital vibrance level for the
# specified display device.
#
NV_CTRL_DIGITAL_VIBRANCE = 4 # RWDG
#
# NV_CTRL_BUS_TYPE - returns the bus type through which the specified device
# is connected to the computer.
# When this attribute is queried on an X screen target, the bus type of the
# GPU driving the X screen is returned.
#
NV_CTRL_BUS_TYPE = 5 # R--GI
NV_CTRL_BUS_TYPE_AGP = 0
NV_CTRL_BUS_TYPE_PCI = 1
NV_CTRL_BUS_TYPE_PCI_EXPRESS = 2
NV_CTRL_BUS_TYPE_INTEGRATED = 3
#
# NV_CTRL_TOTAL_GPU_MEMORY - returns the total amount of memory available
# to the specified GPU (or the GPU driving the specified X
# screen). Note: if the GPU supports TurboCache(TM), the value
# reported may exceed the amount of video memory installed on the
# GPU. The value reported for integrated GPUs may likewise exceed
# the amount of dedicated system memory set aside by the system
# BIOS for use by the integrated GPU.
#
NV_CTRL_TOTAL_GPU_MEMORY = 6 # R--G
NV_CTRL_VIDEO_RAM = NV_CTRL_TOTAL_GPU_MEMORY
#
# NV_CTRL_IRQ - returns the interrupt request line used by the specified
# device.
# When this attribute is queried on an X screen target, the IRQ of the GPU
# driving the X screen is returned.
#
NV_CTRL_IRQ = 7 # R--GI
#
# NV_CTRL_OPERATING_SYSTEM - returns the operating system on which
# the X server is running.
#
NV_CTRL_OPERATING_SYSTEM = 8 # R--G
NV_CTRL_OPERATING_SYSTEM_LINUX = 0
NV_CTRL_OPERATING_SYSTEM_FREEBSD = 1
NV_CTRL_OPERATING_SYSTEM_SUNOS = 2
#
# 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.
#
NV_CTRL_SYNC_TO_VBLANK = 9 # RW-X
NV_CTRL_SYNC_TO_VBLANK_OFF = 0
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.
#
NV_CTRL_LOG_ANISO = 10 # RW-X
#
# 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"
# NV_CTRL_FSAA_MODE_8xS "4x Multisampling by 2x Supersampling"
#
# This setting is only applied to OpenGL clients that are started
# after this setting is applied.
#
NV_CTRL_FSAA_MODE = 11 # RW-X
NV_CTRL_FSAA_MODE_NONE = 0
NV_CTRL_FSAA_MODE_2x = 1
NV_CTRL_FSAA_MODE_2x_5t = 2
NV_CTRL_FSAA_MODE_15x15 = 3
NV_CTRL_FSAA_MODE_2x2 = 4
NV_CTRL_FSAA_MODE_4x = 5
NV_CTRL_FSAA_MODE_4x_9t = 6
NV_CTRL_FSAA_MODE_8x = 7
NV_CTRL_FSAA_MODE_16x = 8
NV_CTRL_FSAA_MODE_8xS = 9
NV_CTRL_FSAA_MODE_8xQ = 10
NV_CTRL_FSAA_MODE_16xS = 11
NV_CTRL_FSAA_MODE_16xQ = 12
NV_CTRL_FSAA_MODE_32xS = 13
NV_CTRL_FSAA_MODE_32x = 14
NV_CTRL_FSAA_MODE_64xS = 15
NV_CTRL_FSAA_MODE_MAX = NV_CTRL_FSAA_MODE_64xS
#
# NV_CTRL_UBB - returns whether UBB is enabled for the specified X
# screen.
#
NV_CTRL_UBB = 13 # R--
NV_CTRL_UBB_OFF = 0
NV_CTRL_UBB_ON = 1
#
# NV_CTRL_OVERLAY - returns whether the RGB overlay is enabled for
# the specified X screen.
#
NV_CTRL_OVERLAY = 14 # R--
NV_CTRL_OVERLAY_OFF = 0
NV_CTRL_OVERLAY_ON = 1
#
# NV_CTRL_STEREO - returns whether stereo (and what type) is enabled
# for the specified X screen.
#
NV_CTRL_STEREO = 16 # R--
NV_CTRL_STEREO_OFF = 0
NV_CTRL_STEREO_DDC = 1
NV_CTRL_STEREO_BLUELINE = 2
NV_CTRL_STEREO_DIN = 3
NV_CTRL_STEREO_PASSIVE_EYE_PER_DPY = 4
NV_CTRL_STEREO_VERTICAL_INTERLACED = 5
NV_CTRL_STEREO_COLOR_INTERLACED = 6
NV_CTRL_STEREO_HORIZONTAL_INTERLACED = 7
NV_CTRL_STEREO_CHECKERBOARD_PATTERN = 8
NV_CTRL_STEREO_INVERSE_CHECKERBOARD_PATTERN = 9
NV_CTRL_STEREO_3D_VISION = 10
NV_CTRL_STEREO_3D_VISION_PRO = 11
NV_CTRL_STEREO_HDMI_3D = 12
NV_CTRL_STEREO_TRIDELITY_SL = 13
NV_CTRL_STEREO_INBAND_STEREO_SIGNALING = 14
NV_CTRL_STEREO_MAX = NV_CTRL_STEREO_INBAND_STEREO_SIGNALING
#
# NV_CTRL_EMULATE - not supported
#
NV_CTRL_EMULATE = 17 # not supported
NV_CTRL_EMULATE_NONE = 0 # not supported
#
# NV_CTRL_TWINVIEW - returns whether TwinView is enabled for the
# specified X screen.
#
NV_CTRL_TWINVIEW = 18 # R--
NV_CTRL_TWINVIEW_NOT_ENABLED = 0
NV_CTRL_TWINVIEW_ENABLED = 1
#
# NV_CTRL_CONNECTED_DISPLAYS - deprecated
#
# NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU and
# NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead.
#
NV_CTRL_CONNECTED_DISPLAYS = 19 # deprecated
#
# NV_CTRL_ENABLED_DISPLAYS - Event that notifies when one or more display
# devices are enabled or disabled on a GPU and/or X screen.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target.
#
# Note: Querying this value has been deprecated.
# NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU,
# NV_CTRL_DISPLAY_ENABLED, and
# NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN should be used
# instead to obtain the list of enabled displays.
#
NV_CTRL_ENABLED_DISPLAYS = 20 # ---G
############################################################################
#
# Integer attributes specific to configuring Frame Lock on boards that
# support it.
#
#
# NV_CTRL_FRAMELOCK - returns whether the underlying GPU supports
# Frame Lock. All of the other frame lock attributes are only
# applicable if NV_CTRL_FRAMELOCK is _SUPPORTED.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target.
#
NV_CTRL_FRAMELOCK = 21 # R--G
NV_CTRL_FRAMELOCK_NOT_SUPPORTED = 0
NV_CTRL_FRAMELOCK_SUPPORTED = 1
#
# NV_CTRL_FRAMELOCK_MASTER - deprecated
#
# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead.
#
NV_CTRL_FRAMELOCK_MASTER = 22 # deprecated
NV_CTRL_FRAMELOCK_MASTER_FALSE = 0 # deprecated
NV_CTRL_FRAMELOCK_MASTER_TRUE = 1 # deprecated
#
# NV_CTRL_FRAMELOCK_POLARITY - sync either to the rising edge of the
# frame lock pulse, the falling edge of the frame lock pulse or both.
#
# On Quadro Sync II, this attribute is ignored when
# NV_CTRL_USE_HOUSE_SYNC is OUTPUT.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_POLARITY = 23 # RW-F
NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE = 0x1
NV_CTRL_FRAMELOCK_POLARITY_FALLING_EDGE = 0x2
NV_CTRL_FRAMELOCK_POLARITY_BOTH_EDGES = 0x3
#
# NV_CTRL_FRAMELOCK_SYNC_DELAY - delay between the frame lock pulse
# and the GPU sync. This value must be multiplied by
# NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION to determine the sync delay in
# nanoseconds.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
# USAGE NOTE: NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX and
# NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR are deprecated.
# The Sync Delay _MAX and _FACTOR are different for different
# Quadro Sync products and so, to be correct, the valid values for
# NV_CTRL_FRAMELOCK_SYNC_DELAY must be queried to get the range
# of acceptable sync delay values, and
# NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION must be queried to
# obtain the correct factor.
#
NV_CTRL_FRAMELOCK_SYNC_DELAY = 24 # RW-F
NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX = 2047 # deprecated
NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR = 7.81 # deprecated
#
# NV_CTRL_FRAMELOCK_SYNC_INTERVAL - how many house sync pulses
# between the frame lock sync generation (0 == sync every house sync);
# this only applies to the master when receiving house sync.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_SYNC_INTERVAL = 25 # RW-F
#
# NV_CTRL_FRAMELOCK_PORT0_STATUS - status of the rj45 port0.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_PORT0_STATUS = 26 # R--F
NV_CTRL_FRAMELOCK_PORT0_STATUS_INPUT = 0
NV_CTRL_FRAMELOCK_PORT0_STATUS_OUTPUT = 1
#
# NV_CTRL_FRAMELOCK_PORT1_STATUS - status of the rj45 port1.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_PORT1_STATUS = 27 # R--F
NV_CTRL_FRAMELOCK_PORT1_STATUS_INPUT = 0
NV_CTRL_FRAMELOCK_PORT1_STATUS_OUTPUT = 1
#
# NV_CTRL_FRAMELOCK_HOUSE_STATUS - returns whether or not the house
# sync input signal was detected on the BNC connector of the frame lock
# board.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_HOUSE_STATUS = 28 # R--F
NV_CTRL_FRAMELOCK_HOUSE_STATUS_NOT_DETECTED = 0
NV_CTRL_FRAMELOCK_HOUSE_STATUS_DETECTED = 1
#
# NV_CTRL_FRAMELOCK_SYNC - enable/disable the syncing of display
# devices to the frame lock pulse as specified by previous calls to
# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG.
#
# This attribute can only be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be
# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN.
#
NV_CTRL_FRAMELOCK_SYNC = 29 # RW-G
NV_CTRL_FRAMELOCK_SYNC_DISABLE = 0
NV_CTRL_FRAMELOCK_SYNC_ENABLE = 1
#
# NV_CTRL_FRAMELOCK_SYNC_READY - reports whether a frame lock
# board is receiving sync (regardless of whether or not any display
# devices are using the sync).
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_SYNC_READY = 30 # R--F
NV_CTRL_FRAMELOCK_SYNC_READY_FALSE = 0
NV_CTRL_FRAMELOCK_SYNC_READY_TRUE = 1
#
# NV_CTRL_FRAMELOCK_STEREO_SYNC - this indicates that the GPU stereo
# signal is in sync with the frame lock stereo signal.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_STEREO_SYNC = 31 # R--G
NV_CTRL_FRAMELOCK_STEREO_SYNC_FALSE = 0
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 frame lock.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target.
#
NV_CTRL_FRAMELOCK_TEST_SIGNAL = 32 # RW-G
NV_CTRL_FRAMELOCK_TEST_SIGNAL_DISABLE = 0
NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE = 1
#
# NV_CTRL_FRAMELOCK_ETHERNET_DETECTED - The frame lock 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.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_ETHERNET_DETECTED = 33 # R--F
NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_NONE = 0
NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT0 = 0x1
NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT1 = 0x2
#
# NV_CTRL_FRAMELOCK_VIDEO_MODE - get/set what video mode is used
# to interperate the house sync signal. This should only be set
# on the master.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_VIDEO_MODE = 34 # RW-F
NV_CTRL_FRAMELOCK_VIDEO_MODE_NONE = 0
NV_CTRL_FRAMELOCK_VIDEO_MODE_TTL = 1
NV_CTRL_FRAMELOCK_VIDEO_MODE_NTSCPALSECAM = 2
NV_CTRL_FRAMELOCK_VIDEO_MODE_HDTV = 3
#
# During FRAMELOCK bring-up, the above values were redefined to
# these:
#
NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_AUTO = 0
NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_BI_LEVEL = 2
NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_TRI_LEVEL = 3
#
# NV_CTRL_FRAMELOCK_SYNC_RATE - this is the refresh rate that the
# frame lock board is sending to the GPU, in milliHz.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN
# target.
#
NV_CTRL_FRAMELOCK_SYNC_RATE = 35 # R--F
############################################################################
#
# NV_CTRL_FORCE_GENERIC_CPU - not supported
#
NV_CTRL_FORCE_GENERIC_CPU = 37 # not supported
NV_CTRL_FORCE_GENERIC_CPU_DISABLE = 0 # not supported
NV_CTRL_FORCE_GENERIC_CPU_ENABLE = 1 # not supported
#
# 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.
#
NV_CTRL_OPENGL_AA_LINE_GAMMA = 38 # RW-X
NV_CTRL_OPENGL_AA_LINE_GAMMA_DISABLE = 0
NV_CTRL_OPENGL_AA_LINE_GAMMA_ENABLE = 1
#
# NV_CTRL_FRAMELOCK_TIMING - this is TRUE when the gpu is both receiving
# and locked to an input timing signal. Timing information may come from
# the following places: Another frame lock device that is set to master,
# the house sync signal, or the GPU's internal timing from a display
# device.
#
# This attribute may be queried through XNVCTRLQueryTargetAttribute()
# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target.
#
NV_CTRL_FRAMELOCK_TIMING = 39 # R--G
NV_CTRL_FRAMELOCK_TIMING_FALSE = 0
NV_CTRL_FRAMELOCK_TIMING_TRUE = 1
#
# NV_CTRL_FLIPPING_ALLOWED - when TRUE, OpenGL will swap by flipping
# when possible; when FALSE, OpenGL will always swap by blitting.
#
NV_CTRL_FLIPPING_ALLOWED = 40 # RW-X
NV_CTRL_FLIPPING_ALLOWED_FALSE = 0
NV_CTRL_FLIPPING_ALLOWED_TRUE = 1