2929
3030def query_target_count (self , target ):
3131 """return the target count"""
32- reply = NVCtrlQueryTargetCountRequest (display = self .display ,
33- opcode = self .display .get_extension_major (extname ),
34- target_type = target .type ())
32+ reply = NVCtrlQueryTargetCountReplyRequest (display = self .display ,
33+ opcode = self .display .get_extension_major (extname ),
34+ target_type = target .type ())
3535 return int (reply ._data .get ('count' ))
3636
3737
@@ -43,12 +43,12 @@ def get_gpu_count(self):
4343def query_int_attribute (self , target , displays , attr ):
4444 """return the value of an integer attribute"""
4545 display_mask = _displays2mask (displays )
46- reply = NVCtrlQueryAttributeRequest (display = self .display ,
47- opcode = self .display .get_extension_major (extname ),
48- target_id = target .id (),
49- target_type = target .type (),
50- display_mask = display_mask ,
51- attr = attr )
46+ reply = NVCtrlQueryAttributeReplyRequest (display = self .display ,
47+ opcode = self .display .get_extension_major (extname ),
48+ target_id = target .id (),
49+ target_type = target .type (),
50+ display_mask = display_mask ,
51+ attr = attr )
5252 if not reply ._data .get ('flags' ):
5353 return None
5454 return int (reply ._data .get ('value' ))
@@ -57,30 +57,44 @@ def query_int_attribute(self, target, displays, attr):
5757def set_int_attribute (self , target , displays , attr , value ):
5858 """return the value of an integer attribute"""
5959 display_mask = _displays2mask (displays )
60- reply = NVCtrlSetAttributeAndGetStatusRequest (display = self .display ,
61- opcode = self .display .get_extension_major (extname ),
62- target_id = target .id (),
63- target_type = target .type (),
64- display_mask = display_mask ,
65- attr = attr ,
66- value = value )
60+ reply = NVCtrlSetAttributeAndGetStatusReplyRequest (display = self .display ,
61+ opcode = self .display .get_extension_major (extname ),
62+ target_id = target .id (),
63+ target_type = target .type (),
64+ display_mask = display_mask ,
65+ attr = attr ,
66+ value = value )
6767 return reply ._data .get ('flags' )
6868
6969
7070def query_string_attribute (self , target , displays , attr ):
7171 """return the value of an integer attribute"""
7272 display_mask = _displays2mask (displays )
73- reply = NVCtrlQueryStringAttributeRequest (display = self .display ,
74- opcode = self .display .get_extension_major (extname ),
75- target_id = target .id (),
76- target_type = target .type (),
77- display_mask = display_mask ,
78- attr = attr )
73+ reply = NVCtrlQueryStringAttributeReplyRequest (display = self .display ,
74+ opcode = self .display .get_extension_major (extname ),
75+ target_id = target .id (),
76+ target_type = target .type (),
77+ display_mask = display_mask ,
78+ attr = attr )
7979 if not reply ._data .get ('flags' ):
8080 return None
8181 return str (reply ._data .get ('string' )).strip ('\0 ' )
8282
8383
84+ def query_valid_attr_values (self , target , displays , attr ):
85+ """return the value of an integer attribute"""
86+ display_mask = _displays2mask (displays )
87+ reply = NVCtrlQueryValidAttributeValuesReplyRequest (display = self .display ,
88+ opcode = self .display .get_extension_major (extname ),
89+ target_id = target .id (),
90+ target_type = target .type (),
91+ display_mask = display_mask ,
92+ attr = attr )
93+ if not reply ._data .get ('flags' ):
94+ return None
95+ return int (reply ._data .get ('min' )), int (reply ._data .get ('max' ))
96+
97+
8498def get_name (self , target ):
8599 """the GPU product name on which the specified X screen is running"""
86100 return query_string_attribute (self , target , [], NV_CTRL_STRING_PRODUCT_NAME )
@@ -201,10 +215,18 @@ def get_gpu_nvclock_offset(self, target):
201215 return query_int_attribute (self , target , [], NV_CTRL_GPU_NVCLOCK_OFFSET )
202216
203217
218+ def get_gpu_nvclock_offset_range (self , target ):
219+ return query_valid_attr_values (self , target , [], NV_CTRL_GPU_NVCLOCK_OFFSET )
220+
221+
204222def get_mem_transfer_rate_offset (self , target ):
205223 return query_int_attribute (self , target , [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET )
206224
207225
226+ def get_mem_transfer_rate_offset_range (self , target ):
227+ return query_valid_attr_values (self , target , [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET )
228+
229+
208230def get_cooler_manual_control_enabled (self , target ):
209231 return query_int_attribute (self , target , [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL ) == 1
210232
@@ -309,6 +331,10 @@ def init(disp, info):
309331 disp .extension_add_method ('display' , 'nvcontrol_get_performance_modes' , get_performance_modes )
310332 disp .extension_add_method ('display' , 'nvcontrol_set_cooler_manual_control_enabled' ,
311333 set_cooler_manual_control_enabled )
334+ disp .extension_add_method ('display' , 'nvcontrol_get_gpu_nvclock_offset_range' ,
335+ get_gpu_nvclock_offset_range )
336+ disp .extension_add_method ('display' , 'nvcontrol_get_mem_transfer_rate_offset_range' ,
337+ get_mem_transfer_rate_offset_range )
312338
313339
314340############################################################################
@@ -5129,7 +5155,7 @@ def __init__(self, nfan=0):
51295155 self ._name = 'Cooler'
51305156
51315157
5132- class NVCtrlQueryAttributeRequest (rq .ReplyRequest ):
5158+ class NVCtrlQueryAttributeReplyRequest (rq .ReplyRequest ):
51335159 _request = rq .Struct (
51345160 rq .Card8 ('opcode' ),
51355161 rq .Opcode (X_nvCtrlQueryAttribute ),
@@ -5153,7 +5179,7 @@ class NVCtrlQueryAttributeRequest(rq.ReplyRequest):
51535179 )
51545180
51555181
5156- class NVCtrlSetAttributeAndGetStatusRequest (rq .ReplyRequest ):
5182+ class NVCtrlSetAttributeAndGetStatusReplyRequest (rq .ReplyRequest ):
51575183 _request = rq .Struct (
51585184 rq .Card8 ('opcode' ),
51595185 rq .Opcode (X_nvCtrlSetAttributeAndGetStatus ),
@@ -5178,7 +5204,7 @@ class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest):
51785204 )
51795205
51805206
5181- class NVCtrlQueryStringAttributeRequest (rq .ReplyRequest ):
5207+ class NVCtrlQueryStringAttributeReplyRequest (rq .ReplyRequest ):
51825208 _request = rq .Struct (
51835209 rq .Card8 ('opcode' ),
51845210 rq .Opcode (X_nvCtrlQueryStringAttribute ),
@@ -5203,7 +5229,7 @@ class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest):
52035229 )
52045230
52055231
5206- class NVCtrlQueryTargetCountRequest (rq .ReplyRequest ):
5232+ class NVCtrlQueryTargetCountReplyRequest (rq .ReplyRequest ):
52075233 _request = rq .Struct (
52085234 rq .Card8 ('opcode' ),
52095235 rq .Opcode (X_nvCtrlQueryTargetCount ),
@@ -5222,3 +5248,27 @@ class NVCtrlQueryTargetCountRequest(rq.ReplyRequest):
52225248 rq .Card32 ('pad7' ),
52235249 rq .Card32 ('pad8' ),
52245250 )
5251+
5252+
5253+ class NVCtrlQueryValidAttributeValuesReplyRequest (rq .ReplyRequest ):
5254+ _request = rq .Struct (
5255+ rq .Card8 ('opcode' ),
5256+ rq .Opcode (X_nvCtrlQueryValidAttributeValues ),
5257+ rq .RequestLength (),
5258+ rq .Card16 ('target_id' ),
5259+ rq .Card16 ('target_type' ),
5260+ rq .Card32 ('display_mask' ),
5261+ rq .Card32 ('attr' ),
5262+ )
5263+ _reply = rq .Struct (
5264+ rq .ReplyCode (),
5265+ rq .Card8 ('pad0' ),
5266+ rq .Card16 ('sequence_number' ),
5267+ rq .ReplyLength (),
5268+ rq .Card32 ('flags' ),
5269+ rq .Int32 ('attr_type' ),
5270+ rq .Int32 ('min' ),
5271+ rq .Int32 ('max' ),
5272+ rq .Card32 ('bits' ),
5273+ rq .Card32 ('perms' ),
5274+ )
0 commit comments