From 3c8812e3b6bd29f35d06cdc8296d01f1bfe89798 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 6 Jun 2018 14:41:39 +0200 Subject: [PATCH 001/100] support/unix_connect: fix protocol handling - fix support for explicit unix connections - fix macOS support --- Xlib/protocol/display.py | 4 ++-- Xlib/support/connect.py | 8 +++---- Xlib/support/unix_connect.py | 45 ++++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 4f431e99..6453b49d 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -89,8 +89,8 @@ def __init__(self, display = None): self.socket = connect.get_socket(name, protocol, host, displayno) - auth_name, auth_data = connect.get_auth(self.socket, - name, host, displayno) + auth_name, auth_data = connect.get_auth(self.socket, name, + protocol, host, displayno) # Internal structures for communication, grouped # by their function and locks diff --git a/Xlib/support/connect.py b/Xlib/support/connect.py index 93b26c0e..4db4c2f4 100644 --- a/Xlib/support/connect.py +++ b/Xlib/support/connect.py @@ -87,11 +87,11 @@ def get_socket(dname, protocol, host, dno): return mod.get_socket(dname, protocol, host, dno) -def get_auth(sock, dname, host, dno): - """auth_name, auth_data = get_auth(sock, dname, host, dno) +def get_auth(sock, dname, protocol, host, dno): + """auth_name, auth_data = get_auth(sock, dname, protocol, host, dno) Return authentication data for the display on the other side of - SOCK, which was opened with DNAME, HOST and DNO. + SOCK, which was opened with DNAME, HOST and DNO, using PROTOCOL. Return AUTH_NAME and AUTH_DATA, two strings to be used in the connection setup request. @@ -99,4 +99,4 @@ def get_auth(sock, dname, host, dno): modname = _auth_mods.get(platform, _default_auth_mod) mod = _relative_import(modname) - return mod.get_auth(sock, dname, host, dno) + return mod.get_auth(sock, dname, protocol, host, dno) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 25a8f3ac..c2261dae 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -42,36 +42,50 @@ from Xlib import error, xauth + +SUPPORTED_PROTOCOLS = (None, 'tcp', 'unix') + +# Darwin funky socket. uname = platform.uname() if (uname[0] == 'Darwin') and ([int(x) for x in uname[2].split('.')] >= [9, 0]): + SUPPORTED_PROTOCOLS += ('darwin',) + DARWIN_DISPLAY_RE = re.compile(r'^/private/tmp/[-:a-zA-Z0-9._]*:(?P[0-9]+)(\.(?P[0-9]+))?$') - display_re = re.compile(r'^(?P)(?P[-:a-zA-Z0-9._/]*):(?P[0-9]+)(\.(?P[0-9]+))?$') - -else: +DISPLAY_RE = re.compile(r'^((?Ptcp|unix)/)?(?P[-:a-zA-Z0-9._]*):(?P[0-9]+)(\.(?P[0-9]+))?$') - display_re = re.compile(r'^((?Ptcp|unix)/)?(?P[-:a-zA-Z0-9._]*):(?P[0-9]+)(\.(?P[0-9]+))?$') def get_display(display): # Use $DISPLAY if display isn't provided if display is None: display = os.environ.get('DISPLAY', '') - m = display_re.match(display) - if not m: + re_list = [(DISPLAY_RE, {})] + + if 'darwin' in SUPPORTED_PROTOCOLS: + re_list.insert(0, (DARWIN_DISPLAY_RE, {'protocol': 'darwin'})) + + for re, defaults in re_list: + m = re.match(display) + if m is not None: + protocol, host, dno, screen = [ + m.groupdict().get(field, defaults.get(field)) + for field in ('proto', 'host', 'dno', 'screen') + ] + break + else: raise error.DisplayNameError(display) - name = display - protocol, host, dno, screen = m.group('proto', 'host', 'dno', 'screen') if protocol == 'tcp' and not host: # Host is mandatory when protocol is TCP. raise error.DisplayNameError(display) + dno = int(dno) if screen: screen = int(screen) else: screen = 0 - return name, protocol, host, dno, screen + return display, protocol, host, dno, screen def _get_tcp_socket(host, dno): @@ -85,14 +99,14 @@ def _get_unix_socket(address): return s def get_socket(dname, protocol, host, dno): - assert protocol in (None, 'tcp', 'unix') + assert protocol in SUPPORTED_PROTOCOLS try: # Darwin funky socket. - if uname[0] == 'Darwin' and host and host.startswith('/private/tmp/'): + if protocol == 'darwin': s = _get_unix_socket(dname) # TCP socket, note the special case: `unix:0.0` is equivalent to `:0.0`. - elif (not protocol or protocol != 'unix') and host and host != 'unix': + elif (protocol is None or protocol != 'unix') and host and host != 'unix': s = _get_tcp_socket(host, dno) # Unix socket. @@ -118,13 +132,14 @@ def get_socket(dname, protocol, host, dno): return s -def new_get_auth(sock, dname, host, dno): +def new_get_auth(sock, dname, protocol, host, dno): + assert protocol in SUPPORTED_PROTOCOLS # Translate socket address into the xauth domain - if (uname[0] == 'Darwin') and host and host.startswith('/private/tmp/'): + if protocol == 'darwin': family = xauth.FamilyLocal addr = socket.gethostname() - elif host: + elif protocol == 'tcp': family = xauth.FamilyInternet # Convert the prettyprinted IP number into 4-octet string. From a953c932a865c15552a91290ef7f113ad6e21c73 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 17 Jul 2018 14:02:39 -0700 Subject: [PATCH 002/100] fix parse_event_response subcode decoding When using python3, the subcode received from the response is already an int, triggering a TypeError when attempting to decode it using ord(). This patch checks the subcode type before attempting to decode it. Fixes #119 --- Xlib/protocol/display.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 6453b49d..6964c555 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -822,8 +822,14 @@ def parse_event_response(self, etype): estruct = self.event_classes.get(etype, event.AnyEvent) if type(estruct) == dict: + subcode = self.data_recv[1] + + # Python2 compatibility + if type(subcode) == str: + subcode = ord(subcode) + # this etype refers to a set of sub-events with individual subcodes - estruct = estruct[ord(self.data_recv[1])] + estruct = estruct[subcode] e = estruct(display = self, binarydata = self.data_recv[:length]) From 3bb44923ac37b8b2ddb0602e8d4473746d5bd4df Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 12:00:02 +0200 Subject: [PATCH 003/100] Fix in comments: receiving Signed-off-by: Piotr Kasprzyk --- Xlib/protocol/display.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 6964c555..82d14a79 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -485,7 +485,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # There's no thread doing what we need to do. Find out exactly # what to do - # There must always be some thread recieving data, but it must not + # There must always be some thread receiving data, but it must not # necessarily be us if not self.recv_active: @@ -497,7 +497,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) flush_bytes = None sending = 0 - # Loop, recieving and sending data. + # Loop, receiving and sending data. while 1: # We might want to start sending data @@ -542,9 +542,9 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) try: # We're only checking for the socket to be writable # if we're the sending thread. We always check for it - # to become readable: either we are the recieving thread - # and should take care of the data, or the recieving thread - # might finish recieving after having read the data + # to become readable: either we are the receiving thread + # and should take care of the data, or the receiving thread + # might finish receiving after having read the data if sending: writeset = [self.socket] @@ -594,7 +594,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) gotreq = 0 if rs: - # We're the recieving thread, parse the data + # We're the receiving thread, parse the data if recieving: try: count = self.recv_packet_len - len(self.data_recv) From 909990e869cb104fc2415f3d50bcd974a8d48cdc Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 12:01:45 +0200 Subject: [PATCH 004/100] Fix variable name: receiving Signed-off-by: Piotr Kasprzyk --- Xlib/protocol/display.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 82d14a79..258ecc84 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -489,10 +489,10 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # necessarily be us if not self.recv_active: - recieving = 1 + receiving = 1 self.recv_active = 1 else: - recieving = 0 + receiving = 0 flush_bytes = None sending = 0 @@ -529,7 +529,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) self.send_recv_lock.release() # There's no longer anything useful we can do here. - if not (sending or recieving): + if not (sending or receiving): break # If we're flushing, figure out how many bytes we @@ -595,7 +595,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if rs: # We're the receiving thread, parse the data - if recieving: + if receiving: try: count = self.recv_packet_len - len(self.data_recv) count = max(self.recv_buffer_size, count) @@ -661,7 +661,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if sending: self.send_active = 0 - if recieving: + if receiving: self.recv_active = 0 if self.event_waiting: From 6b5df2f490cd9623a0313c7cc27e7215bdb8cbc2 Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 12:18:06 +0200 Subject: [PATCH 005/100] There is StaticGray in Xlib/X.py Signed-off-by: Piotr Kasprzyk --- doc/src/objects.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/objects.texi b/doc/src/objects.texi index 16d4adbe..f970c370 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -205,7 +205,7 @@ list items have the following attributes: The ID of this visual. @item visual_class -One of @code{X.StaticGrey}, @code{X.StaticColor}, @code{X.TrueColor}, +One of @code{X.StaticGray}, @code{X.StaticColor}, @code{X.TrueColor}, @code{X.GrayScale}, @code{X.PseudoColor}, or @code{X.DirectColor}. @item bits_per_rgb_value From 044debee6dcab2b754bb75890f1e01a435f427f4 Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 13:00:21 +0200 Subject: [PATCH 006/100] Fix many misspellings Signed-off-by: Piotr Kasprzyk --- Xlib/display.py | 4 ++-- Xlib/ext/xinerama.py | 2 +- Xlib/protocol/display.py | 24 ++++++++++++------------ Xlib/protocol/rq.py | 2 +- Xlib/rdb.py | 2 +- debian/rules | 2 +- doc/src/errors.texi | 2 +- doc/src/events.texi | 4 ++-- doc/src/objects.texi | 2 +- examples/get_selection.py | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index 88d3ac97..622e0a2a 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -517,7 +517,7 @@ def send_event(self, destination, event, event_mask = 0, propagate = 0, event = event) def ungrab_pointer(self, time, onerror = None): - """elease a grabbed pointer and any queued events. See + """Release a grabbed pointer and any queued events. See XUngrabPointer(3X11).""" request.UngrabPointer(display = self.display, onerror = onerror, @@ -661,7 +661,7 @@ def list_fonts_with_info(self, pattern, max_names): font_ascent font_descent replies_hint - See the descripton of XFontStruct in XGetFontProperty(3X11) + See the description of XFontStruct in XGetFontProperty(3X11) for details on these values. properties A list of properties. Each entry has two attributes: diff --git a/Xlib/ext/xinerama.py b/Xlib/ext/xinerama.py index 12d2f0e0..f0546707 100644 --- a/Xlib/ext/xinerama.py +++ b/Xlib/ext/xinerama.py @@ -30,7 +30,7 @@ this is untested because I don't have a server that implements it. The functions loosely follow the libXineram functions. Mostly, they -return an rq.Struct in lieue of passing in pointers that get data from +return an rq.Struct in lieu of passing in pointers that get data from the rq.Struct crammed into them. The exception is isActive, which returns the state information - because that's what libXinerama does.""" diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 258ecc84..ce0413cd 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -110,7 +110,7 @@ def __init__(self, display = None): self.request_serial = 1 self.request_queue = [] - # Send-and-recieve loop, see function send_and_recive + # Send-and-receive loop, see function send_and_receive # for a detailed explanation self.send_recv_lock = lock.allocate_lock() self.send_active = 0 @@ -127,7 +127,7 @@ def __init__(self, display = None): buffer_size = math.pow(2, math.floor(math.log(buffer_size, 2))) self.recv_buffer_size = int(buffer_size) - # Data used by the send-and-recieve loop + # Data used by the send-and-receive loop self.sent_requests = [] self.recv_packet_len = 0 self.data_send = b'' @@ -146,7 +146,7 @@ def __init__(self, display = None): # Right, now we're all set up for the connection setup # request with the server. - # Figure out which endianess the hardware uses + # Figure out which endianness the hardware uses self.big_endian = struct.unpack('BB', struct.pack('H', 0x0100))[0] if self.big_endian: @@ -204,7 +204,7 @@ def next_event(self): while not self.event_queue: - # Lock send_recv so no send_and_recieve + # Lock send_recv so no send_and_receive # can start or stop while we're checking # whether there are one active. self.send_recv_lock.acquire() @@ -400,7 +400,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) be true. Will return immediately if another thread is already doing send_and_recv. - To wait for an event to be recieved, event should be true. + To wait for an event to be received, event should be true. To wait for a response to a certain request (either an error or a response), request should be set the that request's @@ -561,7 +561,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) rs, ws, es = select.select([self.socket], writeset, [], timeout) - # Ignore errors caused by a signal recieved while blocking. + # Ignore errors caused by a signal received while blocking. # All other errors are re-raised. except select.error as err: if isinstance(err, OSError): @@ -627,7 +627,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # There are three different end of send-recv-loop conditions. # However, we don't leave the loop immediately, instead we - # try to send and recieve any data that might be left. We + # try to send and receive any data that might be left. We # do this by giving a timeout of 0 to select to poll # the socket. @@ -643,7 +643,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if request is not None and gotreq: break - # Always break if we just want to recieve as much as possible + # Always break if we just want to receive as much as possible if recv: break @@ -678,9 +678,9 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) def parse_response(self, request): """Internal method. - Parse data recieved from server. If REQUEST is not None + Parse data received from server. If REQUEST is not None true is returned if the request with that serial number - was recieved, otherwise false is returned. + was received, otherwise false is returned. If REQUEST is -1, we're parsing the server connection setup response. @@ -711,11 +711,11 @@ def parse_response(self, request): raise AssertionError(rtype) # Every response is at least 32 bytes long, so don't bother - # until we have recieved that much + # until we have received that much if len(self.data_recv) < 32: return gotreq - # Error resposne + # Error response if rtype == 0: gotreq = self.parse_error_response(request) or gotreq diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 296e44c1..f4c1399d 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1058,7 +1058,7 @@ def to_binary(self, *varargs, **keys): pack_items.append(field_args[f.name]) # Multivalue field. Handled like single valuefield, - # but the value are tuple unpacked into seperate arguments + # but the value are tuple unpacked into separate arguments # which are appended to pack_items else: if f.check_value is not None: diff --git a/Xlib/rdb.py b/Xlib/rdb.py index 21ef5622..03b06e2a 100644 --- a/Xlib/rdb.py +++ b/Xlib/rdb.py @@ -699,7 +699,7 @@ def get_display_opts(options, argv = sys.argv): # the resource object. # Example: Inserting "foo.bar*gazonk: yep" into an otherwise empty -# resource database would give the folliwing structure: +# resource database would give the following structure: # { 'foo': ( { 'bar': ( { }, # { 'gazonk': ( { }, diff --git a/debian/rules b/debian/rules index 9bc7713d..dd820f18 100644 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -# This is the debhelper compatability version to use. +# This is the debhelper compatibility version to use. export DH_COMPAT=1 build: build-stamp diff --git a/doc/src/errors.texi b/doc/src/errors.texi index 2a9a700d..a76ce316 100644 --- a/doc/src/errors.texi +++ b/doc/src/errors.texi @@ -142,7 +142,7 @@ Forget any caught error. Since the X protocol is mostly asynchronous any error we're watching for -might not have been recieved when we call @code{get_error}. To make +might not have been received when we call @code{get_error}. To make sure that the request has been processed by the server and any error generated has been received by the Xlib, we must synchronize with the server. diff --git a/doc/src/events.texi b/doc/src/events.texi index 035a5220..ba678ffd 100644 --- a/doc/src/events.texi +++ b/doc/src/events.texi @@ -22,7 +22,7 @@ typically by doing one or more X requests. @section Getting Events Events can be sent at any time, not necessarily when the client is ready -to recieve an event. Therefore they must be stored temporarily from that +to receive an event. Therefore they must be stored temporarily from that they are read from the network until the client is ready to handle them. Read but unhandled events are stored on an event queue in the Display object. There are two functions to access this queue: @@ -72,7 +72,7 @@ while 1: if not readable: handle_timeout() - # if display is readable, handle as many events as have been recieved + # if display is readable, handle as many events as have been received elif disp in readable: i = disp.pending_events() while i > 0: diff --git a/doc/src/objects.texi b/doc/src/objects.texi index f970c370..6d47137a 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -475,7 +475,7 @@ The name of the font. @itemx font_ascent @itemx font_descent @itemx replies_hint -See the descripton of XFontStruct in XGetFontProperty(3X11) for details +See the description of XFontStruct in XGetFontProperty(3X11) for details on these values. @item properties diff --git a/examples/get_selection.py b/examples/get_selection.py index 79ea739f..b249c027 100755 --- a/examples/get_selection.py +++ b/examples/get_selection.py @@ -83,7 +83,7 @@ def main(): # since we don't have an event here we have to. w.convert_selection(sel_atom, target_atom, data_atom, X.CurrentTime) - # Wait for the notificiaton that we got the selection + # Wait for the notification that we got the selection while True: e = d.next_event() if e.type == X.SelectionNotify: From afc5bb3c5aba0742275a27e57aaa962fec128873 Mon Sep 17 00:00:00 2001 From: hbregalad Date: Sat, 11 Aug 2018 09:02:20 -0400 Subject: [PATCH 007/100] Update xfixes.py xfixes_hide_cursor() called twice, changed second call to xfixes_show_cursor() --- examples/xfixes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xfixes.py b/examples/xfixes.py index a7fc06ba..53c37146 100755 --- a/examples/xfixes.py +++ b/examples/xfixes.py @@ -58,7 +58,7 @@ def main(argv): time.sleep(5) print('Showing cursor ...', file=sys.stderr) - screen.root.xfixes_hide_cursor() + screen.root.xfixes_show_cursor() display.sync() From 859f50d4933dc0c96742dc5db4994be7a842b216 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Fri, 5 Oct 2018 08:42:06 -0700 Subject: [PATCH 008/100] ext: composite: set default client version --- Xlib/ext/composite.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index be1fac76..464ddd9c 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -65,6 +65,8 @@ def query_version(self): return QueryVersion( display = self.display, opcode = self.display.get_extension_major(extname), + major_version=0, + minor_version=4 ) From 0aa0acde181667cc7e3b40d8d0ebc9202ed686f7 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 9 Oct 2018 09:37:12 -0700 Subject: [PATCH 009/100] ext: composite: add error handlers --- Xlib/ext/composite.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index be1fac76..1533d36b 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -78,11 +78,12 @@ class RedirectWindow(rq.Request): rq.Pad(3), ) -def redirect_window(self, update): +def redirect_window(self, update, onerror = None): """Redirect the hierarchy starting at this window to off-screen storage. """ RedirectWindow(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -99,11 +100,12 @@ class RedirectSubwindows(rq.Request): rq.Pad(3), ) -def redirect_subwindows(self, update): +def redirect_subwindows(self, update, onerror = None): """Redirect the hierarchies starting at all current and future children to this window to off-screen storage. """ RedirectSubwindows(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -120,10 +122,11 @@ class UnredirectWindow(rq.Request): rq.Pad(3), ) -def unredirect_window(self, update): +def unredirect_window(self, update, onerror = None): """Stop redirecting this window hierarchy. """ UnredirectWindow(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -140,10 +143,11 @@ class UnredirectSubindows(rq.Request): rq.Pad(3), ) -def unredirect_subwindows(self, update): +def unredirect_subwindows(self, update, onerror = None): """Stop redirecting the hierarchies of children to this window. """ RedirectWindow(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -159,7 +163,7 @@ class CreateRegionFromBorderClip(rq.Request): rq.Window('window'), ) -def create_region_from_border_clip(self): +def create_region_from_border_clip(self, onerror = None): """Create a region of the border clip of the window, i.e. the area that is not clipped by the parent and any sibling windows. """ @@ -167,6 +171,7 @@ def create_region_from_border_clip(self): rid = self.display.allocate_resource_id() CreateRegionFromBorderClip( display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), region = rid, window = self, @@ -185,7 +190,7 @@ class NameWindowPixmap(rq.Request): rq.Pixmap('pixmap'), ) -def name_window_pixmap(self): +def name_window_pixmap(self, onerror = None): """Create a new pixmap that refers to the off-screen storage of the window, including its border. @@ -198,6 +203,7 @@ def name_window_pixmap(self): pid = self.display.allocate_resource_id() NameWindowPixmap(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, pixmap = pid, From cfaf9ede7455aa75a152ac74c24ff1738b318c89 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Fri, 5 Oct 2018 08:42:35 -0700 Subject: [PATCH 010/100] ext: create damage client extension --- Xlib/ext/__init__.py | 1 + Xlib/ext/damage.py | 186 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 Xlib/ext/damage.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 4ba62f8e..15193d7e 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -36,6 +36,7 @@ ('XFIXES', 'xfixes'), ('SECURITY', 'security'), ('XInputExtension', 'xinput'), + ('DAMAGE', 'damage'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py new file mode 100644 index 00000000..eeb7340b --- /dev/null +++ b/Xlib/ext/damage.py @@ -0,0 +1,186 @@ +# Xlib.ext.damage -- DAMAGE extension module +# +# Copyright (C) 2018 Joseph Kogut +# +# 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 + + +from Xlib import X +from Xlib.protocol import rq, structs +from Xlib.xobject import resource +from Xlib.error import XError + +extname = 'DAMAGE' + +# Event codes # +DamageNotifyCode = 0 + +# Error codes # +BadDamageCode = 0 + +class BadDamageError(XError): + pass + +# DamageReportLevel options +DamageReportRawRectangles = 0 +DamageReportDeltaRectangles = 1 +DamageReportBoundingBox = 2 +DamageReportNonEmpty = 3 + +DamageReportLevel = ( + DamageReportRawRectangles, + DamageReportDeltaRectangles, + DamageReportBoundingBox, + DamageReportNonEmpty, +) + +DAMAGE = rq.Card32 + +# Methods + +class QueryVersion(rq.ReplyRequest): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + rq.Card32('major_version'), + rq.Card32('minor_version'), + ) + + _reply = rq.Struct(rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('major_version'), + rq.Card32('minor_version'), + rq.Pad(16), + ) + +def query_version(self): + return QueryVersion(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + +class DamageCreate(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + DAMAGE('damage'), + rq.Drawable('drawable'), + rq.Set('level', 1, DamageReportLevel), + rq.Pad(3), + ) + +def damage_create(self, level): + did = self.display.allocate_resource_id() + DamageCreate(display=self.display, + opcode=self.display.get_extension_major(extname), + damage=did, + drawable=self.id, + level=level, + ) + print('damage create') + return did + +class DamageDestroy(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + DAMAGE('damage') + ) + +def damage_destroy(self, damage): + DamageDestroy(display=self.display, + opcode=self.display.get_extension_major(extname), + damage=damage, + ) + + self.display.free_resource_id(damage) + print('damage destroy') + +class DamageSubtract(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + DAMAGE('damage'), + rq.Card32('repair'), + rq.Card32('parts') + ) + +def damage_subtract(self, damage, repair=X.NONE, parts=X.NONE): + DamageSubtract(display=self.display, + opcode=self.display.get_extension_major(extname), + damage=damage, + repair=repair, + parts=parts) + print('damage subtract') + +class DamageAdd(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + rq.Card32('repair'), + rq.Card32('parts'), + ) + +def damage_add(self, repair, parts): + DamageAdd(display=self.display, + opcode=self.display.get_extension_major(extname), + repair=repair, + parts=parts) + print('damage add') + +# Events # + +class DamageNotify(rq.Event): + _code = None + _fields = rq.Struct( + rq.Card8('type'), + rq.Card8('level'), + rq.Card16('sequence_number'), + rq.Drawable('drawable'), + DAMAGE('damage'), + rq.Card32('timestamp'), + rq.Object('area', structs.Rectangle), + rq.Object('drawable_geometry', structs.Rectangle) + ) + +def init(disp, info): + disp.extension_add_method('display', + 'damage_query_version', + query_version) + + disp.extension_add_method('drawable', + 'damage_create', + damage_create) + + disp.extension_add_method('display', + 'damage_destroy', + damage_destroy) + + disp.extension_add_method('display', + 'damage_subtract', + damage_subtract) + + disp.extension_add_method('drawable', + 'damage_add', + damage_add) + + disp.extension_add_event(info.first_event + DamageNotifyCode, DamageNotify) + + disp.add_extension_error(code=BadDamageCode, err=BadDamageError) From a7553472c10839eaa50fa9505bfc447789d16de1 Mon Sep 17 00:00:00 2001 From: gpatel-fr <44170243+gpatel-fr@users.noreply.github.com> Date: Sat, 1 Dec 2018 15:47:05 +0100 Subject: [PATCH 011/100] fix python3 crash with sample at http://rosettacode.org/wiki/Window_creation/X11#Xlib_2 --- Xlib/protocol/rq.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index f4c1399d..24042176 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1221,7 +1221,7 @@ def pack_value(self, value): for v in value: # Let values be simple strings, meaning a delta of 0 - if type(v) is bytes: + if type(v) in (str, bytes): v = (0, v) # A tuple, it should be (delta, string) @@ -1230,19 +1230,19 @@ def pack_value(self, value): if isinstance(v, (tuple, dict, DictWrapper)): if isinstance(v, tuple): - delta, str = v + delta, m_str = v else: delta = v['delta'] - str = v['string'] + m_str = v['string'] - while delta or str: + while delta or m_str: args['delta'] = delta - args['string'] = str[:254] + args['string'] = m_str[:254] data = data + self.string_textitem.to_binary(*(), **args) delta = 0 - str = str[254:] + m_str = m_str[254:] # Else an integer, i.e. a font change else: From 919cdc1960266f0ed87967601aadf83cd34910b0 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 27 Jan 2019 14:33:49 +0100 Subject: [PATCH 012/100] update news --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d4db6c..9fae403f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ NEWS for Python X Library +Version 0.24 +============ + +Bug Fixes +--------- + +- fix protocol handling: correctly support explicit Unix + connections and fix support fox macOS +- improve Python 3 support: fix events sub-code handling + and possible crashes when unpacking text data +- add support for error handlers to the Composite extension + +Misc +---- + +- fix `xfixes` example +- fix a bunch of typos in the code / documentation + +--- Version 0.23 ============ From a8df10702393fd055432f00aa433def71597f655 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 27 Jan 2019 17:06:10 +0100 Subject: [PATCH 013/100] release 0.24 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 042f1df0..c290d9ad 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 23) +__version__ = (0, 24) __version_extra__ = '' From 85ecd6bb759b1cabcb6e5132b7fb62f0df80daef Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 19:21:43 +0100 Subject: [PATCH 014/100] NV-CONTROL: query/set integer plus query string --- Xlib/ext/__init__.py | 1 + Xlib/ext/nvcontrol.py | 5188 +++++++++++++++++++++++++++++++++++++++++ examples/nvcontrol.py | 91 + 3 files changed, 5280 insertions(+) create mode 100644 Xlib/ext/nvcontrol.py create mode 100755 examples/nvcontrol.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 4ba62f8e..e9fb0ee0 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -36,6 +36,7 @@ ('XFIXES', 'xfixes'), ('SECURITY', 'security'), ('XInputExtension', 'xinput'), + ('NV-CONTROL', 'nvcontrol'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py new file mode 100644 index 00000000..9f8d45cc --- /dev/null +++ b/Xlib/ext/nvcontrol.py @@ -0,0 +1,5188 @@ +# Xlib.ext.nvcontrol -- NV-CONTROL extension module +# +# Copyright (C) 2019 Roberto Leinardi +# +# 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_int_attribute(self, target, displays, attr): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlQueryAttributeRequest(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, displays, attr, value): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlSetAttributeAndGetStatusRequest(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') + + +def set_cooler_manual_control_enabled(self, target, enabled): + return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + + +def query_string_attribute(self, target, displays, attr): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlQueryStringAttributeRequest(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 get_name(self, target): + """the GPU product name on which the specified X screen is running""" + return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) + + +def get_driver_version(self, target): + """the NVIDIA (kernel level) driver version for the specified screen or GPU""" + return query_string_attribute(self, target, [], NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) + + +def get_vbios_version(self, target): + """the version of the VBIOS for the specified screen or GPU""" + return query_string_attribute(self, target, [], NV_CTRL_STRING_VBIOS_VERSION) + + +def get_gpu_uuid(self, target): + return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UUID) + + +def get_gpu_utilization(self, target): + return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + + +def get_performance_modes(self, target): + return query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + + +def get_vram(self, target): + return query_int_attribute(self, target, [], 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, [], NV_CTRL_IRQ) + + +def supports_framelock(self, target): + """returns 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, [], NV_CTRL_FRAMELOCK) == 1 + + +def gvo_supported(self, screen): + """returns 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, [], 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, [], NV_CTRL_GPU_CORE_THRESHOLD) + + +def get_default_core_threshold(self, target): + """return the default core threshold temperature.""" + return query_int_attribute(self, target, [], 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, [], 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, [], NV_CTRL_AMBIENT_TEMPERATURE) + + +def get_cuda_cores(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_CORES) + + +def get_memory_bus_width(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_MEMORY_BUS_WIDTH) + + +def get_total_dedicated_gpu_memory(self, target): + return query_int_attribute(self, target, [], NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY) + + +def get_used_dedicated_gpu_memory(self, target): + return query_int_attribute(self, target, [], NV_CTRL_USED_DEDICATED_GPU_MEMORY) + + +def get_pcie_current_link_width(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) + + +def get_pcie_max_link_width(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) + + +def get_pcie_generation(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_GENERATION) + + +def get_video_encoder_utilization(self, target): + return query_int_attribute(self, target, [], NV_CTRL_VIDEO_ENCODER_UTILIZATION) + + +def get_video_decoder_utilization(self, target): + return query_int_attribute(self, target, [], NV_CTRL_VIDEO_DECODER_UTILIZATION) + + +def get_current_performance_level(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL) + + +def get_gpu_nvclock_offset(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) + + +def get_mem_transfer_rate_offset(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) + + +def get_cooler_manual_control_enabled(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 + + +def get_fan_duty(self, target): + return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) + + +def get_fan_rpm(self, target): + return query_int_attribute(self, target, [], 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 (e.g., that can be used in a MetaMode at once). + 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, [], NV_CTRL_MAX_DISPLAYS) + + +# def get_connected_displays(self, target): +# """Return an array with connected display numbers""" +# return query_int_attribute(self, target, [], NV_CTRL_CONNECTED_DISPLAYS) +# +# +# def get_enabled_displays(self, target): +# """returns an array of displays that are enabled on the specified X +# screen or GPU.""" +# return query_int_attribute(self, target, [], NV_CTRL_ENABLED_DISPLAYS) + +# def get_current_clocks(self, target): +# """return the current (GPU, memory) clocks of the graphics device +# driving the X screen.""" +# return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_CLOCK_FREQS) + +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_int_attribute', query_int_attribute) + disp.extension_add_method('display', 'nvcontrol_query_string_attribute', query_string_attribute) + 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_pcie_current_link_width', get_pcie_current_link_width) + disp.extension_add_method('display', 'nvcontrol_get_pcie_max_link_width', get_pcie_max_link_width) + disp.extension_add_method('display', 'nvcontrol_get_pcie_generation', get_pcie_generation) + disp.extension_add_method('display', 'nvcontrol_get_video_encoder_utilization', get_video_encoder_utilization) + disp.extension_add_method('display', 'nvcontrol_get_video_decoder_utilization', get_video_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_get_mem_transfer_rate_offset', get_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_get_fan_rpm', get_fan_rpm) + 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_gpu_utilization', get_gpu_utilization) + disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes) + disp.extension_add_method('display', 'nvcontrol_set_cooler_manual_control_enabled', + set_cooler_manual_control_enabled) + + +############################################################################ +# +# 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 + +# +# NV_CTRL_ARCHITECTURE - returns the architecture on which the X server is +# running. +# + +NV_CTRL_ARCHITECTURE = 41 # R-- +NV_CTRL_ARCHITECTURE_X86 = 0 +NV_CTRL_ARCHITECTURE_X86_64 = 1 +NV_CTRL_ARCHITECTURE_IA64 = 2 +NV_CTRL_ARCHITECTURE_ARM = 3 +NV_CTRL_ARCHITECTURE_AARCH64 = 4 +NV_CTRL_ARCHITECTURE_PPC64LE = 5 + +# +# NV_CTRL_TEXTURE_CLAMPING - texture clamping mode in OpenGL. By +# default, _SPEC is used, which forces OpenGL texture clamping to +# conform with the OpenGL specification. _EDGE forces NVIDIA's +# OpenGL implementation to remap GL_CLAMP to GL_CLAMP_TO_EDGE, +# which is not strictly conformant, but some applications rely on +# the non-conformant behavior. +# + +NV_CTRL_TEXTURE_CLAMPING = 42 # RW-X +NV_CTRL_TEXTURE_CLAMPING_EDGE = 0 +NV_CTRL_TEXTURE_CLAMPING_SPEC = 1 + +# +# The NV_CTRL_CURSOR_SHADOW - not supported +# +# use an ARGB cursor instead. +# + +NV_CTRL_CURSOR_SHADOW = 43 # not supported +NV_CTRL_CURSOR_SHADOW_DISABLE = 0 # not supported +NV_CTRL_CURSOR_SHADOW_ENABLE = 1 # not supported + +NV_CTRL_CURSOR_SHADOW_ALPHA = 44 # not supported +NV_CTRL_CURSOR_SHADOW_RED = 45 # not supported +NV_CTRL_CURSOR_SHADOW_GREEN = 46 # not supported +NV_CTRL_CURSOR_SHADOW_BLUE = 47 # not supported + +NV_CTRL_CURSOR_SHADOW_X_OFFSET = 48 # not supported +NV_CTRL_CURSOR_SHADOW_Y_OFFSET = 49 # not supported + +# +# When Application Control for FSAA is enabled, then what the +# application requests is used, and NV_CTRL_FSAA_MODE is ignored. If +# this is disabled, then any application setting is overridden with +# NV_CTRL_FSAA_MODE +# + +NV_CTRL_FSAA_APPLICATION_CONTROLLED = 50 # RW-X +NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED = 1 +NV_CTRL_FSAA_APPLICATION_CONTROLLED_DISABLED = 0 + +# +# When Application Control for LogAniso is enabled, then what the +# application requests is used, and NV_CTRL_LOG_ANISO is ignored. If +# this is disabled, then any application setting is overridden with +# NV_CTRL_LOG_ANISO +# + +NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED = 51 # RW-X +NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_ENABLED = 1 +NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_DISABLED = 0 + +# +# IMAGE_SHARPENING adjusts the sharpness of the display's image +# quality by amplifying high frequency content. Valid values will +# normally be in the range [0,32). Only available on GeForceFX or +# newer. +# + +NV_CTRL_IMAGE_SHARPENING = 52 # RWDG + +# +# NV_CTRL_TV_OVERSCAN - not supported +# + +NV_CTRL_TV_OVERSCAN = 53 # not supported + +# +# NV_CTRL_TV_FLICKER_FILTER - not supported +# + +NV_CTRL_TV_FLICKER_FILTER = 54 # not supported + +# +# NV_CTRL_TV_BRIGHTNESS - not supported +# + +NV_CTRL_TV_BRIGHTNESS = 55 # not supported + +# +# NV_CTRL_TV_HUE - not supported +# + +NV_CTRL_TV_HUE = 56 # not supported + +# +# NV_CTRL_TV_CONTRAST - not suppoerted +# + +NV_CTRL_TV_CONTRAST = 57 # not supported + +# +# NV_CTRL_TV_SATURATION - not supported +# + +NV_CTRL_TV_SATURATION = 58 # not supported + +# +# NV_CTRL_TV_RESET_SETTINGS - not supported +# + +NV_CTRL_TV_RESET_SETTINGS = 59 # not supported + +# +# NV_CTRL_GPU_CORE_TEMPERATURE reports the current core temperature +# of the GPU driving the X screen. +# + +NV_CTRL_GPU_CORE_TEMPERATURE = 60 # R--G + +# +# NV_CTRL_GPU_CORE_THRESHOLD reports the current GPU core slowdown +# threshold temperature, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD and +# NV_CTRL_GPU_MAX_CORE_THRESHOLD report the default and MAX core +# slowdown threshold temperatures. +# +# NV_CTRL_GPU_CORE_THRESHOLD reflects the temperature at which the +# GPU is throttled to prevent overheating. +# + +NV_CTRL_GPU_CORE_THRESHOLD = 61 # R--G +NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD = 62 # R--G +NV_CTRL_GPU_MAX_CORE_THRESHOLD = 63 # R--G + +# +# NV_CTRL_AMBIENT_TEMPERATURE reports the current temperature in the +# immediate neighbourhood of the GPU driving the X screen. +# + +NV_CTRL_AMBIENT_TEMPERATURE = 64 # R--G + +# +# NV_CTRL_PBUFFER_SCANOUT_SUPPORTED - returns whether this X screen +# supports scanout of FP pbuffers; +# +# if this screen does not support PBUFFER_SCANOUT, then all other +# PBUFFER_SCANOUT attributes are unavailable. +# +# PBUFFER_SCANOUT is supported if and only if: +# - Twinview is configured with clone mode. The secondary screen is used to +# scanout the pbuffer. +# - The desktop is running in with 16 bits per pixel. +# +NV_CTRL_PBUFFER_SCANOUT_SUPPORTED = 65 # not supported +NV_CTRL_PBUFFER_SCANOUT_FALSE = 0 +NV_CTRL_PBUFFER_SCANOUT_TRUE = 1 + +# +# NV_CTRL_PBUFFER_SCANOUT_XID indicates the XID of the pbuffer used for +# scanout. +# +NV_CTRL_PBUFFER_SCANOUT_XID = 66 # not supported + +############################################################################ +# +# The NV_CTRL_GVO_* integer attributes are used to configure GVO +# (Graphics to Video Out). This functionality is available, for +# example, on the Quadro SDI Output card. +# +# The following is a typical usage pattern for the GVO attributes: +# +# - query NV_CTRL_GVO_SUPPORTED to determine if the X screen supports GV0. +# +# - specify NV_CTRL_GVO_SYNC_MODE (one of FREE_RUNNING, GENLOCK, or +# FRAMELOCK); if you specify GENLOCK or FRAMELOCK, you should also +# specify NV_CTRL_GVO_SYNC_SOURCE. +# +# - Use NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED and +# NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED to detect what input syncs are +# present. +# +# (If no analog sync is detected but it is known that a valid +# bi-level or tri-level sync is connected set +# NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE appropriately and +# retest with NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED). +# +# - if syncing to input sync, query the +# NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT attribute; note that Input video +# format can only be queried after SYNC_SOURCE is specified. +# +# - specify the NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT +# +# - specify the NV_CTRL_GVO_DATA_FORMAT +# +# - specify any custom Color Space Conversion (CSC) matrix, offset, +# and scale with XNVCTRLSetGvoColorConversion(). +# +# - if using the GLX_NV_video_out extension to display one or more +# pbuffers, call glXGetVideoDeviceNV() to lock the GVO output for use +# by the GLX client; then bind the pbuffer(s) to the GVO output with +# glXBindVideoImageNV() and send pbuffers to the GVO output with +# glXSendPbufferToVideoNV(); see the GLX_NV_video_out spec for more +# details. +# +# - if using the GLX_NV_present_video extension, call +# glXBindVideoDeviceNV() to bind the GVO video device to current +# OpenGL context. +# +# Note that setting most GVO attributes only causes the value to be +# cached in the X server. The values will be flushed to the hardware +# either when the next MetaMode is set that uses the GVO display +# device, or when a GLX pbuffer is bound to the GVO output (with +# glXBindVideoImageNV()). +# +# Note that GLX_NV_video_out/GLX_NV_present_video and X screen use +# are mutually exclusive. If a MetaMode is currently using the GVO +# device, then glXGetVideoDeviceNV and glXBindVideoImageNV() will +# fail. Similarly, if a GLX client has locked the GVO output (via +# glXGetVideoDeviceNV or glXBindVideoImageNV), then setting a +# MetaMode that uses the GVO device will fail. The +# NV_CTRL_GVO_GLX_LOCKED event will be sent when a GLX client locks +# the GVO output. +# +# + + +# +# NV_CTRL_GVO_SUPPORTED - returns whether this X screen supports GVO; +# if this screen does not support GVO output, then all other GVO +# attributes are unavailable. +# + +NV_CTRL_GVO_SUPPORTED = 67 # R-- +NV_CTRL_GVO_SUPPORTED_FALSE = 0 +NV_CTRL_GVO_SUPPORTED_TRUE = 1 + +# +# NV_CTRL_GVO_SYNC_MODE - selects the GVO sync mode; possible values +# are: +# +# FREE_RUNNING - GVO does not sync to any external signal +# +# GENLOCK - the GVO output is genlocked to an incoming sync signal; +# genlocking locks at hsync. This requires that the output video +# format exactly match the incoming sync video format. +# +# FRAMELOCK - the GVO output is frame locked to an incoming sync +# signal; frame locking locks at vsync. This requires that the output +# video format have the same refresh rate as the incoming sync video +# format. +# + +NV_CTRL_GVO_SYNC_MODE = 68 # RW- +NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING = 0 +NV_CTRL_GVO_SYNC_MODE_GENLOCK = 1 +NV_CTRL_GVO_SYNC_MODE_FRAMELOCK = 2 + +# +# NV_CTRL_GVO_SYNC_SOURCE - if NV_CTRL_GVO_SYNC_MODE is set to either +# GENLOCK or FRAMELOCK, this controls which sync source is used as +# the incoming sync signal (either Composite or SDI). If +# NV_CTRL_GVO_SYNC_MODE is FREE_RUNNING, this attribute has no +# effect. +# + +NV_CTRL_GVO_SYNC_SOURCE = 69 # RW- +NV_CTRL_GVO_SYNC_SOURCE_COMPOSITE = 0 +NV_CTRL_GVO_SYNC_SOURCE_SDI = 1 + +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT - specifies the desired output video +# format for GVO devices or the desired input video format for GVI devices. +# +# Note that for GVO, the valid video formats may vary depending on +# the NV_CTRL_GVO_SYNC_MODE and the incoming sync video format. See +# the definition of NV_CTRL_GVO_SYNC_MODE. +# +# Note that when querying the ValidValues for this data type, the +# values are reported as bits within a bitmask +# (ATTRIBUTE_TYPE_INT_BITS); unfortunately, there are more valid +# value bits than will fit in a single 32-bit value. To solve this, +# query the ValidValues for NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT to +# check which of the first 31 VIDEO_FORMATS are valid, query the +# ValidValues for NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 to check which +# of the 32-63 VIDEO_FORMATS are valid, and query the ValidValues of +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 to check which of the 64-95 +# VIDEO_FORMATS are valid. +# +# Note: Setting this attribute on a GVI device may also result in the +# following NV-CONTROL attributes being reset on that device (to +# ensure the configuration remains valid): +# NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT +# NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING +# + +NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT = 70 # RW--I + +NV_CTRL_GVIO_VIDEO_FORMAT_NONE = 0 +NV_CTRL_GVIO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC = 1 +NV_CTRL_GVIO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL = 2 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_59_94_SMPTE296 = 3 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296 = 4 +NV_CTRL_GVIO_VIDEO_FORMAT_1035I_59_94_SMPTE260 = 5 +NV_CTRL_GVIO_VIDEO_FORMAT_1035I_60_00_SMPTE260 = 6 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_SMPTE295 = 7 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_SMPTE274 = 8 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_59_94_SMPTE274 = 9 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_60_00_SMPTE274 = 10 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_23_976_SMPTE274 = 11 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_24_00_SMPTE274 = 12 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_25_00_SMPTE274 = 13 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_29_97_SMPTE274 = 14 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_30_00_SMPTE274 = 15 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_50_00_SMPTE296 = 16 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_48_00_SMPTE274 = 17 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_47_96_SMPTE274 = 18 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_30_00_SMPTE296 = 19 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_29_97_SMPTE296 = 20 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_25_00_SMPTE296 = 21 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_24_00_SMPTE296 = 22 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_23_98_SMPTE296 = 23 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 = 24 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 = 25 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 = 26 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 = 27 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 = 28 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_30_00_SMPTE372 = 29 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_29_97_SMPTE372 = 30 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_60_00_SMPTE372 = 31 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_59_94_SMPTE372 = 32 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_25_00_SMPTE372 = 33 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_50_00_SMPTE372 = 34 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_24_00_SMPTE372 = 35 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_23_98_SMPTE372 = 36 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_48_00_SMPTE372 = 37 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_SMPTE372 = 38 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_50_00_3G_LEVEL_A_SMPTE274 = 39 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_59_94_3G_LEVEL_A_SMPTE274 = 40 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_60_00_3G_LEVEL_A_SMPTE274 = 41 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_60_00_3G_LEVEL_B_SMPTE274 = 42 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_60_00_3G_LEVEL_B_SMPTE274 = 43 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_60_00_3G_LEVEL_B_SMPTE372 = 44 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_50_00_3G_LEVEL_B_SMPTE274 = 45 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_3G_LEVEL_B_SMPTE274 = 46 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_50_00_3G_LEVEL_B_SMPTE372 = 47 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_30_00_3G_LEVEL_B_SMPTE274 = 48 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_30_00_3G_LEVEL_B_SMPTE372 = 49 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_25_00_3G_LEVEL_B_SMPTE274 = 50 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_25_00_3G_LEVEL_B_SMPTE372 = 51 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_24_00_3G_LEVEL_B_SMPTE274 = 52 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_24_00_3G_LEVEL_B_SMPTE372 = 53 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_48_00_3G_LEVEL_B_SMPTE274 = 54 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_48_00_3G_LEVEL_B_SMPTE372 = 55 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_59_94_3G_LEVEL_B_SMPTE274 = 56 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_59_94_3G_LEVEL_B_SMPTE274 = 57 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_59_94_3G_LEVEL_B_SMPTE372 = 58 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_29_97_3G_LEVEL_B_SMPTE274 = 59 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_29_97_3G_LEVEL_B_SMPTE372 = 60 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_23_98_3G_LEVEL_B_SMPTE274 = 61 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_23_98_3G_LEVEL_B_SMPTE372 = 62 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_47_96_3G_LEVEL_B_SMPTE274 = 63 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_3G_LEVEL_B_SMPTE372 = 64 + +# +# The following have been renamed; NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT and the +# corresponding NV_CTRL_GVIO_* formats should be used instead. +# +NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT = 70 # renamed + +NV_CTRL_GVO_VIDEO_FORMAT_NONE = 0 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC = 1 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL = 2 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_59_94_SMPTE296 = 3 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_60_00_SMPTE296 = 4 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1035I_59_94_SMPTE260 = 5 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1035I_60_00_SMPTE260 = 6 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE295 = 7 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE274 = 8 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_59_94_SMPTE274 = 9 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_60_00_SMPTE274 = 10 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_23_976_SMPTE274 = 11 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_24_00_SMPTE274 = 12 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_25_00_SMPTE274 = 13 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_29_97_SMPTE274 = 14 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_30_00_SMPTE274 = 15 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_50_00_SMPTE296 = 16 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_48_00_SMPTE274 = 17 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_47_96_SMPTE274 = 18 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_30_00_SMPTE296 = 19 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_29_97_SMPTE296 = 20 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_25_00_SMPTE296 = 21 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_24_00_SMPTE296 = 22 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_23_98_SMPTE296 = 23 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 = 24 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 = 25 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 = 26 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 = 27 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 = 28 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_30_00_SMPTE372 = 29 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_29_97_SMPTE372 = 30 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_60_00_SMPTE372 = 31 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_59_94_SMPTE372 = 32 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_25_00_SMPTE372 = 33 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_50_00_SMPTE372 = 34 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_24_00_SMPTE372 = 35 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_23_98_SMPTE372 = 36 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_48_00_SMPTE372 = 37 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_47_96_SMPTE372 = 38 # renamed + +# +# NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT - indicates the input video format +# detected for GVO or GVI devices; the possible values are the +# NV_CTRL_GVIO_VIDEO_FORMAT constants. +# +# For GVI devices, the jack number should be specified in the lower +# 16 bits of the "display_mask" parameter, while the channel number should be +# specified in the upper 16 bits. +# + +NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT = 71 # R--I + +# +# NV_CTRL_GVO_INPUT_VIDEO_FORMAT - renamed +# +# NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT should be used instead. +# + +NV_CTRL_GVO_INPUT_VIDEO_FORMAT = 71 # renamed + +# +# NV_CTRL_GVO_DATA_FORMAT - This controls how the data in the source +# (either the X screen or the GLX pbuffer) is interpretted and +# displayed. +# +# Note: some of the below DATA_FORMATS have been renamed. For +# example, R8G8B8_TO_RGB444 has been renamed to X8X8X8_444_PASSTHRU. +# This is to more accurately reflect DATA_FORMATS where the +# per-channel data could be either RGB or YCrCb -- the point is that +# the driver and GVO hardware do not perform any implicit color space +# conversion on the data; it is passed through to the SDI out. +# + +NV_CTRL_GVO_DATA_FORMAT = 72 # RW- +NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB444 = 0 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4444 = 1 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4444 = 2 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB422 = 3 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4224 = 4 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4224 = 5 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_RGB444 = 6 # renamed +NV_CTRL_GVO_DATA_FORMAT_X8X8X8_444_PASSTHRU = 6 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_RGBA4444 = 7 # renamed +NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4444_PASSTHRU = 7 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_RGBZ4444 = 8 # renamed +NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4444_PASSTHRU = 8 +NV_CTRL_GVO_DATA_FORMAT_Y10CR10CB10_TO_YCRCB444 = 9 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X10X10_444_PASSTHRU = 9 +NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8_TO_YCRCB444 = 10 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X8X8_444_PASSTHRU = 10 +NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8A10_TO_YCRCBA4444 = 11 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4444_PASSTHRU = 11 +NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8Z10_TO_YCRCBZ4444 = 12 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4444_PASSTHRU = 12 +NV_CTRL_GVO_DATA_FORMAT_DUAL_R8G8B8_TO_DUAL_YCRCB422 = 13 +NV_CTRL_GVO_DATA_FORMAT_DUAL_Y8CR8CB8_TO_DUAL_YCRCB422 = 14 # renamed +NV_CTRL_GVO_DATA_FORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU = 14 +NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB422 = 15 +NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB444 = 16 +NV_CTRL_GVO_DATA_FORMAT_Y12CR12CB12_TO_YCRCB444 = 17 # renamed +NV_CTRL_GVO_DATA_FORMAT_X12X12X12_444_PASSTHRU = 17 +NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB444 = 18 +NV_CTRL_GVO_DATA_FORMAT_X8X8X8_422_PASSTHRU = 19 +NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4224_PASSTHRU = 20 +NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4224_PASSTHRU = 21 +NV_CTRL_GVO_DATA_FORMAT_X10X10X10_422_PASSTHRU = 22 +NV_CTRL_GVO_DATA_FORMAT_X10X8X8_422_PASSTHRU = 23 +NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4224_PASSTHRU = 24 +NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4224_PASSTHRU = 25 +NV_CTRL_GVO_DATA_FORMAT_X12X12X12_422_PASSTHRU = 26 +NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB422 = 27 + +# +# NV_CTRL_GVO_DISPLAY_X_SCREEN - not supported +# + +NV_CTRL_GVO_DISPLAY_X_SCREEN = 73 # not supported +NV_CTRL_GVO_DISPLAY_X_SCREEN_ENABLE = 1 # not supported +NV_CTRL_GVO_DISPLAY_X_SCREEN_DISABLE = 0 # not supported + +# +# NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED - indicates whether +# Composite Sync input is detected. +# + +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED = 74 # R-- +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_FALSE = 0 +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_TRUE = 1 + +# +# NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE - get/set the +# Composite Sync input detect mode. +# + +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE = 75 # RW- +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_AUTO = 0 +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_BI_LEVEL = 1 +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_TRI_LEVEL = 2 + +# +# NV_CTRL_GVO_SYNC_INPUT_DETECTED - indicates whether SDI Sync input +# is detected, and what type. +# + +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED = 76 # R-- +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_NONE = 0 +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_HD = 1 +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_SD = 2 + +# +# NV_CTRL_GVO_VIDEO_OUTPUTS - indicates which GVO video output +# connectors are currently outputing data. +# + +NV_CTRL_GVO_VIDEO_OUTPUTS = 77 # R-- +NV_CTRL_GVO_VIDEO_OUTPUTS_NONE = 0 +NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO1 = 1 +NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO2 = 2 +NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO_BOTH = 3 + +# +# NV_CTRL_GVO_FIRMWARE_VERSION - deprecated +# +# NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead. +# + +NV_CTRL_GVO_FIRMWARE_VERSION = 78 # deprecated + +# +# NV_CTRL_GVO_SYNC_DELAY_PIXELS - controls the delay between the +# input sync and the output sync in numbers of pixels from hsync; +# this is a 12 bit value. +# +# If the NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW bit is set, +# then setting this value will set an advance instead of a delay. +# + +NV_CTRL_GVO_SYNC_DELAY_PIXELS = 79 # RW- + +# +# NV_CTRL_GVO_SYNC_DELAY_LINES - controls the delay between the input +# sync and the output sync in numbers of lines from vsync; this is a +# 12 bit value. +# +# If the NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW bit is set, +# then setting this value will set an advance instead of a delay. +# + +NV_CTRL_GVO_SYNC_DELAY_LINES = 80 # RW- + +# +# NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE - must be set for a period +# of about 2 seconds for the new InputVideoFormat to be properly +# locked to. In nvidia-settings, we do a reacquire whenever genlock +# or frame lock mode is entered into, when the user clicks the +# "detect" button. This value can be written, but always reads back +# _FALSE. +# + +NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE = 81 # -W- +NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_FALSE = 0 +NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_TRUE = 1 + +# +# NV_CTRL_GVO_GLX_LOCKED - deprecated +# +# NV_CTRL_GVO_LOCK_OWNER should be used instead. +# + +NV_CTRL_GVO_GLX_LOCKED = 82 # deprecated +NV_CTRL_GVO_GLX_LOCKED_FALSE = 0 # deprecated +NV_CTRL_GVO_GLX_LOCKED_TRUE = 1 # deprecated + +# +# NV_CTRL_GVIO_VIDEO_FORMAT_{WIDTH,HEIGHT,REFRESH_RATE} - query the +# width, height, and refresh rate for the specified +# NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be queried with +# existing interfaces, XNVCTRLQueryAttribute() should be used, and +# the video format specified in the display_mask field; eg: +# +# XNVCTRLQueryAttribute (dpy, +# screen, +# NV_CTRL_GVIO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC, +# NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH, +# &value); +# +# Note that Refresh Rate is in milliHertz values +# + +NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH = 83 # R--I +NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT = 84 # R--I +NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE = 85 # R--I + +# The following have been renamed; use the NV_CTRL_GVIO_* versions, instead +NV_CTRL_GVO_VIDEO_FORMAT_WIDTH = 83 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_HEIGHT = 84 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_REFRESH_RATE = 85 # renamed + +# +# NV_CTRL_GVO_X_SCREEN_PAN_[XY] - not supported +# + +NV_CTRL_GVO_X_SCREEN_PAN_X = 86 # not supported +NV_CTRL_GVO_X_SCREEN_PAN_Y = 87 # not supported + +# +# NV_CTRL_GPU_OVERCLOCKING_STATE - not supported +# + +NV_CTRL_GPU_OVERCLOCKING_STATE = 88 # not supported +NV_CTRL_GPU_OVERCLOCKING_STATE_NONE = 0 # not supported +NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL = 1 # not supported + +# +# NV_CTRL_GPU_{2,3}D_CLOCK_FREQS - not supported +# + +NV_CTRL_GPU_2D_CLOCK_FREQS = 89 # not supported +NV_CTRL_GPU_3D_CLOCK_FREQS = 90 # not supported + +# +# NV_CTRL_GPU_DEFAULT_{2,3}D_CLOCK_FREQS - not supported +# + +NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS = 91 # not supported +NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS = 92 # not supported + +# +# NV_CTRL_GPU_CURRENT_CLOCK_FREQS - query the current GPU and memory +# clocks of the graphics device driving the X screen. +# +# NV_CTRL_GPU_CURRENT_CLOCK_FREQS is a "packed" integer attribute; +# the GPU clock is stored in the upper 16 bits of the integer, and +# the memory clock is stored in the lower 16 bits of the integer. +# All clock values are in MHz. All clock values are in MHz. +# + +NV_CTRL_GPU_CURRENT_CLOCK_FREQS = 93 # R--G + +# +# NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS - not supported +# + +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS = 94 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_INVALID = 0 # not supported + +# +# NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION - not supported +# + +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION = 95 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_START = 0 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_CANCEL = 1 # not supported + +# +# NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE - not supported +# + +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE = 96 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_IDLE = 0 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY = 1 # not supported + +# +# NV_CTRL_FLATPANEL_CHIP_LOCATION - for the specified display device, +# report whether the flat panel is driven by the on-chip controller, +# or a separate controller chip elsewhere on the graphics board. +# This attribute is only available for flat panels. +# + +NV_CTRL_FLATPANEL_CHIP_LOCATION = 215 # R-DG +NV_CTRL_FLATPANEL_CHIP_LOCATION_INTERNAL = 0 +NV_CTRL_FLATPANEL_CHIP_LOCATION_EXTERNAL = 1 + +# +# NV_CTRL_FLATPANEL_LINK - report the number of links for a DVI connection, or +# the main link's active lane count for DisplayPort. +# This attribute is only available for flat panels. +# + +NV_CTRL_FLATPANEL_LINK = 216 # R-DG +NV_CTRL_FLATPANEL_LINK_SINGLE = 0 +NV_CTRL_FLATPANEL_LINK_DUAL = 1 +NV_CTRL_FLATPANEL_LINK_QUAD = 3 + +# +# NV_CTRL_FLATPANEL_SIGNAL - for the specified display device, report +# whether the flat panel is driven by an LVDS, TMDS, or DisplayPort signal. +# This attribute is only available for flat panels. +# + +NV_CTRL_FLATPANEL_SIGNAL = 217 # R-DG +NV_CTRL_FLATPANEL_SIGNAL_LVDS = 0 +NV_CTRL_FLATPANEL_SIGNAL_TMDS = 1 +NV_CTRL_FLATPANEL_SIGNAL_DISPLAYPORT = 2 + +# +# NV_CTRL_USE_HOUSE_SYNC - when INPUT, the server (master) frame lock +# device will propagate the incoming house sync signal as the outgoing +# frame lock sync signal. If the frame lock device cannot detect a +# frame lock sync signal, it will default to using the internal timings +# from the GPU connected to the primary connector. +# +# When set to OUTPUT, the server (master) frame lock device will +# generate a house sync signal from its internal timing and output +# this signal over the BNC connector on the frame lock device. This +# is only allowed on a Quadro Sync II device. If an incoming house +# sync signal is present on the BNC connector, this setting will +# have no effect. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_USE_HOUSE_SYNC = 218 # RW-F +NV_CTRL_USE_HOUSE_SYNC_DISABLED = 0 # aliases with FALSE +NV_CTRL_USE_HOUSE_SYNC_INPUT = 1 # aliases with TRUE +NV_CTRL_USE_HOUSE_SYNC_OUTPUT = 2 +NV_CTRL_USE_HOUSE_SYNC_FALSE = 0 +NV_CTRL_USE_HOUSE_SYNC_TRUE = 1 + +# +# NV_CTRL_EDID_AVAILABLE - report if an EDID is available for the +# specified display device. +# +# This attribute may also be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_EDID_AVAILABLE = 219 # R-DG +NV_CTRL_EDID_AVAILABLE_FALSE = 0 +NV_CTRL_EDID_AVAILABLE_TRUE = 1 + +# +# NV_CTRL_FORCE_STEREO - when TRUE, OpenGL will force stereo flipping +# even when no stereo drawables are visible (if the device is configured +# to support it, see the "Stereo" X config option). +# When false, fall back to the default behavior of only flipping when a +# stereo drawable is visible. +# + +NV_CTRL_FORCE_STEREO = 220 # RW- +NV_CTRL_FORCE_STEREO_FALSE = 0 +NV_CTRL_FORCE_STEREO_TRUE = 1 + +# +# NV_CTRL_IMAGE_SETTINGS - the image quality setting for OpenGL clients. +# +# This setting is only applied to OpenGL clients that are started +# after this setting is applied. +# + +NV_CTRL_IMAGE_SETTINGS = 221 # RW-X +NV_CTRL_IMAGE_SETTINGS_HIGH_QUALITY = 0 +NV_CTRL_IMAGE_SETTINGS_QUALITY = 1 +NV_CTRL_IMAGE_SETTINGS_PERFORMANCE = 2 +NV_CTRL_IMAGE_SETTINGS_HIGH_PERFORMANCE = 3 + +# +# NV_CTRL_XINERAMA - return whether xinerama is enabled +# + +NV_CTRL_XINERAMA = 222 # R--G +NV_CTRL_XINERAMA_OFF = 0 +NV_CTRL_XINERAMA_ON = 1 + +# +# NV_CTRL_XINERAMA_STEREO - when TRUE, OpenGL will allow stereo flipping +# on multiple X screens configured with Xinerama. +# When FALSE, flipping is allowed only on one X screen at a time. +# + +NV_CTRL_XINERAMA_STEREO = 223 # RW- +NV_CTRL_XINERAMA_STEREO_FALSE = 0 +NV_CTRL_XINERAMA_STEREO_TRUE = 1 + +# +# NV_CTRL_BUS_RATE - if the bus type of the specified device is AGP, then +# NV_CTRL_BUS_RATE returns the configured AGP transfer rate. If the bus type +# is PCI Express, then this attribute returns the maximum link width. +# When this attribute is queried on an X screen target, the bus rate of the +# GPU driving the X screen is returned. +# + +NV_CTRL_BUS_RATE = 224 # R--GI + +# +# NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH - returns the maximum +# PCIe link width, in number of lanes. +# +NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH = NV_CTRL_BUS_RATE +# +# NV_CTRL_SHOW_SLI_VISUAL_INDICATOR - when TRUE, OpenGL will draw information +# about the current SLI mode. +# + +NV_CTRL_SHOW_SLI_VISUAL_INDICATOR = 225 # RW-X +NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE = 1 + +# +# NV_CTRL_SHOW_SLI_HUD - when TRUE, OpenGL will draw information about the +# current SLI mode. +# Renamed this attribute to NV_CTRL_SHOW_SLI_VISUAL_INDICATOR +# + +NV_CTRL_SHOW_SLI_HUD = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR +NV_CTRL_SHOW_SLI_HUD_FALSE = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE +NV_CTRL_SHOW_SLI_HUD_TRUE = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE + +# +# NV_CTRL_XV_SYNC_TO_DISPLAY - deprecated +# +# NV_CTRL_XV_SYNC_TO_DISPLAY_ID should be used instead. +# + +NV_CTRL_XV_SYNC_TO_DISPLAY = 226 # deprecated + +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 - this attribute is only +# intended to be used to query the ValidValues for +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for VIDEO_FORMAT values between +# 31 and 63. See NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for details. +# + +NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 = 227 # ---GI + +# +# NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 - renamed +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 should be used instead. +# +NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 = 227 # renamed + +# +# NV_CTRL_GVO_OVERRIDE_HW_CSC - Override the SDI hardware's Color Space +# Conversion with the values controlled through +# XNVCTRLSetGvoColorConversion() and XNVCTRLGetGvoColorConversion(). If +# this attribute is FALSE, then the values specified through +# XNVCTRLSetGvoColorConversion() are ignored. +# + +NV_CTRL_GVO_OVERRIDE_HW_CSC = 228 # RW- +NV_CTRL_GVO_OVERRIDE_HW_CSC_FALSE = 0 +NV_CTRL_GVO_OVERRIDE_HW_CSC_TRUE = 1 + +# +# NV_CTRL_GVO_CAPABILITIES - this read-only attribute describes GVO +# capabilities that differ between NVIDIA SDI products. This value +# is a bitmask where each bit indicates whether that capability is +# available. +# +# APPLY_CSC_IMMEDIATELY - whether the CSC matrix, offset, and scale +# specified through XNVCTRLSetGvoColorConversion() will take affect +# immediately, or only after SDI output is disabled and enabled +# again. +# +# APPLY_CSC_TO_X_SCREEN - whether the CSC matrix, offset, and scale +# specified through XNVCTRLSetGvoColorConversion() will also apply +# to GVO output of an X screen, or only to OpenGL GVO output, as +# enabled through the GLX_NV_video_out extension. +# +# COMPOSITE_TERMINATION - whether the 75 ohm termination of the +# SDI composite input signal can be programmed through the +# NV_CTRL_GVO_COMPOSITE_TERMINATION attribute. +# +# SHARED_SYNC_BNC - whether the SDI device has a single BNC +# connector used for both (SDI & Composite) incoming signals. +# +# MULTIRATE_SYNC - whether the SDI device supports synchronization +# of input and output video modes that match in being odd or even +# modes (ie, AA.00 Hz modes can be synched to other BB.00 Hz modes and +# AA.XX Hz can match to BB.YY Hz where .XX and .YY are not .00) +# + +NV_CTRL_GVO_CAPABILITIES = 229 # R-- +NV_CTRL_GVO_CAPABILITIES_APPLY_CSC_IMMEDIATELY = 0x00000001 +NV_CTRL_GVO_CAPABILITIES_APPLY_CSC_TO_X_SCREEN = 0x00000002 +NV_CTRL_GVO_CAPABILITIES_COMPOSITE_TERMINATION = 0x00000004 +NV_CTRL_GVO_CAPABILITIES_SHARED_SYNC_BNC = 0x00000008 +NV_CTRL_GVO_CAPABILITIES_MULTIRATE_SYNC = 0x00000010 +NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW = 0x00000020 + +# +# NV_CTRL_GVO_COMPOSITE_TERMINATION - enable or disable 75 ohm +# termination of the SDI composite input signal. +# + +NV_CTRL_GVO_COMPOSITE_TERMINATION = 230 # RW- +NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE = 1 +NV_CTRL_GVO_COMPOSITE_TERMINATION_DISABLE = 0 + +# +# NV_CTRL_ASSOCIATED_DISPLAY_DEVICES - deprecated +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead. +# + +NV_CTRL_ASSOCIATED_DISPLAY_DEVICES = 231 # deprecated + +# +# NV_CTRL_FRAMELOCK_SLAVES - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_SLAVES = 232 # deprecated + +# +# NV_CTRL_FRAMELOCK_MASTERABLE - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_MASTERABLE = 233 # deprecated + +# +# NV_CTRL_PROBE_DISPLAYS - re-probes the hardware to detect what +# display devices are connected to the GPU or GPU driving the +# specified X screen. The return value is deprecated and should not be used. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_PROBE_DISPLAYS = 234 # R--G + +# +# NV_CTRL_REFRESH_RATE - Returns the refresh rate of the specified +# display device in 100# Hz (ie. to get the refresh rate in Hz, divide +# the returned value by 100.) +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_REFRESH_RATE = 235 # R-DG + +# +# NV_CTRL_GVO_FLIP_QUEUE_SIZE - The Graphics to Video Out interface +# exposed through NV-CONTROL and the GLX_NV_video_out extension uses +# an internal flip queue when pbuffers are sent to the video device +# (via glXSendPbufferToVideoNV()). The NV_CTRL_GVO_FLIP_QUEUE_SIZE +# can be used to query and assign the flip queue size. This +# attribute is applied to GLX when glXGetVideoDeviceNV() is called by +# the application. +# + +NV_CTRL_GVO_FLIP_QUEUE_SIZE = 236 # RW- + +# +# NV_CTRL_CURRENT_SCANLINE - query the current scanline for the +# specified display device. +# + +NV_CTRL_CURRENT_SCANLINE = 237 # R-DG + +# +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT - Controls where X pixmaps are initially +# created. +# +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM causes pixmaps to stay in +# system memory. These pixmaps can't be accelerated by the NVIDIA driver; this +# will cause blank windows if used with an OpenGL compositing manager. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM creates pixmaps in system memory +# initially, but allows them to migrate to video memory. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM creates pixmaps in video memory +# when enough resources are available. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_RESERVED is currently reserved for future +# use. Behavior is undefined. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_GPU_SYSMEM creates pixmaps in GPU accessible +# system memory when enough resources are available. +# + +NV_CTRL_INITIAL_PIXMAP_PLACEMENT = 238 # RW- +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM = 0 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM = 1 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM = 2 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_RESERVED = 3 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_GPU_SYSMEM = 4 + +# +# NV_CTRL_PCI_BUS - Returns the PCI bus number the specified device is using. +# + +NV_CTRL_PCI_BUS = 239 # R--GI + +# +# NV_CTRL_PCI_DEVICE - Returns the PCI device number the specified device is +# using. +# + +NV_CTRL_PCI_DEVICE = 240 # R--GI + +# +# NV_CTRL_PCI_FUNCTION - Returns the PCI function number the specified device +# is using. +# + +NV_CTRL_PCI_FUNCTION = 241 # R--GI + +# +# NV_CTRL_FRAMELOCK_FPGA_REVISION - Queries the FPGA revision of the +# Frame Lock device. +# +# This attribute must be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. +# + +NV_CTRL_FRAMELOCK_FPGA_REVISION = 242 # R--F + +# +# NV_CTRL_MAX_SCREEN_{WIDTH,HEIGHT} - the maximum allowable size, in +# pixels, of either the specified X screen (if the target_type of the +# query is an X screen), or any X screen on the specified GPU (if the +# target_type of the query is a GPU). +# + +NV_CTRL_MAX_SCREEN_WIDTH = 243 # R--G +NV_CTRL_MAX_SCREEN_HEIGHT = 244 # R--G + +# +# NV_CTRL_MAX_DISPLAYS - The maximum number of display devices that +# can be driven simultaneously on a GPU (e.g., that can be used in a +# MetaMode at once). Note that this does not indicate the maximum +# number of displays that are listed in NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU +# and NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU because more display +# devices can be connected than are actively in use. +# + +NV_CTRL_MAX_DISPLAYS = 245 # R--G + +# +# NV_CTRL_DYNAMIC_TWINVIEW - Returns whether or not the screen +# supports dynamic twinview. +# + +NV_CTRL_DYNAMIC_TWINVIEW = 246 # R-- + +# +# NV_CTRL_MULTIGPU_DISPLAY_OWNER - Returns the (NV-CONTROL) GPU ID of +# the GPU that has the display device(s) used for showing the X Screen. +# + +NV_CTRL_MULTIGPU_DISPLAY_OWNER = 247 # R-- + +# +# NV_CTRL_GPU_SCALING - not supported +# + +NV_CTRL_GPU_SCALING = 248 # not supported + +NV_CTRL_GPU_SCALING_TARGET_INVALID = 0 # not supported +NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT = 1 # not supported +NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_NATIVE = 2 # not supported + +NV_CTRL_GPU_SCALING_METHOD_INVALID = 0 # not supported +NV_CTRL_GPU_SCALING_METHOD_STRETCHED = 1 # not supported +NV_CTRL_GPU_SCALING_METHOD_CENTERED = 2 # not supported +NV_CTRL_GPU_SCALING_METHOD_ASPECT_SCALED = 3 # not supported + +# +# NV_CTRL_FRONTEND_RESOLUTION - not supported +# + +NV_CTRL_FRONTEND_RESOLUTION = 249 # not supported + +# +# NV_CTRL_BACKEND_RESOLUTION - not supported +# + +NV_CTRL_BACKEND_RESOLUTION = 250 # not supported + +# +# NV_CTRL_FLATPANEL_NATIVE_RESOLUTION - not supported +# + +NV_CTRL_FLATPANEL_NATIVE_RESOLUTION = 251 # not supported + +# +# NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION - not supported +# + +NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION = 252 # not supported + +# +# NV_CTRL_GPU_SCALING_ACTIVE - not supported +# + +NV_CTRL_GPU_SCALING_ACTIVE = 253 # not supported + +# +# NV_CTRL_DFP_SCALING_ACTIVE - not supported +# + +NV_CTRL_DFP_SCALING_ACTIVE = 254 # not supported + +# +# NV_CTRL_FSAA_APPLICATION_ENHANCED - Controls how the NV_CTRL_FSAA_MODE +# is applied when NV_CTRL_FSAA_APPLICATION_CONTROLLED is set to +# NV_CTRL_APPLICATION_CONTROLLED_DISABLED. When +# NV_CTRL_FSAA_APPLICATION_ENHANCED is _DISABLED, OpenGL applications will +# be forced to use the FSAA mode specified by NV_CTRL_FSAA_MODE. when set +# to _ENABLED, only those applications that have selected a multisample +# FBConfig will be made to use the NV_CTRL_FSAA_MODE specified. +# +# This attribute is ignored when NV_CTRL_FSAA_APPLICATION_CONTROLLED is +# set to NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED. +# + +NV_CTRL_FSAA_APPLICATION_ENHANCED = 255 # RW-X +NV_CTRL_FSAA_APPLICATION_ENHANCED_ENABLED = 1 +NV_CTRL_FSAA_APPLICATION_ENHANCED_DISABLED = 0 + +# +# NV_CTRL_FRAMELOCK_SYNC_RATE_4 - This is the refresh rate that the +# frame lock board is sending to the GPU with 4 digits of precision. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK. +# + +NV_CTRL_FRAMELOCK_SYNC_RATE_4 = 256 # R--F + +# +# NV_CTRL_GVO_LOCK_OWNER - indicates that the GVO device is available +# or in use (by GLX or an X screen). +# +# The GVO device is locked by GLX when either glXGetVideoDeviceNV +# (part of GLX_NV_video_out) or glXBindVideoDeviceNV (part of +# GLX_NV_present_video) is called. All GVO output resources are +# locked until released by the GLX_NV_video_out/GLX_NV_present_video +# client. +# +# The GVO device is locked/unlocked by an X screen, when the GVO device is +# used in a MetaMode on an X screen. +# +# When the GVO device is locked, setting of the following GVO NV-CONTROL +# attributes will not happen immediately and will instead be cached. The +# GVO resource will need to be disabled/released and re-enabled/claimed for +# the values to be flushed. These attributes are: +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT +# NV_CTRL_GVO_DATA_FORMAT +# NV_CTRL_GVO_FLIP_QUEUE_SIZE +# + +NV_CTRL_GVO_LOCK_OWNER = 257 # R-- +NV_CTRL_GVO_LOCK_OWNER_NONE = 0 +NV_CTRL_GVO_LOCK_OWNER_GLX = 1 +NV_CTRL_GVO_LOCK_OWNER_CLONE = 2 # not supported +NV_CTRL_GVO_LOCK_OWNER_X_SCREEN = 3 + +# +# NV_CTRL_HWOVERLAY - when a workstation overlay is in use, reports +# whether the hardware overlay is used, or if the overlay is emulated. +# + +NV_CTRL_HWOVERLAY = 258 # R-- +NV_CTRL_HWOVERLAY_FALSE = 0 +NV_CTRL_HWOVERLAY_TRUE = 1 + +# +# NV_CTRL_NUM_GPU_ERRORS_RECOVERED - Returns the number of GPU errors +# occured. This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_NUM_GPU_ERRORS_RECOVERED = 259 # R--- + +# +# NV_CTRL_REFRESH_RATE_3 - Returns the refresh rate of the specified +# display device in 1000# Hz (ie. to get the refresh rate in Hz, divide +# the returned value by 1000.) +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_REFRESH_RATE_3 = 260 # R-DG + +# +# NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS - not supported +# + +NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS = 261 # not supported +NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_OFF = 0 # not supported +NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_ON = 1 # not supported + +# +# NV_CTRL_GPU_POWER_SOURCE reports the type of power source +# of the GPU driving the X screen. +# + +NV_CTRL_GPU_POWER_SOURCE = 262 # R--G +NV_CTRL_GPU_POWER_SOURCE_AC = 0 +NV_CTRL_GPU_POWER_SOURCE_BATTERY = 1 + +# +# NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE - not supported +# + +NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE = 263 # not supported +NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_DESKTOP = 0 # not supported +NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_MAXPERF = 1 # not supported + +# NV_CTRL_GLYPH_CACHE - Enables RENDER Glyph Caching to VRAM + +NV_CTRL_GLYPH_CACHE = 264 # RW- +NV_CTRL_GLYPH_CACHE_DISABLED = 0 +NV_CTRL_GLYPH_CACHE_ENABLED = 1 + +# +# NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL reports the current +# Performance level of the GPU driving the X screen. Each +# Performance level has associated NVClock and Mem Clock values. +# + +NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL = 265 # R--G + +# +# NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE reports if Adaptive Clocking +# is Enabled on the GPU driving the X screen. +# + +NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE = 266 # R--G +NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE_DISABLED = 0 +NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE_ENABLED = 1 + +# +# NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED - Returns whether or not the GVO output +# video is locked to the GPU. +# + +NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED = 267 # R--- +NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED_FALSE = 0 +NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED_TRUE = 1 + +# +# NV_CTRL_GVO_SYNC_LOCK_STATUS - Returns whether or not the GVO device +# is locked to the input ref signal. If the sync mode is set to +# NV_CTRL_GVO_SYNC_MODE_GENLOCK, then this returns the genlock +# sync status, and if the sync mode is set to NV_CTRL_GVO_SYNC_MODE_FRAMELOCK, +# then this reports the frame lock status. +# + +NV_CTRL_GVO_SYNC_LOCK_STATUS = 268 # R--- +NV_CTRL_GVO_SYNC_LOCK_STATUS_UNLOCKED = 0 +NV_CTRL_GVO_SYNC_LOCK_STATUS_LOCKED = 1 + +# +# NV_CTRL_GVO_ANC_TIME_CODE_GENERATION - Allows SDI device to generate +# time codes in the ANC region of the SDI video output stream. +# + +NV_CTRL_GVO_ANC_TIME_CODE_GENERATION = 269 # RW-- +NV_CTRL_GVO_ANC_TIME_CODE_GENERATION_DISABLE = 0 +NV_CTRL_GVO_ANC_TIME_CODE_GENERATION_ENABLE = 1 + +# +# NV_CTRL_GVO_COMPOSITE - Enables/Disables SDI compositing. This attribute +# is only available when an SDI input source is detected and is in genlock +# mode. +# + +NV_CTRL_GVO_COMPOSITE = 270 # RW-- +NV_CTRL_GVO_COMPOSITE_DISABLE = 0 +NV_CTRL_GVO_COMPOSITE_ENABLE = 1 + +# +# NV_CTRL_GVO_COMPOSITE_ALPHA_KEY - When compositing is enabled, this +# enables/disables alpha blending. +# + +NV_CTRL_GVO_COMPOSITE_ALPHA_KEY = 271 # RW-- +NV_CTRL_GVO_COMPOSITE_ALPHA_KEY_DISABLE = 0 +NV_CTRL_GVO_COMPOSITE_ALPHA_KEY_ENABLE = 1 + +# +# NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE - Set the values of a luma +# channel range. This is a packed int that has the following format +# (in order of high-bits to low bits): +# +# Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) +# +# To query the current values, pass the range # throught the display_mask +# variable. +# + +NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE = 272 # RW-- + +# +# NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE - Set the values of a CR +# channel range. This is a packed int that has the following format +# (in order of high-bits to low bits): +# +# Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) +# +# To query the current values, pass the range # throught he display_mask +# variable. +# + +NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE = 273 # RW-- + +# +# NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE - Set the values of a CB +# channel range. This is a packed int that has the following format +# (in order of high-bits to low bits): +# +# Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) +# +# To query the current values, pass the range # throught he display_mask +# variable. +# + +NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE = 274 # RW-- + +# +# NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES - Returns the number of ranges +# available for each channel (Y/Luma, Cr, and Cb.) +# + +NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES = 275 # R--- + +# +# NV_CTRL_SWITCH_TO_DISPLAYS - not supported +# + +NV_CTRL_SWITCH_TO_DISPLAYS = 276 # not supported + +# +# NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT - not supported +# + +NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT = 277 # not supported + +# +# NV_CTRL_NOTEBOOK_INTERNAL_LCD - deprecated +# + +NV_CTRL_NOTEBOOK_INTERNAL_LCD = 278 # deprecated + +# +# NV_CTRL_DEPTH_30_ALLOWED - returns whether the NVIDIA X driver supports +# depth 30 on the specified X screen or GPU. +# + +NV_CTRL_DEPTH_30_ALLOWED = 279 # R--G + +# +# NV_CTRL_MODE_SET_EVENT This attribute is sent as an event +# when hotkey, ctrl-alt-+/- or randr event occurs. Note that +# This attribute cannot be set or queried and is meant to +# be received by clients that wish to be notified of when +# mode set events occur. +# + +NV_CTRL_MODE_SET_EVENT = 280 # --- + +# +# NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE - the gamma value used by +# OpenGL when NV_CTRL_OPENGL_AA_LINE_GAMMA is enabled +# + +NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE = 281 # RW-X + +# +# NV_CTRL_VCSC_HIGH_PERF_MODE - deprecated +# +# Is used to both query High Performance Mode status on the Visual Computing +# System, and also to enable or disable High Performance Mode. +# + +NV_CTRL_VCSC_HIGH_PERF_MODE = 282 # RW-V +NV_CTRL_VCSC_HIGH_PERF_MODE_DISABLE = 0 +NV_CTRL_VCSC_HIGH_PERF_MODE_ENABLE = 1 + +# +# NV_CTRL_DISPLAYPORT_LINK_RATE - returns the negotiated lane bandwidth of the +# DisplayPort main link. The numerical value of this attribute is the link +# rate in bps divided by 27000000. +# This attribute is only available for DisplayPort flat panels. +# + +NV_CTRL_DISPLAYPORT_LINK_RATE = 291 # R-DG +NV_CTRL_DISPLAYPORT_LINK_RATE_DISABLED = 0x0 +NV_CTRL_DISPLAYPORT_LINK_RATE_1_62GBPS = 0x6 # deprecated +NV_CTRL_DISPLAYPORT_LINK_RATE_2_70GBPS = 0xA # deprecated + +# +# NV_CTRL_STEREO_EYES_EXCHANGE - Controls whether or not the left and right +# eyes of a stereo image are flipped. +# + +NV_CTRL_STEREO_EYES_EXCHANGE = 292 # RW-X +NV_CTRL_STEREO_EYES_EXCHANGE_OFF = 0 +NV_CTRL_STEREO_EYES_EXCHANGE_ON = 1 + +# +# NV_CTRL_NO_SCANOUT - returns whether the special "NoScanout" mode is +# enabled on the specified X screen or GPU; for details on this mode, +# see the description of the "none" value for the "UseDisplayDevice" +# X configuration option in the NVIDIA driver README. +# + +NV_CTRL_NO_SCANOUT = 293 # R--G +NV_CTRL_NO_SCANOUT_DISABLED = 0 +NV_CTRL_NO_SCANOUT_ENABLED = 1 + +# +# NV_CTRL_GVO_CSC_CHANGED_EVENT This attribute is sent as an event +# when the color space conversion matrix has been altered by another +# client. +# + +NV_CTRL_GVO_CSC_CHANGED_EVENT = 294 # --- + +# +# NV_CTRL_FRAMELOCK_SLAVEABLE - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_SLAVEABLE = 295 # deprecated + +# +# NV_CTRL_GVO_SYNC_TO_DISPLAY This attribute controls whether or not +# the non-SDI display device will be sync'ed to the SDI display device +# (when configured in TwinView, Clone Mode or when using the SDI device +# with OpenGL). +# + +NV_CTRL_GVO_SYNC_TO_DISPLAY = 296 # --- +NV_CTRL_GVO_SYNC_TO_DISPLAY_DISABLE = 0 +NV_CTRL_GVO_SYNC_TO_DISPLAY_ENABLE = 1 + +# +# NV_CTRL_X_SERVER_UNIQUE_ID - returns a pseudo-unique identifier for this +# X server. Intended for use in cases where an NV-CONTROL client communicates +# with multiple X servers, and wants some level of confidence that two +# X Display connections correspond to the same or different X servers. +# + +NV_CTRL_X_SERVER_UNIQUE_ID = 297 # R--- + +# +# NV_CTRL_PIXMAP_CACHE - This attribute controls whether the driver attempts to +# store video memory pixmaps in a cache. The cache speeds up allocation and +# deallocation of pixmaps, but could use more memory than when the cache is +# disabled. +# + +NV_CTRL_PIXMAP_CACHE = 298 # RW-X +NV_CTRL_PIXMAP_CACHE_DISABLE = 0 +NV_CTRL_PIXMAP_CACHE_ENABLE = 1 + +# +# NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB - When the pixmap cache is enabled and +# there is not enough free space in the cache to fit a new pixmap, the driver +# will round up to the next multiple of this number of kilobytes when +# allocating more memory for the cache. +# + +NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB = 299 # RW-X + +# +# NV_CTRL_IS_GVO_DISPLAY - returns whether or not a given display is an +# SDI device. +# + +NV_CTRL_IS_GVO_DISPLAY = 300 # R-D +NV_CTRL_IS_GVO_DISPLAY_FALSE = 0 +NV_CTRL_IS_GVO_DISPLAY_TRUE = 1 + +# +# NV_CTRL_PCI_ID - Returns the PCI vendor and device ID of the specified +# device. +# +# NV_CTRL_PCI_ID is a "packed" integer attribute; the PCI vendor ID is stored +# in the upper 16 bits of the integer, and the PCI device ID is stored in the +# lower 16 bits of the integer. +# + +NV_CTRL_PCI_ID = 301 # R--GI + +# +# NV_CTRL_GVO_FULL_RANGE_COLOR - Allow full range color data [4-1019] +# without clamping to [64-940]. +# + +NV_CTRL_GVO_FULL_RANGE_COLOR = 302 # RW- +NV_CTRL_GVO_FULL_RANGE_COLOR_DISABLED = 0 +NV_CTRL_GVO_FULL_RANGE_COLOR_ENABLED = 1 + +# +# NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE - Returns whether or not +# SLI Mosaic Mode supported. +# + +NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE = 303 # R-- +NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_FALSE = 0 +NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_TRUE = 1 + +# +# NV_CTRL_GVO_ENABLE_RGB_DATA - Allows clients to specify when +# the GVO board should process colors as RGB when the output data +# format is one of the NV_CTRL_GVO_DATA_FORMAT_???_PASSTRHU modes. +# + +NV_CTRL_GVO_ENABLE_RGB_DATA = 304 # RW- +NV_CTRL_GVO_ENABLE_RGB_DATA_DISABLE = 0 +NV_CTRL_GVO_ENABLE_RGB_DATA_ENABLE = 1 + +# +# NV_CTRL_IMAGE_SHARPENING_DEFAULT - Returns default value of +# Image Sharpening. +# + +NV_CTRL_IMAGE_SHARPENING_DEFAULT = 305 # R-- + +# +# NV_CTRL_PCI_DOMAIN - Returns the PCI domain number the specified device is +# using. +# + +NV_CTRL_PCI_DOMAIN = 306 # R--GI + +# +# NV_CTRL_GVI_NUM_JACKS - Returns the number of input BNC jacks available +# on a GVI device. +# + +NV_CTRL_GVI_NUM_JACKS = 307 # R--I + +# +# NV_CTRL_GVI_MAX_LINKS_PER_STREAM - Returns the maximum supported number of +# links that can be tied to one stream. +# + +NV_CTRL_GVI_MAX_LINKS_PER_STREAM = 308 # R--I + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT - Returns the detected +# number of bits per component (BPC) of data on the given input jack+ +# channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT = 309 # R--I +NV_CTRL_GVI_BITS_PER_COMPONENT_UNKNOWN = 0 +NV_CTRL_GVI_BITS_PER_COMPONENT_8 = 1 +NV_CTRL_GVI_BITS_PER_COMPONENT_10 = 2 +NV_CTRL_GVI_BITS_PER_COMPONENT_12 = 3 + +# +# NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT - Specify the number of +# bits per component (BPC) of data for the captured stream. +# The stream number should be specified in the "display_mask" parameter. +# +# Note: Setting this attribute may also result in the following +# NV-CONTROL attributes being reset on the GVI device (to ensure +# the configuration remains valid): +# NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING +# + +NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT = 310 # RW-I + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING - Returns the detected +# sampling format for the input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING = 311 # R--I +NV_CTRL_GVI_COMPONENT_SAMPLING_UNKNOWN = 0 +NV_CTRL_GVI_COMPONENT_SAMPLING_4444 = 1 +NV_CTRL_GVI_COMPONENT_SAMPLING_4224 = 2 +NV_CTRL_GVI_COMPONENT_SAMPLING_444 = 3 +NV_CTRL_GVI_COMPONENT_SAMPLING_422 = 4 +NV_CTRL_GVI_COMPONENT_SAMPLING_420 = 5 + +# +# NV_CTRL_GVI_REQUESTED_COMPONENT_SAMPLING - Specify the sampling format for +# the captured stream. +# The possible values are the NV_CTRL_GVI_DETECTED_COMPONENT_SAMPLING +# constants. +# The stream number should be specified in the "display_mask" parameter. +# + +NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING = 312 # RW-I + +# +# NV_CTRL_GVI_CHROMA_EXPAND - Enable or disable 4:2:2 -> 4:4:4 chroma +# expansion for the captured stream. This value is ignored when a +# COMPONENT_SAMPLING format is selected that does not use chroma subsampling, +# or if a BITS_PER_COMPONENT value is selected that is not supported. +# The stream number should be specified in the "display_mask" parameter. +# + +NV_CTRL_GVI_REQUESTED_STREAM_CHROMA_EXPAND = 313 # RW-I +NV_CTRL_GVI_CHROMA_EXPAND_FALSE = 0 +NV_CTRL_GVI_CHROMA_EXPAND_TRUE = 1 + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE - Returns the detected color space +# of the input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE = 314 # R--I +NV_CTRL_GVI_COLOR_SPACE_UNKNOWN = 0 +NV_CTRL_GVI_COLOR_SPACE_GBR = 1 +NV_CTRL_GVI_COLOR_SPACE_GBRA = 2 +NV_CTRL_GVI_COLOR_SPACE_GBRD = 3 +NV_CTRL_GVI_COLOR_SPACE_YCBCR = 4 +NV_CTRL_GVI_COLOR_SPACE_YCBCRA = 5 +NV_CTRL_GVI_COLOR_SPACE_YCBCRD = 6 + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID - Returns the detected link identifier +# for the given input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID = 315 # R--I +NV_CTRL_GVI_LINK_ID_UNKNOWN = 0xFFFF + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER - Returns the 4-byte +# SMPTE 352 identifier from the given input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER = 316 # R--I + +# +# NV_CTRL_GVI_GLOBAL_IDENTIFIER - Returns a global identifier for the +# GVI device. This identifier can be used to relate GVI devices named +# in NV-CONTROL with those enumerated in OpenGL. +# + +NV_CTRL_GVI_GLOBAL_IDENTIFIER = 317 # R--I + +# +# NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION - Returns the number of nanoseconds +# that one unit of NV_CTRL_FRAMELOCK_SYNC_DELAY corresponds to. +# +NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION = 318 # R-- + +# +# NV_CTRL_GPU_COOLER_MANUAL_CONTROL - Query the current or set a new +# cooler control state; the value of this attribute controls the +# availability of additional cooler control attributes (see below). +# +# Note: this attribute is unavailable unless cooler control support +# has been enabled in the X server (by the user). +# + +NV_CTRL_GPU_COOLER_MANUAL_CONTROL = 319 # RW-G +NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE = 0 +NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE = 1 + +# +# NV_CTRL_THERMAL_COOLER_LEVEL - The cooler's target level. +# Normally, the driver dynamically adjusts the cooler based on +# the needs of the GPU. But when NV_CTRL_GPU_COOLER_MANUAL_CONTROL=TRUE, +# the driver will attempt to make the cooler achieve the setting in +# NV_CTRL_THERMAL_COOLER_LEVEL. The actual current level of the cooler +# is reported in NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL. +# + +NV_CTRL_THERMAL_COOLER_LEVEL = 320 # RW-C + +# NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT - Sets default values of +# cooler. +# + +NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT = 321 # -W-C + +# +# NV_CTRL_THERMAL_COOLER_CONTROL_TYPE - +# Returns a cooler's control signal characteristics. +# The possible types are restricted, Variable and Toggle. +# + +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE = 322 # R--C +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_NONE = 0 +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_TOGGLE = 1 +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE = 2 + +# +# NV_CTRL_THERMAL_COOLER_TARGET - Returns objects that cooler cools. +# Targets may be GPU, Memory, Power Supply or All of these. +# GPU_RELATED = GPU | MEMORY | POWER_SUPPLY +# +# + +NV_CTRL_THERMAL_COOLER_TARGET = 323 # R--C +NV_CTRL_THERMAL_COOLER_TARGET_NONE = 0 +NV_CTRL_THERMAL_COOLER_TARGET_GPU = 1 +NV_CTRL_THERMAL_COOLER_TARGET_MEMORY = 2 +NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY = 4 +NV_CTRL_THERMAL_COOLER_TARGET_GPU_RELATED = NV_CTRL_THERMAL_COOLER_TARGET_GPU | NV_CTRL_THERMAL_COOLER_TARGET_MEMORY | NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY + +# +# NV_CTRL_GPU_ECC_SUPPORTED - Reports whether ECC is supported by the +# targeted GPU. +# +NV_CTRL_GPU_ECC_SUPPORTED = 324 # R--G +NV_CTRL_GPU_ECC_SUPPORTED_FALSE = 0 +NV_CTRL_GPU_ECC_SUPPORTED_TRUE = 1 + +# +# NV_CTRL_GPU_ECC_STATUS - Returns the current hardware ECC setting +# for the targeted GPU. +# +NV_CTRL_GPU_ECC_STATUS = 325 # R--G +NV_CTRL_GPU_ECC_STATUS_DISABLED = 0 +NV_CTRL_GPU_ECC_STATUS_ENABLED = 1 + +# +# NV_CTRL_GPU_ECC_CONFIGURATION - Reports whether ECC can be configured +# dynamically for the GPU in question. +# +NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED = 326 # R--G +NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_FALSE = 0 +NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_TRUE = 1 + +# +# NV_CTRL_GPU_ECC_CONFIGURATION_SETTING - Returns the current ECC +# configuration setting or specifies new settings. New settings do not +# take effect until the next POST. +# +NV_CTRL_GPU_ECC_CONFIGURATION = 327 # RW-G +NV_CTRL_GPU_ECC_CONFIGURATION_DISABLED = 0 +NV_CTRL_GPU_ECC_CONFIGURATION_ENABLED = 1 + +# +# NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_SETTING - Returns the default +# ECC configuration setting. +# +NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION = 328 # R--G +NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_DISABLED = 0 +NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_ENABLED = 1 + +# +# NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS - Returns the number of single-bit +# ECC errors detected by the targeted GPU since the last POST. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS = 329 # R--GQ + +# +# NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS - Returns the number of double-bit +# ECC errors detected by the targeted GPU since the last POST. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS = 330 # R--GQ + +# +# NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS - Returns the number of +# single-bit ECC errors detected by the targeted GPU since the +# last counter reset. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS = 331 # R--GQ + +# +# NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS - Returns the number of +# double-bit ECC errors detected by the targeted GPU since the +# last counter reset. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS = 332 # R--GQ + +# +# NV_CTRL_GPU_ECC_RESET_ERROR_STATUS - Resets the volatile/aggregate +# single-bit and double-bit error counters. This attribute is a +# bitmask attribute. +# +NV_CTRL_GPU_ECC_RESET_ERROR_STATUS = 333 # -W-G +NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_VOLATILE = 0x00000001 +NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_AGGREGATE = 0x00000002 + +# +# NV_CTRL_GPU_POWER_MIZER_MODE - Provides a hint to the driver +# as to how to manage the performance of the GPU. +# +# ADAPTIVE - adjust GPU clocks based on GPU +# utilization +# PREFER_MAXIMUM_PERFORMANCE - raise GPU clocks to favor +# maximum performance, to the extent +# that thermal and other constraints +# allow +# AUTO - let the driver choose the performance +# policy +# PREFER_CONSISTENT_PERFORMANCE - lock to GPU base clocks +# +NV_CTRL_GPU_POWER_MIZER_MODE = 334 # RW-G +NV_CTRL_GPU_POWER_MIZER_MODE_ADAPTIVE = 0 +NV_CTRL_GPU_POWER_MIZER_MODE_PREFER_MAXIMUM_PERFORMANCE = 1 +NV_CTRL_GPU_POWER_MIZER_MODE_AUTO = 2 +NV_CTRL_GPU_POWER_MIZER_MODE_PREFER_CONSISTENT_PERFORMANCE = 3 + +# +# NV_CTRL_GVI_SYNC_OUTPUT_FORMAT - Returns the output sync signal +# from the GVI device. +# + +NV_CTRL_GVI_SYNC_OUTPUT_FORMAT = 335 # R--I + +# +# NV_CTRL_GVI_MAX_CHANNELS_PER_JACK - Returns the maximum +# supported number of (logical) channels within a single physical jack of +# a GVI device. For most SDI video formats, there is only one channel +# (channel 0). But for 3G video formats (as specified in SMPTE 425), +# as an example, there are two channels (channel 0 and channel 1) per +# physical jack. +# + +NV_CTRL_GVI_MAX_CHANNELS_PER_JACK = 336 # R--I + +# +# NV_CTRL_GVI_MAX_STREAMS - Returns the maximum number of streams +# that can be configured on the GVI device. +# + +NV_CTRL_GVI_MAX_STREAMS = 337 # R--I + +# +# NV_CTRL_GVI_NUM_CAPTURE_SURFACES - The GVI interface exposed through +# NV-CONTROL and the GLX_NV_video_input extension uses internal capture +# surfaces when frames are read from the GVI device. The +# NV_CTRL_GVI_NUM_CAPTURE_SURFACES can be used to query and assign the +# number of capture surfaces. This attribute is applied when +# glXBindVideoCaptureDeviceNV() is called by the application. +# +# A lower number of capture surfaces will mean less video memory is used, +# but can result in frames being dropped if the application cannot keep up +# with the capture device. A higher number will prevent frames from being +# dropped, making capture more reliable but will consume move video memory. +# +NV_CTRL_GVI_NUM_CAPTURE_SURFACES = 338 # RW-I + +# +# NV_CTRL_OVERSCAN_COMPENSATION - not supported +# +NV_CTRL_OVERSCAN_COMPENSATION = 339 # not supported + +# +# NV_CTRL_GPU_PCIE_GENERATION - Reports the current PCIe generation. +# +NV_CTRL_GPU_PCIE_GENERATION = 341 # R--GI +NV_CTRL_GPU_PCIE_GENERATION1 = 0x00000001 +NV_CTRL_GPU_PCIE_GENERATION2 = 0x00000002 +NV_CTRL_GPU_PCIE_GENERATION3 = 0x00000003 + +# +# NV_CTRL_GVI_BOUND_GPU - Returns the NV_CTRL_TARGET_TYPE_GPU target_id of +# the GPU currently bound to the GVI device. Returns -1 if no GPU is +# currently bound to the GVI device. +# +NV_CTRL_GVI_BOUND_GPU = 342 # R--I + +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 - this attribute is only +# intended to be used to query the ValidValues for +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for VIDEO_FORMAT values between +# 64 and 95. See NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for details. +# + +NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 = 343 # ---GI + +# +# NV_CTRL_ACCELERATE_TRAPEZOIDS - Toggles RENDER Trapezoid acceleration +# + +NV_CTRL_ACCELERATE_TRAPEZOIDS = 344 # RW- +NV_CTRL_ACCELERATE_TRAPEZOIDS_DISABLE = 0 +NV_CTRL_ACCELERATE_TRAPEZOIDS_ENABLE = 1 + +# +# NV_CTRL_GPU_CORES - Returns number of GPU cores supported by the graphics +# pipeline. +# + +NV_CTRL_GPU_CORES = 345 # R--G + +# +# NV_CTRL_GPU_MEMORY_BUS_WIDTH - Returns memory bus bandwidth on the associated +# subdevice. +# + +NV_CTRL_GPU_MEMORY_BUS_WIDTH = 346 # R--G + +# +# NV_CTRL_GVI_TEST_MODE - This attribute controls the GVI test mode. When +# enabled, the GVI device will generate fake data as quickly as possible. All +# GVI settings are still valid when this is enabled (e.g., the requested video +# format is honored and sets the video size). +# This may be used to test the pipeline. +# + +NV_CTRL_GVI_TEST_MODE = 347 # R--I +NV_CTRL_GVI_TEST_MODE_DISABLE = 0 +NV_CTRL_GVI_TEST_MODE_ENABLE = 1 + +# +# NV_CTRL_COLOR_SPACE - This option controls the preferred color space of the +# video signal. This may not match the current color space depending on the +# current mode on this display. +# +# NV_CTRL_CURRENT_COLOR_SPACE will reflect the actual color space in use. +# +NV_CTRL_COLOR_SPACE = 348 # RWDG +NV_CTRL_COLOR_SPACE_RGB = 0 +NV_CTRL_COLOR_SPACE_YCbCr422 = 1 +NV_CTRL_COLOR_SPACE_YCbCr444 = 2 + +# +# NV_CTRL_COLOR_RANGE - This option controls the preferred color range of the +# video signal. +# +# If the current color space requires it, the actual color range will be +# limited. +# +# NV_CTRL_CURRENT_COLOR_RANGE will reflect the actual color range in use. +# +NV_CTRL_COLOR_RANGE = 349 # RWDG +NV_CTRL_COLOR_RANGE_FULL = 0 +NV_CTRL_COLOR_RANGE_LIMITED = 1 + +# +# NV_CTRL_GPU_SCALING_DEFAULT_TARGET - not supported +# + +NV_CTRL_GPU_SCALING_DEFAULT_TARGET = 350 # not supported + +# +# NV_CTRL_GPU_SCALING_DEFAULT_METHOD - not supported +# + +NV_CTRL_GPU_SCALING_DEFAULT_METHOD = 351 # not supported + +# +# NV_CTRL_DITHERING_MODE - Controls the dithering mode, when +# NV_CTRL_CURRENT_DITHERING is Enabled. +# +# AUTO: allow the driver to choose the dithering mode automatically. +# +# DYNAMIC_2X2: use a 2x2 matrix to dither from the GPU's pixel +# pipeline to the bit depth of the flat panel. The matrix values +# are changed from frame to frame. +# +# STATIC_2X2: use a 2x2 matrix to dither from the GPU's pixel +# pipeline to the bit depth of the flat panel. The matrix values +# do not change from frame to frame. +# +# TEMPORAL: use a pseudorandom value from a uniform distribution calculated at +# every pixel to achieve stochastic dithering. This method produces a better +# visual result than 2x2 matrix approaches. +# +NV_CTRL_DITHERING_MODE = 352 # RWDG +NV_CTRL_DITHERING_MODE_AUTO = 0 +NV_CTRL_DITHERING_MODE_DYNAMIC_2X2 = 1 +NV_CTRL_DITHERING_MODE_STATIC_2X2 = 2 +NV_CTRL_DITHERING_MODE_TEMPORAL = 3 + +# +# NV_CTRL_CURRENT_DITHERING - Returns the current dithering state. +# +NV_CTRL_CURRENT_DITHERING = 353 # R-DG +NV_CTRL_CURRENT_DITHERING_DISABLED = 0 +NV_CTRL_CURRENT_DITHERING_ENABLED = 1 + +# +# NV_CTRL_CURRENT_DITHERING_MODE - Returns the current dithering +# mode. +# +NV_CTRL_CURRENT_DITHERING_MODE = 354 # R-DG +NV_CTRL_CURRENT_DITHERING_MODE_NONE = 0 +NV_CTRL_CURRENT_DITHERING_MODE_DYNAMIC_2X2 = 1 +NV_CTRL_CURRENT_DITHERING_MODE_STATIC_2X2 = 2 +NV_CTRL_CURRENT_DITHERING_MODE_TEMPORAL = 3 + +# +# NV_CTRL_THERMAL_SENSOR_READING - Returns the thermal sensor's current +# reading. +# +NV_CTRL_THERMAL_SENSOR_READING = 355 # R--S + +# +# NV_CTRL_THERMAL_SENSOR_PROVIDER - Returns the hardware device that +# provides the thermal sensor. +# +NV_CTRL_THERMAL_SENSOR_PROVIDER = 356 # R--S +NV_CTRL_THERMAL_SENSOR_PROVIDER_NONE = 0 +NV_CTRL_THERMAL_SENSOR_PROVIDER_GPU_INTERNAL = 1 +NV_CTRL_THERMAL_SENSOR_PROVIDER_ADM1032 = 2 +NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7461 = 3 +NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX6649 = 4 +NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX1617 = 5 +NV_CTRL_THERMAL_SENSOR_PROVIDER_LM99 = 6 +NV_CTRL_THERMAL_SENSOR_PROVIDER_LM89 = 7 +NV_CTRL_THERMAL_SENSOR_PROVIDER_LM64 = 8 +NV_CTRL_THERMAL_SENSOR_PROVIDER_G781 = 9 +NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7473 = 10 +NV_CTRL_THERMAL_SENSOR_PROVIDER_SBMAX6649 = 11 +NV_CTRL_THERMAL_SENSOR_PROVIDER_VBIOSEVT = 12 +NV_CTRL_THERMAL_SENSOR_PROVIDER_OS = 13 +NV_CTRL_THERMAL_SENSOR_PROVIDER_UNKNOWN = 0xFFFFFFFF + +# +# NV_CTRL_THERMAL_SENSOR_TARGET - Returns what hardware component +# the thermal sensor is measuring. +# +NV_CTRL_THERMAL_SENSOR_TARGET = 357 # R--S +NV_CTRL_THERMAL_SENSOR_TARGET_NONE = 0 +NV_CTRL_THERMAL_SENSOR_TARGET_GPU = 1 +NV_CTRL_THERMAL_SENSOR_TARGET_MEMORY = 2 +NV_CTRL_THERMAL_SENSOR_TARGET_POWER_SUPPLY = 4 +NV_CTRL_THERMAL_SENSOR_TARGET_BOARD = 8 +NV_CTRL_THERMAL_SENSOR_TARGET_UNKNOWN = 0xFFFFFFFF + +# +# NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR - when TRUE, OpenGL will +# draw information about the current MULTIGPU mode. +# +NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR = 358 # RW-X +NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_TRUE = 1 + +# +# NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS - Returns GPU's processor +# clock freqs. +# +NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS = 359 # RW-G + +# +# NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS - query the flags (various information +# for the specified NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be +# queried with existing interfaces, the video format should be specified +# in the display_mask field; eg: +# +# XNVCTRLQueryTargetAttribute(dpy, +# NV_CTRL_TARGET_TYPE_GVI, +# gvi, +# NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296, +# NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS, +# &flags); +# +# Note: The NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_1080P_NO_12BPC flag is set +# for those 1080P 3G modes (level A and B) that do not support +# 12 bits per component (when configuring a GVI stream.) +# + +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS = 360 # R--I +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_NONE = 0x00000000 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_INTERLACED = 0x00000001 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_PROGRESSIVE = 0x00000002 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_PSF = 0x00000004 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_A = 0x00000008 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_B = 0x00000010 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G = NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_A | NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_B +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_1080P_NO_12BPC = 0x00000020 + +# +# NV_CTRL_GPU_PCIE_MAX_LINK_SPEED - returns maximum PCIe link speed, +# in gigatransfers per second (GT/s). +# + +NV_CTRL_GPU_PCIE_MAX_LINK_SPEED = 361 # R--GI + +# +# NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS - Resets the +# 3D Vision Pro transceiver to its factory settings. +# +NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS = 363 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL - Controls the channel that is +# currently used by the 3D Vision Pro transceiver. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL = 364 # RW-T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE - Controls the mode in which the +# 3D Vision Pro transceiver operates. +# NV_CTRL_3D_VISION_PRO_TM_LOW_RANGE is bidirectional +# NV_CTRL_3D_VISION_PRO_TM_MEDIUM_RANGE is bidirectional +# NV_CTRL_3D_VISION_PRO_TM_HIGH_RANGE may be bidirectional just up to a +# given range, and unidirectional beyond it +# NV_CTRL_3D_VISION_PRO_TM_COUNT is the total number of +# 3D Vision Pro transceiver modes +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE = 365 # RW-T +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_INVALID = 0 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_LOW_RANGE = 1 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_MEDIUM_RANGE = 2 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_HIGH_RANGE = 3 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_COUNT = 4 + +# +# NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES - controls whether updates to the color +# lookup table (LUT) are synchronous with respect to X rendering. For example, +# if an X client sends XStoreColors followed by XFillRectangle, the driver will +# guarantee that the FillRectangle request is not processed until after the +# updated LUT colors are actually visible on the screen if +# NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES is enabled. Otherwise, the rendering may +# occur first. +# +# This makes a difference for applications that use the LUT to animate, such as +# XPilot. If you experience flickering in applications that use LUT +# animations, try enabling this attribute. +# +# When synchronous updates are enabled, XStoreColors requests will be processed +# at your screen's refresh rate. +# + +NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES = 367 # RWDG +NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_DISABLE = 0 +NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_ENABLE = 1 + +# +# NV_CTRL_DITHERING_DEPTH - Controls the dithering depth when +# NV_CTRL_CURRENT_DITHERING is ENABLED. Some displays connected +# to the GPU via the DVI or LVDS interfaces cannot display the +# full color range of ten bits per channel, so the GPU will +# dither to either 6 or 8 bits per channel. +# +NV_CTRL_DITHERING_DEPTH = 368 # RWDG +NV_CTRL_DITHERING_DEPTH_AUTO = 0 +NV_CTRL_DITHERING_DEPTH_6_BITS = 1 +NV_CTRL_DITHERING_DEPTH_8_BITS = 2 + +# +# NV_CTRL_CURRENT_DITHERING_DEPTH - Returns the current dithering +# depth value. +# +NV_CTRL_CURRENT_DITHERING_DEPTH = 369 # R-DG +NV_CTRL_CURRENT_DITHERING_DEPTH_NONE = 0 +NV_CTRL_CURRENT_DITHERING_DEPTH_6_BITS = 1 +NV_CTRL_CURRENT_DITHERING_DEPTH_8_BITS = 2 + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY - Returns the +# frequency of the channel(in kHz) of the 3D Vision Pro transceiver. +# Use the display_mask parameter to specify the channel number. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY = 370 # R--T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY - Returns the +# quality of the channel(in percentage) of the 3D Vision Pro transceiver. +# Use the display_mask parameter to specify the channel number. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY = 371 # R--T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT - Returns the number of +# channels on the 3D Vision Pro transceiver. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT = 372 # R--T + +# +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES - Puts the 3D Vision Pro +# transceiver into pairing mode to gather additional glasses. +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_STOP - stops any pairing +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON - starts continuous +# pairing via beacon mode +# Any other value, N - Puts the 3D Vision Pro transceiver into +# authenticated pairing mode for N seconds. +# +NV_CTRL_3D_VISION_PRO_PAIR_GLASSES = 373 # -W-T +NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_STOP = 0 +NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON = 0xFFFFFFFF + +# +# NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES - Tells a specific pair +# of glasses to unpair. The glasses will "forget" the address +# of the 3D Vision Pro transceiver to which they have been paired. +# To unpair all the currently paired glasses, specify +# the glasses id as 0. +# +NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES = 374 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES - Tells the 3D Vision Pro +# transceiver about the glasses that have been paired using +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON. Unless this is done, +# the 3D Vision Pro transceiver will not know about glasses paired in +# beacon mode. +# +NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES = 375 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES - Causes glasses LEDs to +# flash for a short period of time. +# +NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES = 376 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE - Controls the +# sync cycle duration(in milliseconds) of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE = 378 # RW-T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES - Returns the +# number of state sync cycles recently missed by the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES = 379 # R--T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL - Returns the +# battery level(in percentage) of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL = 380 # R--T + +# +# NV_CTRL_GVO_ANC_PARITY_COMPUTATION - Controls the SDI device's computation +# of the parity bit (bit 8) for ANC data words. +# + +NV_CTRL_GVO_ANC_PARITY_COMPUTATION = 381 # RW--- +NV_CTRL_GVO_ANC_PARITY_COMPUTATION_AUTO = 0 +NV_CTRL_GVO_ANC_PARITY_COMPUTATION_ON = 1 +NV_CTRL_GVO_ANC_PARITY_COMPUTATION_OFF = 2 + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT - This attribute is sent +# as an event when glasses get paired in response to pair command +# from any of the clients. +# +NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT = 382 # ---T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT - This attribute is sent +# as an event when glasses get unpaired in response to unpair command +# from any of the clients. +# +NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT = 383 # ---T + +# +# NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH - returns the current +# PCIe link width, in number of lanes. +# +NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH = 384 # R--GI + +# +# NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED - returns the current +# PCIe link speed, in megatransfers per second (GT/s). +# +NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED = 385 # R--GI + +# +# NV_CTRL_GVO_AUDIO_BLANKING - specifies whether the GVO device should delete +# audio ancillary data packets when frames are repeated. +# +# When a new frame is not ready in time, the current frame, including all +# ancillary data packets, is repeated. When this data includes audio packets, +# this can result in stutters or clicks. When this option is enabled, the GVO +# device will detect when frames are repeated, identify audio ancillary data +# packets, and mark them for deletion. +# +# This option is applied when the GVO device is bound. +# +NV_CTRL_GVO_AUDIO_BLANKING = 386 # RW- +NV_CTRL_GVO_AUDIO_BLANKING_DISABLE = 0 +NV_CTRL_GVO_AUDIO_BLANKING_ENABLE = 1 + +# +# NV_CTRL_CURRENT_METAMODE_ID - switch modes to the MetaMode with +# the specified ID. +# +NV_CTRL_CURRENT_METAMODE_ID = 387 # RW- + +# +# NV_CTRL_DISPLAY_ENABLED - Returns whether or not the display device +# is currently enabled. +# +NV_CTRL_DISPLAY_ENABLED = 388 # R-D +NV_CTRL_DISPLAY_ENABLED_TRUE = 1 +NV_CTRL_DISPLAY_ENABLED_FALSE = 0 + +# +# NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE: this is the rate +# of an incomming house sync signal to the frame lock board, 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_INCOMING_HOUSE_SYNC_RATE = 389 # R--F + +# +# NV_CTRL_FXAA - enables FXAA. A pixel shader based anti- +# aliasing method. +# +NV_CTRL_FXAA = 390 # RW-X +NV_CTRL_FXAA_DISABLE = 0 +NV_CTRL_FXAA_ENABLE = 1 + +# +# NV_CTRL_DISPLAY_RANDR_OUTPUT_ID - the RandR Output ID (type RROutput) +# that corresponds to the specified Display Device target. If a new +# enough version of RandR is not available in the X server, +# DISPLAY_RANDR_OUTPUT_ID will be 0. +# +NV_CTRL_DISPLAY_RANDR_OUTPUT_ID = 391 # R-D- + +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG - Configures whether the display device +# should listen, ignore or drive the framelock sync signal. +# +# Note that whether or not a display device may be set as a client/server +# depends on the current configuration. For example, only one server may be +# set per Quadro Sync device, and displays can only be configured as a client +# if their refresh rate sufficiently matches the refresh rate of the server +# device. +# +# Note that when querying the ValidValues for this data type, the values are +# reported as bits within a bitmask (ATTRIBUTE_TYPE_INT_BITS); +# +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG = 392 # RWD +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_DISABLED = 0 +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_CLIENT = 1 +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_SERVER = 2 + +# +# NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY - Returns the total amount of dedicated +# GPU video memory, in MB, on the specified GPU. This excludes any TurboCache +# padding included in the value returned by NV_CTRL_TOTAL_GPU_MEMORY. +# +NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY = 393 # R--G + +# +# NV_CTRL_USED_DEDICATED_GPU_MEMORY- Returns the amount of video memory +# currently used on the graphics card in MB. +# +NV_CTRL_USED_DEDICATED_GPU_MEMORY = 394 # R--G + +# +# NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE +# Some GPUs can make a tradeoff between double-precision floating-point +# performance and clock speed. Enabling double-precision floating point +# performance may benefit CUDA or OpenGL applications that require high +# bandwidth double-precision performance. Disabling this feature may benefit +# graphics applications that require higher clock speeds. +# +# This attribute is only available when toggling double precision boost +# can be done immediately (without need for a rebooot). +# +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE = 395 # RW-G +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_DISABLED = 0 +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_ENABLED = 1 + +# +# NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT +# Some GPUs can make a tradeoff between double-precision floating-point +# performance and clock speed. Enabling double-precision floating point +# performance may benefit CUDA or OpenGL applications that require high +# bandwidth double-precision performance. Disabling this feature may benefit +# graphics applications that require higher clock speeds. +# +# This attribute is only available when toggling double precision boost +# requires a reboot. +# + +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT = 396 # RW-G +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_DISABLED = 0 +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_ENALED = 1 + +# +# NV_CTRL_DPY_HDMI_3D - Returns whether the specified display device is +# currently using HDMI 3D Frame Packed Stereo mode. Clients may use this +# to help interpret the refresh rate returned by NV_CTRL_REFRESH_RATE or +# NV_CTRL_REFRESH_RATE_3, which will be doubled when using HDMI 3D mode. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# + +NV_CTRL_DPY_HDMI_3D = 397 # R-DG +NV_CTRL_DPY_HDMI_3D_DISABLED = 0 +NV_CTRL_DPY_HDMI_3D_ENABLED = 1 + +# +# NV_CTRL_BASE_MOSAIC - Returns whether Base Mosaic is currently enabled on the +# given GPU. Querying the valid values of this attribute returns capabilities. +# + +NV_CTRL_BASE_MOSAIC = 398 # R--G +NV_CTRL_BASE_MOSAIC_DISABLED = 0 +NV_CTRL_BASE_MOSAIC_FULL = 1 +NV_CTRL_BASE_MOSAIC_LIMITED = 2 + +# +# NV_CTRL_MULTIGPU_MASTER_POSSIBLE - Returns whether the GPU can be configured +# as the master GPU in a Multi GPU configuration (SLI, SLI Mosaic, +# Base Mosaic). +# + +NV_CTRL_MULTIGPU_MASTER_POSSIBLE = 399 # R--G +NV_CTRL_MULTIGPU_MASTER_POSSIBLE_FALSE = 0 +NV_CTRL_MULTIGPU_MASTER_POSSIBLE_TRUE = 1 + +# +# NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE - Returns the default PowerMizer mode +# for the given GPU. +# +NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE = 400 # R--G + +# +# NV_CTRL_XV_SYNC_TO_DISPLAY_ID - When XVideo Sync To VBlank is enabled, this +# controls which display device will be synched to if the display is enabled. +# Returns NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO if no display has been +# selected. +# +NV_CTRL_XV_SYNC_TO_DISPLAY_ID = 401 # RW- +NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO = 0xFFFFFFFF + +# +# NV_CTRL_BACKLIGHT_BRIGHTNESS - The backlight brightness of an internal panel. +# +NV_CTRL_BACKLIGHT_BRIGHTNESS = 402 # RWD- + +# +# NV_CTRL_GPU_LOGO_BRIGHTNESS - Controls brightness +# of the logo on the GPU, if any. The value is variable from 0% - 100%. +# +NV_CTRL_GPU_LOGO_BRIGHTNESS = 403 # RW-G + +# +# NV_CTRL_GPU_SLI_LOGO_BRIGHTNESS - Controls brightness of the logo +# on the SLI bridge, if any. The value is variable from 0% - 100%. +# +NV_CTRL_GPU_SLI_LOGO_BRIGHTNESS = 404 # RW-G + +# +# NV_CTRL_THERMAL_COOLER_SPEED - Returns cooler's current operating speed in +# rotations per minute (RPM). +# + +NV_CTRL_THERMAL_COOLER_SPEED = 405 # R--C + +# +# NV_CTRL_PALETTE_UPDATE_EVENT - The Color Palette has been changed and the +# color correction info needs to be updated. +# + +NV_CTRL_PALETTE_UPDATE_EVENT = 406 # --- + +# +# NV_CTRL_VIDEO_ENCODER_UTILIZATION - Returns the video encoder engine +# utilization as a percentage. +# +NV_CTRL_VIDEO_ENCODER_UTILIZATION = 407 # R--G + +# +# NV_CTRL_GSYNC_ALLOWED - when TRUE, OpenGL will enable G-SYNC when possible; +# when FALSE, OpenGL will always use a fixed monitor refresh rate. +# + +NV_CTRL_GSYNC_ALLOWED = 408 # RW-X +NV_CTRL_GSYNC_ALLOWED_FALSE = 0 +NV_CTRL_GSYNC_ALLOWED_TRUE = 1 + +# +# NV_CTRL_GPU_NVCLOCK_OFFSET - This attribute controls the GPU clock offsets +# (in MHz) used for overclocking per performance level. +# Use the display_mask parameter to specify the performance level. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 400 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_NVCLOCK_OFFSET = 409 # RW-G + +# +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET - This attribute controls +# the memory transfer rate offsets (in MHz) used for overclocking +# per performance level. +# Use the display_mask parameter to specify the performance level. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 400 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET = 410 # RW-G + +# +# NV_CTRL_VIDEO_DECODER_UTILIZATION - Returns the video decoder engine +# utilization as a percentage. +# +NV_CTRL_VIDEO_DECODER_UTILIZATION = 411 # R--G + +# +# NV_CTRL_GPU_OVER_VOLTAGE_OFFSET - This attribute controls +# the overvoltage offset in microvolts (uV). +# +# Note: To enable overvoltage support, set the X configuration +# option "Coolbits" to value "16". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 400 series and later +# Geforce GPUs. +# + +NV_CTRL_GPU_OVER_VOLTAGE_OFFSET = 412 # RW-G + +# +# NV_CTRL_GPU_CURRENT_CORE_VOLTAGE - This attribute returns the +# GPU's current operating voltage in microvolts (uV). +# +# This attribute is available on GPUs that support +# NV_CTRL_GPU_OVER_VOLTAGE_OFFSET. +# +NV_CTRL_GPU_CURRENT_CORE_VOLTAGE = 413 # R--G + +# +# NV_CTRL_CURRENT_COLOR_SPACE - Returns the current color space of the video +# signal. +# +# This will match NV_CTRL_COLOR_SPACE unless the current mode on this display +# device is an HDMI 2.0 4K@60Hz mode and the display device or GPU does not +# support driving this mode in RGB, in which case YCbCr420 will be returned. +# +NV_CTRL_CURRENT_COLOR_SPACE = 414 # R-DG +NV_CTRL_CURRENT_COLOR_SPACE_RGB = 0 +NV_CTRL_CURRENT_COLOR_SPACE_YCbCr422 = 1 +NV_CTRL_CURRENT_COLOR_SPACE_YCbCr444 = 2 +NV_CTRL_CURRENT_COLOR_SPACE_YCbCr420 = 3 + +# +# NV_CTRL_CURRENT_COLOR_RANGE - Returns the current color range of the video +# signal. +# +NV_CTRL_CURRENT_COLOR_RANGE = 415 # R-DG +NV_CTRL_CURRENT_COLOR_RANGE_FULL = 0 +NV_CTRL_CURRENT_COLOR_RANGE_LIMITED = 1 + +# +# NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR - when TRUE, OpenGL will indicate when +# G-SYNC is in use for full-screen applications. +# + +NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR = 416 # RW-X +NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR_TRUE = 1 + +# +# NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL - Returns cooler's current +# operating level. This may fluctuate dynamically. When +# NV_CTRL_GPU_COOLER_MANUAL_CONTROL=TRUE, the driver attempts +# to make this match NV_CTRL_THERMAL_COOLER_LEVEL. When +# NV_CTRL_GPU_COOLER_MANUAL_CONTROL=FALSE, the driver adjusts the +# current level based on the needs of the GPU. +# + +NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL = 417 # R--C + +# +# NV_CTRL_STEREO_SWAP_MODE - This attribute controls the swap mode when +# Quad-Buffered stereo is used. +# NV_CTRL_STEREO_SWAP_MODE_APPLICATION_CONTROL : Stereo swap mode is derived +# from the value of swap interval. +# If it's odd, the per eye swap mode is used. +# If it's even, the per eye pair swap mode is used. +# NV_CTRL_STEREO_SWAP_MODE_PER_EYE : The driver swaps each eye as it is ready. +# NV_CTRL_STEREO_SWAP_MODE_PER_EYE_PAIR : The driver waits for both eyes to +# complete rendering before swapping. +# + +NV_CTRL_STEREO_SWAP_MODE = 418 # RW-X +NV_CTRL_STEREO_SWAP_MODE_APPLICATION_CONTROL = 0 +NV_CTRL_STEREO_SWAP_MODE_PER_EYE = 1 +NV_CTRL_STEREO_SWAP_MODE_PER_EYE_PAIR = 2 + +# +# NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID - When XVideo Sync To VBlank is +# enabled, this returns the display id of the device currently synched to. +# Returns NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO if no display is currently +# set. +# + +NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID = 419 # R-- + +# +# NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED - Returns true if the +# Quadro Sync card connected to this GPU has a firmware version incompatible +# with this GPU. +# + +NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED = 420 # R--G +NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED_FALSE = 0 +NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED_TRUE = 1 + +# +# NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE - Returns the connector type used by +# a DisplayPort display. +# + +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE = 421 # R-DG +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_UNKNOWN = 0 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_DISPLAYPORT = 1 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_HDMI = 2 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_DVI = 3 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_VGA = 4 + +# +# NV_CTRL_DISPLAYPORT_IS_MULTISTREAM - Returns multi-stream support for +# DisplayPort displays. +# +NV_CTRL_DISPLAYPORT_IS_MULTISTREAM = 422 # R-DG + +# +# NV_CTRL_DISPLAYPORT_SINK_IS_AUDIO_CAPABLE - Returns whether a DisplayPort +# device supports audio. +# +NV_CTRL_DISPLAYPORT_SINK_IS_AUDIO_CAPABLE = 423 # R-DG + +# +# NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS - This attribute +# controls the GPU clock offsets (in MHz) used for overclocking. +# The offset is applied to all performance levels. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 1000 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS = 424 # RW-G + +# +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS - This +# attribute controls the memory transfer rate offsets (in MHz) used +# for overclocking. The offset is applied to all performance levels. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 1000 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS = 425 # RW-G + +# +# NV_CTRL_FRAMELOCK_FIRMWARE_VERSION - Queries the firmware major version of +# the Frame Lock device. +# +# This attribute must be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. +# + +NV_CTRL_FRAMELOCK_FIRMWARE_VERSION = 426 # R--F + +# +# NV_CTRL_FRAMELOCK_FIRMWARE_MINOR_VERSION - Queries the firmware minor +# version of the Frame Lock device. +# +# This attribute must be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. +# + +NV_CTRL_FRAMELOCK_FIRMWARE_MINOR_VERSION = 427 # R--F + +# +# NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR - when TRUE, graphics APIs will +# indicate various runtime information such as flip/blit, vsync status, API +# in use. +# + +NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR = 428 # RW-X +NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR_TRUE = 1 + +NV_CTRL_LAST_ATTRIBUTE = NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR + +############################################################################ + +# +# String Attributes: +# +# String attributes can be queryied through the XNVCTRLQueryStringAttribute() +# and XNVCTRLQueryTargetStringAttribute() function calls. +# +# String attributes can be set through the XNVCTRLSetStringAttribute() +# function call. (There are currently no string attributes that can be +# set on non-X Screen targets.) +# +# Unless otherwise noted, all string 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 target also cannot be queried/set through +# XNVCTRLQueryStringAttribute()/XNVCTRLSetStringAttribute() (Since +# these assume an X Screen target). +# + + +# +# NV_CTRL_STRING_PRODUCT_NAME - the product name on which the +# specified X screen is running, or the product name of the specified +# Frame Lock device. +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target to +# return the product name of the GPU, or a NV_CTRL_TARGET_TYPE_FRAMELOCK to +# return the product name of the Frame Lock device. +# + +NV_CTRL_STRING_PRODUCT_NAME = 0 # R--GF + +# +# NV_CTRL_STRING_VBIOS_VERSION - the video bios version on the GPU on +# which the specified X screen is running. +# + +NV_CTRL_STRING_VBIOS_VERSION = 1 # R--G + +# +# NV_CTRL_STRING_NVIDIA_DRIVER_VERSION - string representation of the +# NVIDIA driver version number for the NVIDIA X driver in use. +# + +NV_CTRL_STRING_NVIDIA_DRIVER_VERSION = 3 # R--G + +# +# NV_CTRL_STRING_DISPLAY_DEVICE_NAME - name of the display device +# specified in the display_mask argument. +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_STRING_DISPLAY_DEVICE_NAME = 4 # R-DG + +# +# NV_CTRL_STRING_TV_ENCODER_NAME - not supported +# + +NV_CTRL_STRING_TV_ENCODER_NAME = 5 # not supported + +# +# NV_CTRL_STRING_GVIO_FIRMWARE_VERSION - indicates the version of the +# Firmware on the GVIO device. +# + +NV_CTRL_STRING_GVIO_FIRMWARE_VERSION = 8 # R--I + +# +# NV_CTRL_STRING_GVO_FIRMWARE_VERSION - renamed +# +# NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead. +# +NV_CTRL_STRING_GVO_FIRMWARE_VERSION = 8 # renamed + +# +# NV_CTRL_STRING_CURRENT_MODELINE - Return the ModeLine currently +# being used by the specified display device. +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# +# The ModeLine string may be prepended with a comma-separated list of +# "token=value" pairs, separated from the ModeLine string by "::". +# This "token=value" syntax is the same as that used in +# NV_CTRL_BINARY_DATA_MODELINES +# + +NV_CTRL_STRING_CURRENT_MODELINE = 9 # R-DG + +# +# NV_CTRL_STRING_ADD_MODELINE - Adds a ModeLine to the specified +# display device. The ModeLine is not added if validation fails. +# +# The ModeLine string should have the same syntax as a ModeLine in +# the X configuration file; e.g., +# +# "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync +# + +NV_CTRL_STRING_ADD_MODELINE = 10 # -WDG + +# +# NV_CTRL_STRING_DELETE_MODELINE - Deletes an existing ModeLine +# from the specified display device. The currently selected +# ModeLine cannot be deleted. (This also means you cannot delete +# the last ModeLine.) +# +# The ModeLine string should have the same syntax as a ModeLine in +# the X configuration file; e.g., +# +# "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync +# + +NV_CTRL_STRING_DELETE_MODELINE = 11 # -WDG + +# +# NV_CTRL_STRING_CURRENT_METAMODE - Returns the metamode currently +# being used by the specified X screen. The MetaMode string has the +# same syntax as the MetaMode X configuration option, as documented +# in the NVIDIA driver README. +# +# The returned string may be prepended with a comma-separated list of +# "token=value" pairs, separated from the MetaMode string by "::". +# This "token=value" syntax is the same as that used in +# NV_CTRL_BINARY_DATA_METAMODES. +# + +NV_CTRL_STRING_CURRENT_METAMODE = 12 # RW-- +NV_CTRL_STRING_CURRENT_METAMODE_VERSION_1 = NV_CTRL_STRING_CURRENT_METAMODE + +# +# NV_CTRL_STRING_ADD_METAMODE - Adds a MetaMode to the specified +# X Screen. +# +# It is recommended to not use this attribute, but instead use +# NV_CTRL_STRING_OPERATION_ADD_METAMODE. +# + +NV_CTRL_STRING_ADD_METAMODE = 13 # -W-- + +# +# NV_CTRL_STRING_DELETE_METAMODE - Deletes an existing MetaMode from +# the specified X Screen. The currently selected MetaMode cannot be +# deleted. (This also means you cannot delete the last MetaMode). +# The MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. +# + +NV_CTRL_STRING_DELETE_METAMODE = 14 # -WD-- + +# +# NV_CTRL_STRING_VCSC_PRODUCT_NAME - deprecated +# +# Queries the product name of the VCSC device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_PRODUCT_NAME = 15 # R---V + +# +# NV_CTRL_STRING_VCSC_PRODUCT_ID - deprecated +# +# Queries the product ID of the VCSC device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_PRODUCT_ID = 16 # R---V + +# +# NV_CTRL_STRING_VCSC_SERIAL_NUMBER - deprecated +# +# Queries the unique serial number of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_SERIAL_NUMBER = 17 # R---V + +# +# NV_CTRL_STRING_VCSC_BUILD_DATE - deprecated +# +# Queries the date of the VCS device. the returned string is in the following +# format: "Week.Year" +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_BUILD_DATE = 18 # R---V + +# +# NV_CTRL_STRING_VCSC_FIRMWARE_VERSION - deprecated +# +# Queries the firmware version of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_FIRMWARE_VERSION = 19 # R---V + +# +# NV_CTRL_STRING_VCSC_FIRMWARE_REVISION - deprecated +# +# Queries the firmware revision of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCS target. +# + +NV_CTRL_STRING_VCSC_FIRMWARE_REVISION = 20 # R---V + +# +# NV_CTRL_STRING_VCSC_HARDWARE_VERSION - deprecated +# +# Queries the hardware version of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_HARDWARE_VERSION = 21 # R---V + +# +# NV_CTRL_STRING_VCSC_HARDWARE_REVISION - deprecated +# +# Queries the hardware revision of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_HARDWARE_REVISION = 22 # R---V + +# +# NV_CTRL_STRING_MOVE_METAMODE - Moves a MetaMode to the specified +# index location. The MetaMode must already exist in the X Screen's +# list of MetaModes (as returned by the NV_CTRL_BINARY_DATA_METAMODES +# attribute). If the index is larger than the number of MetaModes in +# the list, the MetaMode is moved to the end of the list. The +# MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. + +# The MetaMode string must be prepended with a comma-separated list +# of "token=value" pairs, separated from the MetaMode string by "::". +# Currently, the only valid token is "index", which indicates where +# in the MetaMode list the MetaMode should be moved to. +# +# Other tokens may be added in the future. +# +# E.g., +# "index=5 :: CRT-0: 1024x768 @1024x768 +0+0" +# + +NV_CTRL_STRING_MOVE_METAMODE = 23 # -W-- + +# +# NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES - returns the valid +# horizontal sync ranges used to perform mode validation for the +# specified display device. The ranges are in the same format as the +# "HorizSync" X config option: +# +# "horizsync-range may be a comma separated list of either discrete +# values or ranges of values. A range of values is two values +# separated by a dash." +# +# The values are in kHz. +# +# Additionally, the string may be prepended with a comma-separated +# list of "token=value" pairs, separated from the HorizSync string by +# "::". Valid tokens: +# +# Token Value +# "source" "edid" - HorizSync is from the display device's EDID +# "xconfig" - HorizSync is from the "HorizSync" entry in +# the Monitor section of the X config file +# "option" - HorizSync is from the "HorizSync" NVIDIA X +# config option +# "builtin" - HorizSync is from NVIDIA X driver builtin +# default values +# +# Additional tokens and/or values may be added in the future. +# +# Example: "source=edid :: 30.000-62.000" +# + +NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES = 24 # R-DG + +# +# NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES - returns the valid +# vertical refresh ranges used to perform mode validation for the +# specified display device. The ranges are in the same format as the +# "VertRefresh" X config option: +# +# "vertrefresh-range may be a comma separated list of either discrete +# values or ranges of values. A range of values is two values +# separated by a dash." +# +# The values are in Hz. +# +# Additionally, the string may be prepended with a comma-separated +# list of "token=value" pairs, separated from the VertRefresh string by +# "::". Valid tokens: +# +# Token Value +# "source" "edid" - VertRefresh is from the display device's EDID +# "xconfig" - VertRefresh is from the "VertRefresh" entry in +# the Monitor section of the X config file +# "option" - VertRefresh is from the "VertRefresh" NVIDIA X +# config option +# "builtin" - VertRefresh is from NVIDIA X driver builtin +# default values +# +# Additional tokens and/or values may be added in the future. +# +# Example: "source=edid :: 50.000-75.000" +# + +NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES = 25 # R-DG + +# +# NV_CTRL_STRING_SCREEN_RECTANGLE - returns the physical X Screen's +# initial position and size (in absolute coordinates) within the +# desktop as the "token=value" string: "x=#, y=#, width=#, height=#" +# +# Querying this attribute returns success only when Xinerama is enabled +# or the X server ABI is greater than equal to 12. +# + +NV_CTRL_STRING_SCREEN_RECTANGLE = 26 # R--- + +# +# NV_CTRL_STRING_XINERAMA_SCREEN_INFO - renamed +# +# NV_CTRL_STRING_SCREEN_RECTANGLE should be used instead. +# + +NV_CTRL_STRING_XINERAMA_SCREEN_INFO = 26 # renamed + +# +# NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER - used to specify the +# order that display devices will be returned via Xinerama when +# nvidiaXineramaInfo is enabled. Follows the same syntax as the +# nvidiaXineramaInfoOrder X config option. +# + +NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER = 27 # RW-- + +NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER = NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER # for backwards compatibility: + +# +# NV_CTRL_STRING_SLI_MODE - returns a string describing the current +# SLI mode, if any, or FALSE if SLI is not currently enabled. +# +# This string should be used for informational purposes only, and +# should not be used to distinguish between SLI modes, other than to +# recognize when SLI is disabled (FALSE is returned) or +# enabled (the returned string is non-NULL and describes the current +# SLI configuration). +# + +NV_CTRL_STRING_SLI_MODE = 28 # R---*/ + +# +# NV_CTRL_STRING_PERFORMANCE_MODES - returns a string with all the +# performance modes defined for this GPU along with their associated +# NV Clock and Memory Clock values. +# Not all tokens will be reported on all GPUs, and additional tokens +# may be added in the future. +# For backwards compatibility we still provide nvclock, memclock, and +# processorclock those are the same as nvclockmin, memclockmin and +# processorclockmin. +# +# Note: These clock values take into account the offset +# set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET. +# +# Each performance modes are returned as a comma-separated list of +# "token=value" pairs. Each set of performance mode tokens are separated +# by a ";". Valid tokens: +# +# Token Value +# "perf" integer - the Performance level +# "nvclock" integer - the GPU clocks (in MHz) for the perf level +# "nvclockmin" integer - the GPU clocks min (in MHz) for the perf level +# "nvclockmax" integer - the GPU clocks max (in MHz) for the perf level +# "nvclockeditable" integer - if the GPU clock domain is editable +# for the perf level +# "memclock" integer - the memory clocks (in MHz) for the perf level +# "memclockmin" integer - the memory clocks min (in MHz) for the perf level +# "memclockmax" integer - the memory clocks max (in MHz) for the perf level +# "memclockeditable" integer - if the memory clock domain is editable +# for the perf level +# "memtransferrate" integer - the memory transfer rate (in MHz) +# for the perf level +# "memtransferratemin" integer - the memory transfer rate min (in MHz) +# for the perf level +# "memtransferratemax" integer - the memory transfer rate max (in MHz) +# for the perf level +# "memtransferrateeditable" integer - if the memory transfer rate is editable +# for the perf level +# "processorclock" integer - the processor clocks (in MHz) +# for the perf level +# "processorclockmin" integer - the processor clocks min (in MHz) +# for the perf level +# "processorclockmax" integer - the processor clocks max (in MHz) +# for the perf level +# "processorclockeditable" integer - if the processor clock domain is editable +# for the perf level +# +# Example: +# +# perf=0, nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0, +# memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0, +# memtransferrate=648, memtransferratemin=648, memtransferratemax=648, +# memtransferrateeditable=0 ; +# perf=1, nvclock=324, nvclockmin=324, nvclockmax=640, nvclockeditable=0, +# memclock=810, memclockmin=810, memclockmax=810, memclockeditable=0, +# memtransferrate=1620, memtransferrate=1620, memtransferrate=1620, +# memtransferrateeditable=0 ; +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_STRING_PERFORMANCE_MODES = 29 # R--G + +# +# NV_CTRL_STRING_VCSC_FAN_STATUS - deprecated +# +# Returns a string with status of all the fans in the Visual Computing System, +# if such a query is supported. Fan information is reported along with its +# tachometer reading (in RPM) and a flag indicating whether the fan has failed +# or not. +# +# Valid tokens: +# +# Token Value +# "fan" integer - the Fan index +# "speed" integer - the tachometer reading of the fan in rpm +# "fail" integer - flag to indicate whether the fan has failed +# +# Example: +# +# fan=0, speed=694, fail=0 ; fan=1, speed=693, fail=0 +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# +# + +NV_CTRL_STRING_VCSC_FAN_STATUS = 30 # R---V + +# +# NV_CTRL_STRING_VCSC_TEMPERATURES - Deprecated +# +# Returns a string with all Temperature readings in the Visual Computing +# System, if such a query is supported. Intake, Exhaust and Board Temperature +# values are reported in Celcius. +# +# Valid tokens: +# +# Token Value +# "intake" integer - the intake temperature for the VCS +# "exhaust" integer - the exhaust temperature for the VCS +# "board" integer - the board temperature of the VCS +# +# Example: +# +# intake=29, exhaust=46, board=41 +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# +# + +NV_CTRL_STRING_VCSC_TEMPERATURES = 31 # R---V + +# +# NV_CTRL_STRING_VCSC_PSU_INFO - Deprecated +# +# Returns a string with all Power Supply Unit related readings in the Visual +# Computing System, if such a query is supported. Current in amperes, Power +# in watts, Voltage in volts and PSU state may be reported. Not all PSU types +# support all of these values, and therefore some readings may be unknown. +# +# Valid tokens: +# +# Token Value +# "current" integer - the current drawn in amperes by the VCS +# "power" integer - the power drawn in watts by the VCS +# "voltage" integer - the voltage reading of the VCS +# "state" integer - flag to indicate whether PSU is operating normally +# +# Example: +# +# current=10, power=15, voltage=unknown, state=normal +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# +# + + +NV_CTRL_STRING_VCSC_PSU_INFO = 32 # R---V + +# +# NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME - query the name for the specified +# NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be queried with existing +# interfaces, XNVCTRLQueryStringAttribute() should be used, and the video +# format specified in the display_mask field; eg: +# +# XNVCTRLQueryStringAttribute(dpy, +# screen, +# NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296, +# NV_CTRL_GVIO_VIDEO_FORMAT_NAME, +# &name); +# + +NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME = 33 # R--GI + +# +# NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME - renamed +# +# NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME should be used instead. +# +NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME = 33 # renamed + +# +# NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS - returns a string with the +# associated NV Clock, Memory Clock and Processor Clock values. +# +# Current valid tokens are "nvclock", "nvclockmin", "nvclockmax", +# "memclock", "memclockmin", "memclockmax", "processorclock", +# "processorclockmin" and "processorclockmax". +# Not all tokens will be reported on all GPUs, and additional tokens +# may be added in the future. +# +# Note: These clock values take into account the offset +# set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET. +# +# Clock values are returned as a comma-separated list of +# "token=value" pairs. +# Valid tokens: +# +# Token Value +# "nvclock" integer - the GPU clocks (in MHz) for the perf level +# "nvclockmin" integer - the GPU clocks min (in MHz) for the perf level +# "nvclockmax" integer - the GPU clocks max (in MHz) for the perf level +# "nvclockeditable" integer - if the GPU clock domain is editable +# for the perf level +# "memclock" integer - the memory clocks (in MHz) for the perf level +# "memclockmin" integer - the memory clocks min (in MHz) for the perf level +# "memclockmax" integer - the memory clocks (max in MHz) for the perf level +# "memclockeditable" integer - if the memory clock domain is editable +# for the perf level +# "memtransferrate" integer - the memory transfer rate (in MHz) +# for the perf level +# "memtransferratemin" integer - the memory transfer rate min (in MHz) +# for the perf level +# "memtransferratemax" integer - the memory transfer rate max (in MHz) +# for the perf level +# "memtransferrateeditable" integer - if the memory transfer rate is editable +# for the perf level +# "processorclock" integer - the processor clocks (in MHz) +# for the perf level +# "processorclockmin" integer - the processor clocks min (in MHz) +# for the perf level +# "processorclockmax" integer - the processor clocks max (in MHz) +# for the perf level +# "processorclockeditable" integer - if the processor clock domain is editable +# for the perf level +# +# Example: +# +# nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0 +# memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0 +# memtrasferrate=628 +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS = 34 # RW-G + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION - Returns the +# hardware revision of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION = 35 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A - Returns the +# firmware version of chip A of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A = 36 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A - Returns the +# date of the firmware of chip A of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A = 37 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B - Returns the +# firmware version of chip B of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B = 38 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B - Returns the +# date of the firmware of chip B of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B = 39 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS - Returns the RF address +# of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS = 40 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A - Returns the +# firmware version of chip A of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A = 41 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A - Returns the +# date of the firmware of chip A of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A = 42 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS - Returns the RF address +# of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS = 43 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME - Controls the name the +# glasses should use. +# Use the display_mask parameter to specify the glasses id. +# Glasses' name should start and end with an alpha-numeric character. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME = 44 # RW-T + +# +# NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2 - Returns the metamode currently +# being used by the specified X screen. The MetaMode string has the same +# syntax as the MetaMode X configuration option, as documented in the NVIDIA +# driver README. Also, see NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 for more +# details on the base syntax. +# +# The returned string may also be prepended with a comma-separated list of +# "token=value" pairs, separated from the MetaMode string by "::". +# +NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2 = 45 # RW-- + +# +# NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME - Returns a type name for the +# display device ("CRT", "DFP", or "TV"). However, note that the determination +# of the name is based on the protocol through which the X driver communicates +# to the display device. E.g., if the driver communicates using VGA ,then the +# basename is "CRT"; if the driver communicates using TMDS, LVDS, or DP, then +# the name is "DFP". +# +NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME = 46 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID - Returns the type-based name + ID for +# the display device, e.g. "CRT-0", "DFP-1", "TV-2". If this device is a +# DisplayPort multistream device, then this name will also be prepended with the +# device's port address like so: "DFP-1.0.1.2.3". See +# NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME for more information about the +# construction of type-based names. +# +NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID = 47 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_DP_GUID - Returns the GUID of the DisplayPort +# display device. e.g. "DP-GUID-f16a5bde-79f3-11e1-b2ae-8b5a8969ba9c" +# +# The display device must be a DisplayPort 1.2 device. +# +NV_CTRL_STRING_DISPLAY_NAME_DP_GUID = 48 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH - Returns the SHA-1 hash of the +# display device's EDID in 8-4-4-4-12 UID format. e.g. +# "DPY-EDID-f16a5bde-79f3-11e1-b2ae-8b5a8969ba9c" +# +# The display device must have a valid EDID. +# +NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH = 49 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX - Returns the current NV-CONTROL +# target ID (name) of the display device. e.g. "DPY-1", "DPY-4" +# +# This name for the display device is not guarenteed to be the same between +# different runs of the X server. +# +NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX = 50 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_RANDR - Returns the RandR output name for the +# display device. e.g. "VGA-1", "DVI-I-0", "DVI-D-3", "LVDS-1", "DP-2", +# "HDMI-3", "eDP-6". This name should match If this device is a DisplayPort +# 1.2 device, then this name will also be prepended with the device's port +# address like so: "DVI-I-3.0.1.2.3" +# +NV_CTRL_STRING_DISPLAY_NAME_RANDR = 51 # R-D- + +# +# NV_CTRL_STRING_GPU_UUID - Returns the UUID of the given GPU. +# +NV_CTRL_STRING_GPU_UUID = 52 # R--G + +# +# NV_CTRL_STRING_GPU_UTILIZATION - Returns the current percentage usage +# of the various components of the GPU. +# +# Current valid tokens are "graphics", "memory", "video" and "PCIe". +# Not all tokens will be reported on all GPUs, and additional tokens +# may be added in the future. +# +# Utilization values are returned as a comma-separated list of +# "token=value" pairs. +# Valid tokens: +# +# Token Value +# "graphics" integer - the percentage usage of graphics engine. +# "memory" integer - the percentage usage of FB. +# "video" integer - the percentage usage of video engine. +# "PCIe" integer - the percentage usage of PCIe bandwidth. +# +# +# Example: +# +# graphics=45, memory=6, video=0, PCIe=0 +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using an NV_CTRL_TARGET_TYPE_GPU. +# +NV_CTRL_STRING_GPU_UTILIZATION = 53 # R--G + +# +# NV_CTRL_STRING_MULTIGPU_MODE - returns a string describing the current +# MULTIGPU mode, if any, or FALSE if MULTIGPU is not currently enabled. +# +NV_CTRL_STRING_MULTIGPU_MODE = 54 # R--- + +# +# NV_CTRL_STRING_PRIME_OUTPUTS_DATA - returns a semicolon delimited list of +# strings that describe all PRIME configured displays. +# +# ex. "xpos=1920, ypos=0, width=1280, height=1024, screen=0;xpos=3200, +# ypos=0, width=800, height=600, screen=0;" +# +NV_CTRL_STRING_PRIME_OUTPUTS_DATA = 55 # R--- + +NV_CTRL_STRING_LAST_ATTRIBUTE = NV_CTRL_STRING_PRIME_OUTPUTS_DATA + +############################################################################ + +# +# Binary Data Attributes: +# +# Binary data attributes can be queryied through the XNVCTRLQueryBinaryData() +# and XNVCTRLQueryTargetBinaryData() function calls. +# +# There are currently no binary data attributes that can be set. +# +# Unless otherwise noted, all Binary data attributes can be queried +# using an NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot take +# an NV_CTRL_TARGET_TYPE_X_SCREEN target also cannot be queried through +# XNVCTRLQueryBinaryData() (Since an X Screen target is assumed). +# + + +# +# NV_CTRL_BINARY_DATA_EDID - Returns a display device's EDID information +# data. +# +# This attribute may be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_BINARY_DATA_EDID = 0 # R-DG + +# +# NV_CTRL_BINARY_DATA_MODELINES - Returns a display device's supported +# ModeLines. ModeLines are returned in a buffer, separated by a single +# '\0' and terminated by two consecutive '\0' s like so: +# +# "ModeLine 1\0ModeLine 2\0ModeLine 3\0Last ModeLine\0\0" +# +# This attribute may be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# +# Each ModeLine string may be prepended with a comma-separated list +# of "token=value" pairs, separated from the ModeLine string with a +# "::". Valid tokens: +# +# Token Value +# "source" "xserver" - the ModeLine is from the core X server +# "xconfig" - the ModeLine was specified in the X config file +# "builtin" - the NVIDIA driver provided this builtin ModeLine +# "vesa" - this is a VESA standard ModeLine +# "edid" - the ModeLine was in the display device's EDID +# "nv-control" - the ModeLine was specified via NV-CONTROL +# +# "xconfig-name" - for ModeLines that were specified in the X config +# file, this is the name the X config file +# gave for the ModeLine. +# +# Note that a ModeLine can have several sources; the "source" token +# can appear multiple times in the "token=value" pairs list. +# Additional source values may be specified in the future. +# +# Additional tokens may be added in the future, so it is recommended +# that any token parser processing the returned string from +# NV_CTRL_BINARY_DATA_MODELINES be implemented to gracefully ignore +# unrecognized tokens. +# +# E.g., +# +# "source=xserver, source=vesa, source=edid :: "1024x768_70" 75.0 1024 1048 1184 1328 768 771 777 806 -HSync -VSync" +# "source=xconfig, xconfig-name=1600x1200_60.00 :: "1600x1200_60_0" 161.0 1600 1704 1880 2160 1200 1201 1204 1242 -HSync +VSync" +# + +NV_CTRL_BINARY_DATA_MODELINES = 1 # R-DG + +# +# NV_CTRL_BINARY_DATA_METAMODES - Returns an X Screen's supported +# MetaModes. MetaModes are returned in a buffer separated by a +# single '\0' and terminated by two consecutive '\0' s like so: +# +# "MetaMode 1\0MetaMode 2\0MetaMode 3\0Last MetaMode\0\0" +# +# The MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. + +# Each MetaMode string may be prepended with a comma-separated list +# of "token=value" pairs, separated from the MetaMode string with +# "::". Currently, valid tokens are: +# +# Token Value +# "id" - the id of this MetaMode; this is stored in +# the Vertical Refresh field, as viewed +# by the XRandR and XF86VidMode X# +# extensions. +# +# "switchable" "yes"/"no" - whether this MetaMode may be switched to via +# ctrl-alt-+/-; Implicit MetaModes (see +# the "IncludeImplicitMetaModes" X +# config option), for example, are not +# normally made available through +# ctrl-alt-+/-. +# +# "source" "xconfig" - the MetaMode was specified in the X +# config file. +# "implicit" - the MetaMode was implicitly added; see the +# "IncludeImplicitMetaModes" X config option +# for details. +# "nv-control" - the MetaMode was added via the NV-CONTROL X +# extension to the currently running X server. +# "RandR" - the MetaMode was modified in response to an +# RandR RRSetCrtcConfig request. +# +# Additional tokens may be added in the future, so it is recommended +# that any token parser processing the returned string from +# NV_CTRL_BINARY_DATA_METAMODES be implemented to gracefully ignore +# unrecognized tokens. +# +# E.g., +# +# "id=50, switchable=yes, source=xconfig :: CRT-0: 1024x768 @1024x768 +0+0" +# + +NV_CTRL_BINARY_DATA_METAMODES = 2 # R-D- +NV_CTRL_BINARY_DATA_METAMODES_VERSION_1 = NV_CTRL_BINARY_DATA_METAMODES + +# +# NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU - Returns the list of X +# screens currently driven by the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of screens +# 4# n CARD32 screen indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU = 3 # R-DG + +# +# NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN - Returns the list of GPUs +# currently in use by the given X screen. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# + +NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN = 4 # R--- + +# +# NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK - Returns the list of +# GPUs currently connected to the given frame lock board. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK = 5 # R-DF + +# +# NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT - Returns the Display Device's +# viewport box into the given X Screen (in X Screen coordinates.) +# +# The format of the returned data is: +# +# 4 CARD32 Offset X +# 4 CARD32 Offset Y +# 4 CARD32 Width +# 4 CARD32 Height +# + +NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT = 6 # R-DG + +# +# NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU - Returns the list of +# Framelock devices currently connected to the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of Framelocks +# 4# n CARD32 Framelock indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU = 7 # R-DG + +# +# NV_CTRL_BINARY_DATA_GPUS_USING_VCSC - Deprecated +# +# Returns the list of GPU devices connected to the given VCS. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_VCSC target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN and cannot be queried using +# a NV_CTRL_TARGET_TYPE_X_GPU +# + +NV_CTRL_BINARY_DATA_GPUS_USING_VCSC = 8 # R-DV + +# +# NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU - Deprecated +# +# Returns the VCSC device that is controlling the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of VCS (always 1) +# 4# n CARD32 VCS indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN +# + +NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU = 9 # R-DG + +# +# NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU - Returns the coolers that +# are cooling the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of COOLER +# 4# n CARD32 COOLER indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN +# + +NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU = 10 # R-DG + +# +# NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN - Returns the list of +# GPUs currently driving the given X screen. If Xinerama is enabled, this +# will return all GPUs that are driving any X screen. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# + +NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN = 11 # R--- + +# +# NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU - Returns the sensors that +# are attached to the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of SENSOR +# 4# n CARD32 SENSOR indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN +# + +NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU = 12 # R--G + +# +# NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER - Returns +# the id of the glasses that are currently paired to the given +# 3D Vision Pro transceiver. +# +# The format of the returned data is: +# +# 4 CARD32 number of glasses +# 4# n CARD32 id of glasses +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER target. +# +NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER = 13 # R--T + +# +# NV_CTRL_BINARY_DATA_DISPLAY_TARGETS - Returns all the display devices +# currently connected to any GPU on the X server. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData(). +# + +NV_CTRL_BINARY_DATA_DISPLAY_TARGETS = 14 # R--- + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU - Returns the list of +# display devices that are connected to the GPU target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU = 15 # R--G + +# +# NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 - Returns values similar to +# NV_CTRL_BINARY_DATA_METAMODES(_VERSION_1) but also returns extended syntax +# information to indicate a specific display device, as well as other per- +# display deviceflags as "token=value" pairs. For example: +# +# "DPY-1: 1280x1024 {Stereo=PassiveLeft}, +# DPY-2: 1280x1024 {Stereo=PassiveRight}," +# +# The display device names have the form "DPY-%d", where the integer +# part of the name is the NV-CONTROL target ID for that display device +# for this instance of the X server. Note that display device NV-CONTROL +# target IDs are not guaranteed to be the same from one run of the X +# server to the next. +# + +NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 = 16 # R-D- + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN - Returns the list of +# display devices that are currently scanning out the X screen target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN = 17 # R--- + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN - Returns the list of +# display devices that are currently assigned the X screen target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN = 18 # R--- + +# +# NV_CTRL_BINARY_DATA_GPU_FLAGS - Returns a list of flags for the +# given GPU. A flag can, for instance, be a capability which enables +# or disables some features according to the GPU state. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPU flags +# 4# n CARD32 GPU flag +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# +NV_CTRL_BINARY_DATA_GPU_FLAGS = 19 # R--- + +# Stereo and display composition transformations are mutually exclusive. +NV_CTRL_BINARY_DATA_GPU_FLAGS_STEREO_DISPLAY_TRANSFORM_EXCLUSIVE = 0 +# Overlay and display composition transformations are mutually exclusive. +NV_CTRL_BINARY_DATA_GPU_FLAGS_OVERLAY_DISPLAY_TRANSFORM_EXCLUSIVE = 1 +# Depth 8 and display composition transformations are mutually exclusive. +NV_CTRL_BINARY_DATA_GPU_FLAGS_DEPTH_8_DISPLAY_TRANSFORM_EXCLUSIVE = 2 + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU - Returns the list of valid +# display devices that can be connected to the GPU target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU = 20 # R--G + +NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE = NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU + +############################################################################ + +# +# String Operation Attributes: +# +# These attributes are used with the XNVCTRLStringOperation() +# function; a string is specified as input, and a string is returned +# as output. +# +# Unless otherwise noted, all attributes can be operated upon using +# an NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + + +# +# NV_CTRL_STRING_OPERATION_ADD_METAMODE - provide a MetaMode string +# as input, and returns a string containing comma-separated list of +# "token=value" pairs as output. Currently, the only output token is +# "id", which indicates the id that was assigned to the MetaMode. +# +# All ModeLines referenced in the MetaMode must already exist for +# each display device (as returned by the +# NV_CTRL_BINARY_DATA_MODELINES attribute). +# +# The MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. +# +# The input string can optionally be prepended with a string of +# comma-separated "token=value" pairs, separated from the MetaMode +# string by "::". Currently, the only valid token is "index" which +# indicates the insertion index for the MetaMode. +# +# E.g., +# +# Input: "index=5 :: 1600x1200+0+0, 1600x1200+1600+0" +# Output: "id=58" +# +# which causes the MetaMode to be inserted at position 5 in the +# MetaMode list (all entries after 5 will be shifted down one slot in +# the list), and the X server's containing mode stores 58 as the +# VRefresh, so that the MetaMode can be uniquely identifed through +# XRandR and XF86VidMode. +# + +NV_CTRL_STRING_OPERATION_ADD_METAMODE = 0 # ---- + +# +# NV_CTRL_STRING_OPERATION_GTF_MODELINE - provide as input a string +# of comma-separated "token=value" pairs, and returns a ModeLine +# string, computed using the GTF formula using the parameters from +# the input string. Valid tokens for the input string are "width", +# "height", and "refreshrate". +# +# E.g., +# +# Input: "width=1600, height=1200, refreshrate=60" +# Output: "160.96 1600 1704 1880 2160 1200 1201 1204 1242 -HSync +VSync" +# +# This operation does not have any impact on any display device's +# modePool, and the ModeLine is not validated; it is simply intended +# for generating ModeLines. +# + +NV_CTRL_STRING_OPERATION_GTF_MODELINE = 1 # --- + +# +# NV_CTRL_STRING_OPERATION_CVT_MODELINE - provide as input a string +# of comma-separated "token=value" pairs, and returns a ModeLine +# string, computed using the CVT formula using the parameters from +# the input string. Valid tokens for the input string are "width", +# "height", "refreshrate", and "reduced-blanking". The +# "reduced-blanking" argument can be "0" or "1", to enable or disable +# use of reduced blanking for the CVT formula. +# +# E.g., +# +# Input: "width=1600, height=1200, refreshrate=60, reduced-blanking=1" +# Output: "130.25 1600 1648 1680 1760 1200 1203 1207 1235 +HSync -VSync" +# +# This operation does not have any impact on any display device's +# modePool, and the ModeLine is not validated; it is simply intended +# for generating ModeLines. +# + +NV_CTRL_STRING_OPERATION_CVT_MODELINE = 2 # --- + +# +# NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL - build a ModePool for the +# specified display device on the specified target (either an X +# screen or a GPU). This is typically used to generate a ModePool +# for a display device on a GPU on which no X screens are present. +# +# Currently, a display device's ModePool is static for the life of +# the X server, so XNVCTRLStringOperation will return FALSE if +# requested to build a ModePool on a display device that already has +# a ModePool. +# +# The string input to BUILD_MODEPOOL may be NULL. If it is not NULL, +# then it is interpreted as a double-colon ("::") separated list +# of "option=value" pairs, where the options and the syntax of their +# values are the X configuration options that impact the behavior of +# modePool construction; namely: +# +# "ModeValidation" +# "HorizSync" +# "VertRefresh" +# "FlatPanelProperties" +# "ExactModeTimingsDVI" +# "UseEdidFreqs" +# +# An example input string might look like: +# +# "ModeValidation=NoVesaModes :: HorizSync=50-110 :: VertRefresh=50-150" +# +# This request currently does not return a string. +# + +NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL = 3 # DG + +# +# NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS - Configure the streams- +# to-jack+channel topology for a GVI (Graphics capture board). +# +# The string input to GVI_CONFIGURE_STREAMS may be NULL. If this is the +# case, then the current topology is returned. +# +# If the input string to GVI_CONFIGURE_STREAMS is not NULL, the string +# is interpreted as a semicolon (";") separated list of comma-separated +# lists of "option=value" pairs that define a stream's composition. The +# available options and their values are: +# +# "stream": Defines which stream this comma-separated list describes. +# Valid values are the integers between 0 and +# NV_CTRL_GVI_NUM_STREAMS-1 (inclusive). +# +# "linkN": Defines a jack+channel pair to use for the given link N. +# Valid options are the string "linkN", where N is an integer +# between 0 and NV_CTRL_GVI_MAX_LINKS_PER_STREAM-1 (inclusive). +# Valid values for these options are strings of the form +# "jackX" and/or "jackX.Y", where X is an integer between 0 and +# NV_CTRL_GVI_NUM_JACKS-1 (inclusive), and Y (optional) is an +# integer between 0 and NV_CTRL_GVI_MAX_CHANNELS_PER_JACK-1 +# (inclusive). +# +# An example input string might look like: +# +# "stream=0, link0=jack0, link1=jack1; stream=1, link0=jack2.1" +# +# This example specifies two streams, stream 0 and stream 1. Stream 0 +# is defined to capture link0 data from the first channel (channel 0) of +# BNC jack 0 and link1 data from the first channel of BNC jack 1. The +# second stream (Stream 1) is defined to capture link0 data from channel 1 +# (second channel) of BNC jack 2. +# +# This example shows a possible configuration for capturing 3G input: +# +# "stream=0, link0=jack0.0, link1=jack0.1" +# +# Applications should query the following attributes to determine +# possible combinations: +# +# NV_CTRL_GVI_MAX_STREAMS +# NV_CTRL_GVI_MAX_LINKS_PER_STREAM +# NV_CTRL_GVI_NUM_JACKS +# NV_CTRL_GVI_MAX_CHANNELS_PER_JACK +# +# Note: A jack+channel pair can only be tied to one link/stream. +# +# Upon successful configuration or querying of this attribute, a string +# representing the current topology for all known streams on the device +# will be returned. On failure, NULL is returned. +# +# Note: Setting this attribute may also result in the following +# NV-CONTROL attributes being reset on the GVI device (to ensure +# the configuration remains valid): +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT +# NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT +# NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING +# + +NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS = 4 # RW-I + +# +# NV_CTRL_STRING_OPERATION_PARSE_METAMODE - Parses the given MetaMode string +# and returns the validated MetaMode string - possibly re-calculating various +# values such as ViewPortIn. If the MetaMode matches an existing MetaMode, +# the details of the existing MetaMode are returned. If the MetaMode fails to +# be parsed, NULL is returned. +# +NV_CTRL_STRING_OPERATION_PARSE_METAMODE = 5 # R--- + +NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE = NV_CTRL_STRING_OPERATION_PARSE_METAMODE + +############################################################################### +# NV-CONTROL major op numbers. these constants identify the request type +# +X_nvCtrlQueryExtension = 0 +X_nvCtrlQueryAttribute = 2 +X_nvCtrlQueryStringAttribute = 4 +X_nvCtrlQueryValidAttributeValues = 5 +X_nvCtrlSetStringAttribute = 9 +X_nvCtrlSetAttributeAndGetStatus = 19 +X_nvCtrlQueryBinaryData = 20 +X_nvCtrlQueryTargetCount = 24 +X_nvCtrlStringOperation = 25 + +############################################################################### +# various lists that go with attrs, but are handled more compactly +# this way. these lists are indexed by the possible values of their attrs +# and are explained in NVCtrl.h +# + +ATTRIBUTE_TYPE_UNKNOWN = 0 +ATTRIBUTE_TYPE_INTEGER = 1 +ATTRIBUTE_TYPE_BITMASK = 2 +ATTRIBUTE_TYPE_BOOL = 3 +ATTRIBUTE_TYPE_RANGE = 4 +ATTRIBUTE_TYPE_INT_BITS = 5 + +ATTRIBUTE_TYPE_READ = 0x01 +ATTRIBUTE_TYPE_WRITE = 0x02 +ATTRIBUTE_TYPE_DISPLAY = 0x04 +ATTRIBUTE_TYPE_GPU = 0x08 +ATTRIBUTE_TYPE_FRAMELOCK = 0x10 +ATTRIBUTE_TYPE_X_SCREEN = 0x20 +ATTRIBUTE_TYPE_XINERAMA = 0x40 +ATTRIBUTE_TYPE_VCSC = 0x80 + +############################################################################ + +# +# Attribute Targets +# +# Targets define attribute groups. For example, some attributes are only +# valid to set on a GPU, others are only valid when talking about an +# X Screen. Target types are then what is used to identify the target +# group of the attribute you wish to set/query. +# +# Here are the supported target types: +# + +NV_CTRL_TARGET_TYPE_X_SCREEN = 0 +NV_CTRL_TARGET_TYPE_GPU = 1 +NV_CTRL_TARGET_TYPE_FRAMELOCK = 2 +# Visual Computing System - deprecated. To be removed along with all +# VCS-specific attributes in a later release. +NV_CTRL_TARGET_TYPE_VCSC = 3 +NV_CTRL_TARGET_TYPE_GVI = 4 +NV_CTRL_TARGET_TYPE_COOLER = 5 # e.g., fan +NV_CTRL_TARGET_TYPE_THERMAL_SENSOR = 6 +NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER = 7 +NV_CTRL_TARGET_TYPE_DISPLAY = 8 + + +############################################################################### +# Targets, to indicate where a command should be executed. +# +class Target(object): + def __init__(self): + self._id = -1 + self._type = -1 + self._name = '' + + def id(self): + return self._id + + def type(self): + return self._type + + def __str__(self): + return '' % (self._name, self.id()) + + +class Gpu(Target): + def __init__(self, ngpu=0): + """Target a GPU""" + super(self.__class__, self).__init__() + self._id = ngpu + self._type = NV_CTRL_TARGET_TYPE_GPU + self._name = 'GPU' + + +class Screen(Target): + def __init__(self, nscr=0): + """Target an X screen""" + super(self.__class__, self).__init__() + self._id = nscr + self._type = NV_CTRL_TARGET_TYPE_X_SCREEN + self._name = 'X screen' + + +class Cooler(Target): + def __init__(self, nfan=0): + """Target a fann""" + super(self.__class__, self).__init__() + self._id = nfan + self._type = NV_CTRL_TARGET_TYPE_COOLER + self._name = 'Cooler' + + +class NVCtrlQueryAttributeRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryAttribute), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Int32('value'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + ) + + +class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlSetAttributeAndGetStatus), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + rq.Int32('value') + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Card32('pad3'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + ) + + +class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryStringAttribute), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Card32('string', 4), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.String8('string'), + ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py new file mode 100755 index 00000000..b8d387a1 --- /dev/null +++ b/examples/nvcontrol.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# +# examples/nvcontrol.py -- demonstrate the NV-CONTROL extension +# +# Copyright (C) 2019 Roberto Leinardi +# +# 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 + + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +import os + +# Change path so we find Xlib +from pprint import pprint + +from Xlib.display import Display +from Xlib.ext.nvcontrol import Gpu, Cooler + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +if __name__ == '__main__': + display = Display() + # Check for extension + if not display.has_extension('NV-CONTROL'): + sys.stderr.write('%s: server does not have the NV-CONTROL extension\n' + % sys.argv[0]) + print(display.query_extension('NV-CONTROL')) + sys.stderr.write("\n".join(display.list_extensions())) + if display.query_extension('NV-CONTROL') is None: + sys.exit(1) + + gpu = Gpu(0) + fan = Cooler(0) + + dic = {'get_vram': display.nvcontrol_get_vram(gpu), + 'get_irq': display.nvcontrol_get_irq(gpu), + 'supports_framelock': display.nvcontrol_supports_framelock(gpu), + 'get_core_temp': display.nvcontrol_get_core_temp(gpu), + 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), + 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), + 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), + 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), + 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), + 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), + 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), + 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), + 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), + 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), + 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), + 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), + 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), + 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), + 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), + 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), + 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), + 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), + 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), + 'get_max_displays': display.nvcontrol_get_max_displays(gpu), + 'get_name': display.nvcontrol_get_name(gpu), + 'get_driver_version': display.nvcontrol_get_driver_version(gpu), + 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), + 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), + 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), + 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu)} + + pprint(dic) + + # display.nvcontrol_set_cooler_manual_control_enabled(gpu, True) + # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) + # display.nvcontrol_set_cooler_manual_control_enabled(gpu, False) + # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) + + display.close() From 98f45f03cc0436d4c70ab6c56592258075500514 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 20:38:28 +0100 Subject: [PATCH 015/100] Ignoring mypy cache --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 19d67036..ac3327fb 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ target/ .idea/ +/.mypy_cache/ From aafedf44b88f5ce7fde2d4355a12e384d093bb44 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 20:39:53 +0100 Subject: [PATCH 016/100] NV-CONTROL: query target count --- Xlib/ext/nvcontrol.py | 44 +++++++++++++++++++++++++++--- examples/nvcontrol.py | 63 ++++++++++++++++++++++--------------------- 2 files changed, 73 insertions(+), 34 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 9f8d45cc..07ed55bf 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -27,6 +27,19 @@ extname = 'NV-CONTROL' +def query_target_count(self, target): + """return the target count""" + reply = NVCtrlQueryTargetCountRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_type=target.type()) + return int(reply._data.get('count')) + + +def get_gpu_count(self): + """Return the number of GPU's present in the system.""" + return int(query_target_count(self, Gpu())) + + def query_int_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) @@ -54,10 +67,6 @@ def set_int_attribute(self, target, displays, attr, value): return reply._data.get('flags') -def set_cooler_manual_control_enabled(self, target, enabled): - return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 - - def query_string_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) @@ -200,6 +209,10 @@ def get_cooler_manual_control_enabled(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 +def set_cooler_manual_control_enabled(self, target, enabled): + return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + + def get_fan_duty(self, target): return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) @@ -259,8 +272,10 @@ def _displays2mask(displays): 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_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) @@ -5186,3 +5201,24 @@ class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): rq.Card32('pad7'), rq.String8('string'), ) + + +class NVCtrlQueryTargetCountRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryTargetCount), + rq.RequestLength(), + rq.Card32('target_type'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('padb1'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('count'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.Card32('pad8'), + ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index b8d387a1..dfd3f9bb 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -50,36 +50,39 @@ gpu = Gpu(0) fan = Cooler(0) - dic = {'get_vram': display.nvcontrol_get_vram(gpu), - 'get_irq': display.nvcontrol_get_irq(gpu), - 'supports_framelock': display.nvcontrol_supports_framelock(gpu), - 'get_core_temp': display.nvcontrol_get_core_temp(gpu), - 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), - 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), - 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), - 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), - 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), - 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), - 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), - 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), - 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), - 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), - 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), - 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), - 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), - 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), - 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), - 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), - 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), - 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), - 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), - 'get_max_displays': display.nvcontrol_get_max_displays(gpu), - 'get_name': display.nvcontrol_get_name(gpu), - 'get_driver_version': display.nvcontrol_get_driver_version(gpu), - 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), - 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), - 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), - 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu)} + dic = { + 'get_gpu_count': display.nvcontrol_get_gpu_count(), + 'get_vram': display.nvcontrol_get_vram(gpu), + 'get_irq': display.nvcontrol_get_irq(gpu), + 'supports_framelock': display.nvcontrol_supports_framelock(gpu), + 'get_core_temp': display.nvcontrol_get_core_temp(gpu), + 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), + 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), + 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), + 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), + 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), + 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), + 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), + 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), + 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), + 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), + 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), + 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), + 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), + 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), + 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), + 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), + 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), + 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), + 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), + 'get_max_displays': display.nvcontrol_get_max_displays(gpu), + 'get_name': display.nvcontrol_get_name(gpu), + 'get_driver_version': display.nvcontrol_get_driver_version(gpu), + 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), + 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), + 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), + 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu) + } pprint(dic) From 14ad974709daa3b9fb8687987a76386cdc39193c Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 20:58:52 +0100 Subject: [PATCH 017/100] NV-CONTROL: query valid attrs values --- Xlib/ext/nvcontrol.py | 102 +++++++++++++++++++++++++++++++----------- examples/nvcontrol.py | 4 +- 2 files changed, 79 insertions(+), 27 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 07ed55bf..81a72b3b 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -29,9 +29,9 @@ def query_target_count(self, target): """return the target count""" - reply = NVCtrlQueryTargetCountRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_type=target.type()) + reply = NVCtrlQueryTargetCountReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_type=target.type()) return int(reply._data.get('count')) @@ -43,12 +43,12 @@ def get_gpu_count(self): def query_int_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) - reply = NVCtrlQueryAttributeRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_id=target.id(), - target_type=target.type(), - display_mask=display_mask, - attr=attr) + 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')) @@ -57,30 +57,44 @@ def query_int_attribute(self, target, displays, attr): def set_int_attribute(self, target, displays, attr, value): """return the value of an integer attribute""" display_mask = _displays2mask(displays) - reply = NVCtrlSetAttributeAndGetStatusRequest(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) + 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') def query_string_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) - reply = NVCtrlQueryStringAttributeRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_id=target.id(), - target_type=target.type(), - display_mask=display_mask, - attr=attr) + 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, displays, attr): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + 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 get_name(self, target): """the GPU product name on which the specified X screen is running""" return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) @@ -201,10 +215,18 @@ def get_gpu_nvclock_offset(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) +def get_gpu_nvclock_offset_range(self, target): + return query_valid_attr_values(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) + + def get_mem_transfer_rate_offset(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) +def get_mem_transfer_rate_offset_range(self, target): + return query_valid_attr_values(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) + + def get_cooler_manual_control_enabled(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 @@ -309,6 +331,10 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes) 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) ############################################################################ @@ -5129,7 +5155,7 @@ def __init__(self, nfan=0): self._name = 'Cooler' -class NVCtrlQueryAttributeRequest(rq.ReplyRequest): +class NVCtrlQueryAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryAttribute), @@ -5153,7 +5179,7 @@ class NVCtrlQueryAttributeRequest(rq.ReplyRequest): ) -class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest): +class NVCtrlSetAttributeAndGetStatusReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlSetAttributeAndGetStatus), @@ -5178,7 +5204,7 @@ class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest): ) -class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): +class NVCtrlQueryStringAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryStringAttribute), @@ -5203,7 +5229,7 @@ class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): ) -class NVCtrlQueryTargetCountRequest(rq.ReplyRequest): +class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryTargetCount), @@ -5222,3 +5248,27 @@ class NVCtrlQueryTargetCountRequest(rq.ReplyRequest): rq.Card32('pad7'), rq.Card32('pad8'), ) + + +class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryValidAttributeValues), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Int32('attr_type'), + rq.Int32('min'), + rq.Int32('max'), + rq.Card32('bits'), + rq.Card32('perms'), + ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index dfd3f9bb..bde1be31 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -81,7 +81,9 @@ 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), - 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu) + 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu), + 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu), + 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu) } pprint(dic) From fb47feb951b9acbdbe3820d28324b117ca38b87c Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 21:31:53 +0100 Subject: [PATCH 018/100] NV-CONTROL: query binary data and get coolers used by gpu --- Xlib/ext/nvcontrol.py | 120 +++++++++++++++++++++++++++++++++++------- examples/nvcontrol.py | 1 + 2 files changed, 101 insertions(+), 20 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 81a72b3b..368c266b 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -35,11 +35,6 @@ def query_target_count(self, target): return int(reply._data.get('count')) -def get_gpu_count(self): - """Return the number of GPU's present in the system.""" - return int(query_target_count(self, Gpu())) - - def query_int_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) @@ -55,7 +50,7 @@ def query_int_attribute(self, target, displays, attr): def set_int_attribute(self, target, displays, attr, value): - """return the value of an integer attribute""" + """set the value of an integer attribute""" display_mask = _displays2mask(displays) reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), @@ -68,7 +63,7 @@ def set_int_attribute(self, target, displays, attr, value): def query_string_attribute(self, target, displays, attr): - """return the value of an integer attribute""" + """return the value of a string attribute""" display_mask = _displays2mask(displays) reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), @@ -95,6 +90,38 @@ def query_valid_attr_values(self, target, displays, attr): return int(reply._data.get('min')), int(reply._data.get('max')) +def query_binary_data(self, target, displays, attr): + """return binary data""" + display_mask = _displays2mask(displays) + 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): + display_mask = _displays2mask([]) + reply = NVCtrlQueryListCard32ReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) + if not reply._data.get('flags'): + return None + return reply._data.get('list') + + +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): """the GPU product name on which the specified X screen is running""" return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) @@ -297,6 +324,8 @@ 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) @@ -322,6 +351,7 @@ def init(disp, info): get_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_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) @@ -5155,6 +5185,27 @@ def __init__(self, nfan=0): self._name = 'Cooler' +class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryTargetCount), + rq.RequestLength(), + rq.Card32('target_type'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('padb1'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('count'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.Card32('pad8'), + ) + + class NVCtrlQueryAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), @@ -5229,31 +5280,59 @@ class NVCtrlQueryStringAttributeReplyRequest(rq.ReplyRequest): ) -class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): +class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), - rq.Opcode(X_nvCtrlQueryTargetCount), + rq.Opcode(X_nvCtrlQueryValidAttributeValues), rq.RequestLength(), - rq.Card32('target_type'), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), - rq.Card8('padb1'), + rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Card32('count'), + rq.Card32('flags'), + rq.Int32('attr_type'), + rq.Int32('min'), + rq.Int32('max'), + rq.Card32('bits'), + rq.Card32('perms'), + ) + + +class NVCtrlQueryBinaryDataReplyRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryBinaryData), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Card32('data', 4), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), - rq.Card32('pad8'), + rq.Binary('data'), ) -class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): +class NVCtrlQueryListCard32ReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), - rq.Opcode(X_nvCtrlQueryValidAttributeValues), + rq.Opcode(X_nvCtrlQueryBinaryData), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), @@ -5266,9 +5345,10 @@ class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), - rq.Int32('attr_type'), - rq.Int32('min'), - rq.Int32('max'), - rq.Card32('bits'), - rq.Card32('perms'), + rq.Card32('list', 4), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.List('list', rq.Card32), ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index bde1be31..c9edaa91 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -75,6 +75,7 @@ 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), + 'get_coolers_used_by_gpu': display.nvcontrol_get_coolers_used_by_gpu(gpu), 'get_max_displays': display.nvcontrol_get_max_displays(gpu), 'get_name': display.nvcontrol_get_name(gpu), 'get_driver_version': display.nvcontrol_get_driver_version(gpu), From f9819f26fb40d6d98c1178e0a8729b5762871db6 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 21:38:48 +0100 Subject: [PATCH 019/100] NV-CONTROL: returning parsed data for gpu usage and perf modes --- Xlib/ext/nvcontrol.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 368c266b..f4070463 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -142,11 +142,26 @@ def get_gpu_uuid(self, target): def get_gpu_utilization(self, target): - return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + string = query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + result = {} + if string is not None and string != '': + for line in string.split(','): + key_value = line.split('=') + result[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + return result def get_performance_modes(self, target): - return query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + string = query_string_attribute(self, target, [], 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('=') + perf_dict[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + result.append(perf_dict) + return result def get_vram(self, target): From 8799e4d384787fee2ea3a91936eaa6d024cb25f2 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 21:47:16 +0100 Subject: [PATCH 020/100] NV-CONTROL: removed commented code --- Xlib/ext/nvcontrol.py | 15 --------------- examples/nvcontrol.py | 5 ----- 2 files changed, 20 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index f4070463..ffd7f77a 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -294,21 +294,6 @@ def get_max_displays(self, target): return query_int_attribute(self, target, [], NV_CTRL_MAX_DISPLAYS) -# def get_connected_displays(self, target): -# """Return an array with connected display numbers""" -# return query_int_attribute(self, target, [], NV_CTRL_CONNECTED_DISPLAYS) -# -# -# def get_enabled_displays(self, target): -# """returns an array of displays that are enabled on the specified X -# screen or GPU.""" -# return query_int_attribute(self, target, [], NV_CTRL_ENABLED_DISPLAYS) - -# def get_current_clocks(self, target): -# """return the current (GPU, memory) clocks of the graphics device -# driving the X screen.""" -# return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_CLOCK_FREQS) - def _displaystr2num(st): """return a display number from a string""" num = None diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index c9edaa91..f8f9be7e 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -89,9 +89,4 @@ pprint(dic) - # display.nvcontrol_set_cooler_manual_control_enabled(gpu, True) - # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) - # display.nvcontrol_set_cooler_manual_control_enabled(gpu, False) - # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) - display.close() From 7753247eb97a6a224e9a1bfd94a2364bbf6ff282 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 22:12:25 +0100 Subject: [PATCH 021/100] NV-CONTROL: set offset for gpu and memory clock --- Xlib/ext/nvcontrol.py | 100 ++++++++++++++++++++++-------------------- examples/nvcontrol.py | 6 ++- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index ffd7f77a..5d3bccde 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -35,9 +35,8 @@ def query_target_count(self, target): return int(reply._data.get('count')) -def query_int_attribute(self, target, displays, attr): +def query_int_attribute(self, target, display_mask, attr): """return the value of an integer attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -49,9 +48,8 @@ def query_int_attribute(self, target, displays, attr): return int(reply._data.get('value')) -def set_int_attribute(self, target, displays, attr, value): +def set_int_attribute(self, target, display_mask, attr, value): """set the value of an integer attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -59,12 +57,11 @@ def set_int_attribute(self, target, displays, attr, value): display_mask=display_mask, attr=attr, value=value) - return reply._data.get('flags') + return reply._data.get('flags') != 0 -def query_string_attribute(self, target, displays, attr): +def query_string_attribute(self, target, display_mask, attr): """return the value of a string attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -76,9 +73,8 @@ def query_string_attribute(self, target, displays, attr): return str(reply._data.get('string')).strip('\0') -def query_valid_attr_values(self, target, displays, attr): +def query_valid_attr_values(self, target, display_mask, attr): """return the value of an integer attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -90,9 +86,8 @@ def query_valid_attr_values(self, target, displays, attr): return int(reply._data.get('min')), int(reply._data.get('max')) -def query_binary_data(self, target, displays, attr): +def query_binary_data(self, target, display_mask, attr): """return binary data""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -105,12 +100,11 @@ def query_binary_data(self, target, displays, attr): def get_coolers_used_by_gpu(self, target): - display_mask = _displays2mask([]) reply = NVCtrlQueryListCard32ReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), - display_mask=display_mask, + display_mask=0, attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) if not reply._data.get('flags'): return None @@ -124,25 +118,25 @@ def get_gpu_count(self): def get_name(self, target): """the GPU product name on which the specified X screen is running""" - return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_PRODUCT_NAME) def get_driver_version(self, target): """the NVIDIA (kernel level) driver version for the specified screen or GPU""" - return query_string_attribute(self, target, [], NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) def get_vbios_version(self, target): """the version of the VBIOS for the specified screen or GPU""" - return query_string_attribute(self, target, [], NV_CTRL_STRING_VBIOS_VERSION) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_VBIOS_VERSION) def get_gpu_uuid(self, target): - return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UUID) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UUID) def get_gpu_utilization(self, target): - string = query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + 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(','): @@ -152,7 +146,7 @@ def get_gpu_utilization(self, target): def get_performance_modes(self, target): - string = query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + 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(';'): @@ -165,18 +159,18 @@ def get_performance_modes(self, target): def get_vram(self, target): - return query_int_attribute(self, target, [], NV_CTRL_VIDEO_RAM) + 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, [], NV_CTRL_IRQ) + return query_int_attribute(self, target, 0, NV_CTRL_IRQ) def supports_framelock(self, target): """returns 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, [], NV_CTRL_FRAMELOCK) == 1 + return query_int_attribute(self, target, 0, NV_CTRL_FRAMELOCK) == 1 def gvo_supported(self, screen): @@ -187,102 +181,110 @@ def gvo_supported(self, screen): def get_core_temp(self, target): """return the current core temperature of the GPU driving the X screen.""" - return query_int_attribute(self, target, [], NV_CTRL_GPU_CORE_TEMPERATURE) + 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, [], NV_CTRL_GPU_CORE_THRESHOLD) + 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, [], NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD) + 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, [], NV_CTRL_GPU_MAX_CORE_THRESHOLD) + 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, [], NV_CTRL_AMBIENT_TEMPERATURE) + return query_int_attribute(self, target, 0, NV_CTRL_AMBIENT_TEMPERATURE) def get_cuda_cores(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_CORES) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORES) def get_memory_bus_width(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_MEMORY_BUS_WIDTH) + 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, [], NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY) + 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, [], NV_CTRL_USED_DEDICATED_GPU_MEMORY) + return query_int_attribute(self, target, 0, NV_CTRL_USED_DEDICATED_GPU_MEMORY) def get_pcie_current_link_width(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) def get_pcie_max_link_width(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) def get_pcie_generation(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_GENERATION) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_GENERATION) def get_video_encoder_utilization(self, target): - return query_int_attribute(self, target, [], NV_CTRL_VIDEO_ENCODER_UTILIZATION) + return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_ENCODER_UTILIZATION) def get_video_decoder_utilization(self, target): - return query_int_attribute(self, target, [], NV_CTRL_VIDEO_DECODER_UTILIZATION) + 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, [], NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL) + 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 get_gpu_nvclock_offset(self, target): - return query_int_attribute(self, target, [], 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): - return query_valid_attr_values(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) + return query_valid_attr_values(self, target, 0, 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 get_mem_transfer_rate_offset(self, target): - return query_int_attribute(self, target, [], 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): - return query_valid_attr_values(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) + return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) def get_cooler_manual_control_enabled(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 + return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 def set_cooler_manual_control_enabled(self, target, enabled): - return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + 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, [], NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) + return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) def get_fan_rpm(self, target): - return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_SPEED) + return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_SPEED) def get_max_displays(self, target): @@ -291,7 +293,7 @@ def get_max_displays(self, target): 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, [], NV_CTRL_MAX_DISPLAYS) + return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS) def _displaystr2num(st): @@ -346,7 +348,9 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_video_decoder_utilization', get_video_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) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index f8f9be7e..36b61cfd 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -50,6 +50,8 @@ gpu = Gpu(0) fan = Cooler(0) + perf_level = 3 + dic = { 'get_gpu_count': display.nvcontrol_get_gpu_count(), 'get_vram': display.nvcontrol_get_vram(gpu), @@ -70,8 +72,8 @@ 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), - 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), - 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), + 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu, perf_level), + 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu, perf_level), 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), From 166e05a7c69b99a5b6e9d9f57fd3cad28c7ac864 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Mon, 28 Jan 2019 19:39:03 +0100 Subject: [PATCH 022/100] NV-CONTROL: small code refactoring --- Xlib/ext/nvcontrol.py | 20 ++++++++++---------- examples/nvcontrol.py | 8 ++++---- examples/xinerama.py | 8 ++++---- examples/xrandr.py | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 5d3bccde..6402214a 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -140,8 +140,8 @@ def get_gpu_utilization(self, target): result = {} if string is not None and string != '': for line in string.split(','): - key_value = line.split('=') - result[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + [key, value] = line.split('=')[:2] + result[key.strip()] = int(value) if value.isdigit() else value return result @@ -152,8 +152,8 @@ def get_performance_modes(self, target): for perf in string.split(';'): perf_dict = {} for line in perf.split(','): - key_value = line.split('=') - perf_dict[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + [key, value] = line.split('=')[:2] + perf_dict[key.strip()] = int(value) if value.isdigit() else value result.append(perf_dict) return result @@ -288,11 +288,11 @@ def get_fan_rpm(self, target): def get_max_displays(self, target): - """return the maximum number of display devices that can be driven - simultaneously on a GPU (e.g., that can be used in a MetaMode at once). - 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 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) @@ -5159,7 +5159,7 @@ def type(self): return self._type def __str__(self): - return '' % (self._name, self.id()) + return ''.format(self._name, self.id()) class Gpu(Target): diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index 36b61cfd..d50d0ea7 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -40,11 +40,11 @@ display = Display() # Check for extension if not display.has_extension('NV-CONTROL'): - sys.stderr.write('%s: server does not have the NV-CONTROL extension\n' - % sys.argv[0]) - print(display.query_extension('NV-CONTROL')) + sys.stderr.write('{}: server does not have the NV-CONTROL extension\n'.format(sys.argv[0])) + ext = display.query_extension('NV-CONTROL') + print(ext) sys.stderr.write("\n".join(display.list_extensions())) - if display.query_extension('NV-CONTROL') is None: + if ext is None: sys.exit(1) gpu = Gpu(0) diff --git a/examples/xinerama.py b/examples/xinerama.py index d635cfd9..13419ba9 100755 --- a/examples/xinerama.py +++ b/examples/xinerama.py @@ -42,11 +42,11 @@ def __init__(self, display): # Check for extension if not self.d.has_extension('XINERAMA'): - sys.stderr.write('%s: server does not have the XINERAMA extension\n' - % sys.argv[0]) - print(self.d.query_extension('XINERAMA')) + sys.stderr.write('{}: server does not have the XINERAMA extension\n'.format(sys.argv[0])) + ext = self.d.query_extension('XINERAMA') + print(ext) sys.stderr.write("\n".join(self.d.list_extensions())) - if self.d.query_extension('XINERAMA') is None: + if ext is None: sys.exit(1) # print version diff --git a/examples/xrandr.py b/examples/xrandr.py index 30176b47..5a645340 100755 --- a/examples/xrandr.py +++ b/examples/xrandr.py @@ -42,11 +42,11 @@ def __init__(self, display): # Check for extension if not self.d.has_extension('RANDR'): - sys.stderr.write('%s: server does not have the RANDR extension\n' - % sys.argv[0]) - print(self.d.query_extension('RANDR')) + sys.stderr.write('{}: server does not have the RANDR extension\n'.format(sys.argv[0])) + ext = self.d.query_extension('RANDR') + print(ext) sys.stderr.write("\n".join(self.d.list_extensions())) - if self.d.query_extension('RANDR') is None: + if ext is None: sys.exit(1) # print(version) From fb511490f3b48ff652189d5d2589a530ad5f3cab Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 2 Feb 2019 10:59:14 +0100 Subject: [PATCH 023/100] Making doc strings complaint with PEP-0257 --- Xlib/ext/nvcontrol.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 6402214a..dd9de6c4 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -168,14 +168,16 @@ def get_irq(self, target): def supports_framelock(self, target): - """returns whether the underlying GPU supports Frame Lock. All of the - other frame lock attributes are only applicable if this returns True.""" + """returns 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): - """returns whether this X screen supports GVO; if this screen does not - support GVO output, then all other GVO attributes are unavailable.""" + """returns 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) @@ -185,9 +187,9 @@ def get_core_temp(self, target): 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 the current GPU core slowdown threshold temperature. + + Itreflects the temperature at which the GPU is throttled to prevent overheating.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_THRESHOLD) @@ -202,8 +204,7 @@ def get_max_core_threshold(self, target): def get_ambient_temp(self, target): - """return the current temperature in the immediate neighbourhood of - the GPU driving the X screen.""" + """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) From 1e230f395fc3d48d358760f3d9bc0d2f13c383ef Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 2 Feb 2019 15:33:23 +0100 Subject: [PATCH 024/100] NV-CONTROL: Set fan duty --- Xlib/ext/nvcontrol.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index dd9de6c4..ec5c40fe 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -108,7 +108,11 @@ def get_coolers_used_by_gpu(self, target): attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) if not reply._data.get('flags'): return None - return reply._data.get('list') + fans = reply._data.get('list') + if len(fans) > 1: + return fans[1:] + else: + return None def get_gpu_count(self): @@ -284,6 +288,10 @@ 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) @@ -355,6 +363,7 @@ def init(disp, info): 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) From 0c3f593a89b81b8fd87b3d5fcad424f528e5bb49 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 17:26:46 +0300 Subject: [PATCH 025/100] Amend the rest of doc strings according to PEP-0257 --- Xlib/ext/nvcontrol.py | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index ec5c40fe..f1bdd8ba 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -28,7 +28,7 @@ def query_target_count(self, target): - """return the target count""" + """Return the target count""" reply = NVCtrlQueryTargetCountReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_type=target.type()) @@ -36,7 +36,7 @@ def query_target_count(self, target): def query_int_attribute(self, target, display_mask, attr): - """return the value of an integer attribute""" + """Return the value of an integer attribute""" reply = NVCtrlQueryAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -49,7 +49,7 @@ def query_int_attribute(self, target, display_mask, attr): def set_int_attribute(self, target, display_mask, attr, value): - """set the value of an integer attribute""" + """Set the value of an integer attribute""" reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -61,7 +61,7 @@ def set_int_attribute(self, target, display_mask, attr, value): def query_string_attribute(self, target, display_mask, attr): - """return the value of a string attribute""" + """Return the value of a string attribute""" reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -74,7 +74,7 @@ def query_string_attribute(self, target, display_mask, attr): def query_valid_attr_values(self, target, display_mask, attr): - """return the value of an integer attribute""" + """Return the value of an integer attribute""" reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -87,7 +87,7 @@ def query_valid_attr_values(self, target, display_mask, attr): def query_binary_data(self, target, display_mask, attr): - """return binary data""" + """Return binary data""" reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -121,17 +121,17 @@ def get_gpu_count(self): def get_name(self, target): - """the GPU product name on which the specified X screen is running""" + """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): - """the NVIDIA (kernel level) driver version for the specified screen or GPU""" + """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): - """the version of the VBIOS for the specified screen or GPU""" + """Return the version of the VBIOS for the specified screen or GPU""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_VBIOS_VERSION) @@ -172,43 +172,46 @@ def get_irq(self, target): def supports_framelock(self, target): - """returns whether the underlying GPU supports Frame Lock. + """Return whether the underlying GPU supports Frame Lock. - All of the other frame lock attributes are only applicable if this returns True.""" + 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): - """returns whether this X screen supports GVO + """Return whether this X screen supports GVO - If this screen does not support GVO output, then all other GVO attributes are unavailable.""" + 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 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. + """Return the current GPU core slowdown threshold temperature. - Itreflects the temperature at which the GPU is throttled to prevent overheating.""" + 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 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 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 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) @@ -297,16 +300,17 @@ def get_fan_rpm(self, target): def get_max_displays(self, target): - """return the maximum number of display devices that can be driven simultaneously on a GPU. + """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.""" + in use. + """ return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS) def _displaystr2num(st): - """return a display number from a string""" + """Return a display number from a string""" num = None for s, n in [('DFP-', 16), ('TV-', 8), ('CRT-', 0)]: if st.startswith(s): @@ -324,7 +328,7 @@ def _displaystr2num(st): def _displays2mask(displays): - """return a display mask from an array of display numbers.""" + """Return a display mask from an array of display numbers.""" mask = 0 for d in displays: mask += (1 << _displaystr2num(d)) From c55dcac4e4bc22cd345c1598b6355ad1331e2f84 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Feb 2019 18:09:12 +0100 Subject: [PATCH 026/100] fix increasing memory usage on display instantiation Move finalized classes for resource types at the instance level, to avoid creating recursive class hierarchies. --- CHANGELOG.md | 9 +++++++++ Xlib/display.py | 2 +- Xlib/protocol/display.py | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fae403f..7c93b76e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +In development +============== + +Bug Fixes +--------- + +- fix increasing memory usage on display instantiation + +--- Version 0.24 ============ diff --git a/Xlib/display.py b/Xlib/display.py index 622e0a2a..beaeaad6 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -62,12 +62,12 @@ } class _BaseDisplay(protocol_display.Display): - resource_classes = _resource_baseclasses.copy() # Implement a cache of atom names, used by Window objects when # dealing with some ICCCM properties not defined in Xlib.Xatom def __init__(self, *args, **keys): + self.resource_classes = _resource_baseclasses.copy() protocol_display.Display.__init__(self, *args, **keys) self._atom_cache = {} diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index ce0413cd..2f8a9e24 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -76,7 +76,6 @@ def bytesview(data, offset=0, size=None): class Display(object): - resource_classes = {} extension_major_opcodes = {} error_classes = error.xerror_class.copy() event_classes = event.event_class.copy() From 89abb403755fc9b835f8570799fcab133298693e Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 23:32:21 +0300 Subject: [PATCH 027/100] Bump version, add NV-CONTROL extension to change log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c93b76e..3a0b0e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ NEWS for Python X Library -In development +Version 0.25 ============== Bug Fixes --------- - fix increasing memory usage on display instantiation +- implement NV-CONTROL extension by Roberto Leinardi (@leinardi) --- Version 0.24 From 501e15c6515d4e0e1585c858689fb3876a2be753 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 23:32:52 +0300 Subject: [PATCH 028/100] Cosmetic change --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0b0e5c..17e875b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ NEWS for Python X Library Version 0.25 -============== +============ Bug Fixes --------- From a8f6c733068ca96aa0f262295eb2376e783b005d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 23:34:36 +0300 Subject: [PATCH 029/100] Move extension note to separate section --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17e875b8..6711de85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ Bug Fixes --------- - fix increasing memory usage on display instantiation -- implement NV-CONTROL extension by Roberto Leinardi (@leinardi) + +NV-CONTROL extension +-------------------- + +- add first implementation by Roberto Leinardi (@leinardi) --- Version 0.24 From 3e98bd91079dde1482a845968ded9c80b011fce9 Mon Sep 17 00:00:00 2001 From: Vasily V Ryabov Date: Sun, 3 Feb 2019 23:57:56 +0300 Subject: [PATCH 030/100] Bump version in __init__.py --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index c290d9ad..f023f80b 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 24) +__version__ = (0, 25) __version_extra__ = '' From 10056bad2d44c10294596efe712739f1b17bed90 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 9 Feb 2019 11:00:48 +0100 Subject: [PATCH 031/100] NV-CONTROL: Returning None if Coolbit 4 is not set Previously it was not possible to know if the manual control was simply disabled or if the coolbit 4 was not set at all. Now the function returns None if the coolbit is not set at all or a boolean if is set. --- Xlib/ext/nvcontrol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index f1bdd8ba..30f9c345 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -280,7 +280,7 @@ def get_mem_transfer_rate_offset_range(self, target): def get_cooler_manual_control_enabled(self, target): - return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 + return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) def set_cooler_manual_control_enabled(self, target, enabled): From d5d0fab1a545425b12683376771f5171c8e8a1fb Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 10 Feb 2019 16:45:53 +0100 Subject: [PATCH 032/100] NV-CONTROL: Allow to specify perf level for get offset range --- Xlib/ext/nvcontrol.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 30f9c345..c4120b66 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -263,8 +263,8 @@ 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): - return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_NVCLOCK_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): @@ -275,8 +275,8 @@ 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): - return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_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): From 8fdbcc6307b71baeb6ee0e80879ac7f12c623f73 Mon Sep 17 00:00:00 2001 From: Mohit Garg Date: Mon, 11 Feb 2019 16:51:59 +0530 Subject: [PATCH 033/100] damage extension example --- examples/xdamage.py | 133 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 examples/xdamage.py diff --git a/examples/xdamage.py b/examples/xdamage.py new file mode 100644 index 00000000..eff4ba43 --- /dev/null +++ b/examples/xdamage.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# examples/xdamage.py -- demonstrate damage extension +# +# Copyright (C) 2002 Peter Liljenberg +# +# 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 + + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +import os + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +from Xlib import display, X, threaded,Xutil +import time +import thread +from Xlib.ext import damage +from PIL import Image, ImageTk + +def redraw(win, gc): + # win.clear_area() + win.fill_rectangle(gc, 0, 0, 60, 60) + +def blink(display, win, gc, cols): + while 1: + time.sleep(2) + print('Changing color', cols[0]) + gc.change(foreground = cols[0]) + cols = (cols[1], cols[0]) + redraw(win, gc) + display.flush() + +def getImageFromWin(win,ptW,ptH,ptX=0,ptY=0): + try: + raw = win.get_image(ptX,ptY, ptW,ptH, X.ZPixmap, 0xffffffff) + image = Image.frombytes("RGB", (ptW, ptH), raw.data, "raw", "BGRX") + return image + + except Exception: + print("exception thrown in getImageFromWin") + +def checkExt(disp): + # Check for extension + if not disp.has_extension('DAMAGE'): + sys.stderr.write('server does not have the DAMAGE extension\n') + sys.stderr.write("\n".join(disp.list_extensions())) + + if disp.query_extension('DAMAGE') is None: + sys.exit(1) + else: + r = disp.damage_query_version() + print('DAMAGE version %d.%d' % (r.major_version, r.minor_version)) + +def main(): + d = display.Display() + root = d.screen().root + + checkExt(d) + colormap = d.screen().default_colormap + + red = colormap.alloc_named_color("red").pixel + blue = colormap.alloc_named_color("blue").pixel + background = colormap.alloc_named_color("white").pixel + + window1 = root.create_window(100, 100, 250, 100, 1, + X.CopyFromParent, X.InputOutput, + X.CopyFromParent, + background_pixel = background, + event_mask = X.StructureNotifyMask | X.ExposureMask) + window1.set_wm_name('Changing Window') + window1.map() + gc = window1.create_gc(foreground = red) + + thread.start_new_thread(blink, (d, window1, gc, (blue, red))) + + window1.damage_create(damage.DamageReportRawRectangles) + window1.set_wm_normal_hints( + flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), + min_width=50, + min_height=50 + ) + + window2 = root.create_window(100, 250, 250, 100, 1, + X.CopyFromParent, X.InputOutput, + X.CopyFromParent, + background_pixel = background, + event_mask = X.StructureNotifyMask | X.ExposureMask) + window2.set_wm_normal_hints( + flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), + min_width=50, + min_height=50 + ) + + window2.set_wm_name('Tracking Window') + window2.map() + + while 1: + event = d.next_event() + if event.type == X.Expose: + if event.count == 0: + redraw(window1, gc) + elif event.type == d.extension_event.DamageNotify: + image = getImageFromWin(window1, event.area.width, event.area.height, event.area.x, event.area.y) + bgpm = window2.create_pixmap(image.width,image.height,d.screen().root_depth) + bggc = window2.create_gc(foreground=0,background=0) + bgpm.put_pil_image(bggc, 0, 0, image) + window2.copy_area(bggc, bgpm, 0, 0, image.width, image.height, 0, 0) + # bggc.free() + elif event.type == X.DestroyNotify: + sys.exit(0) + +if __name__ == "__main__": + main() \ No newline at end of file From ba2ce85849ce9968c11152a14e692fe5f224844c Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Thu, 14 Feb 2019 09:15:26 +0530 Subject: [PATCH 034/100] made the changes as suggested in the review --- examples/xdamage.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index eff4ba43..646aedf1 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -2,7 +2,7 @@ # # examples/xdamage.py -- demonstrate damage extension # -# Copyright (C) 2002 Peter Liljenberg +# Copyright (C) 2019 Mohit Garg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License @@ -36,6 +36,7 @@ import thread from Xlib.ext import damage from PIL import Image, ImageTk +import traceback def redraw(win, gc): # win.clear_area() @@ -50,14 +51,14 @@ def blink(display, win, gc, cols): redraw(win, gc) display.flush() -def getImageFromWin(win,ptW,ptH,ptX=0,ptY=0): +def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): try: raw = win.get_image(ptX,ptY, ptW,ptH, X.ZPixmap, 0xffffffff) image = Image.frombytes("RGB", (ptW, ptH), raw.data, "raw", "BGRX") return image except Exception: - print("exception thrown in getImageFromWin") + traceback.print_exc() def checkExt(disp): # Check for extension @@ -69,7 +70,7 @@ def checkExt(disp): sys.exit(1) else: r = disp.damage_query_version() - print('DAMAGE version %d.%d' % (r.major_version, r.minor_version)) + print('DAMAGE version %d.%d'.format(r.major_version, r.minor_version)) def main(): d = display.Display() @@ -120,9 +121,9 @@ def main(): if event.count == 0: redraw(window1, gc) elif event.type == d.extension_event.DamageNotify: - image = getImageFromWin(window1, event.area.width, event.area.height, event.area.x, event.area.y) - bgpm = window2.create_pixmap(image.width,image.height,d.screen().root_depth) - bggc = window2.create_gc(foreground=0,background=0) + image = get_image_from_win(window1, event.area.width, event.area.height, event.area.x, event.area.y) + bgpm = window2.create_pixmap(image.width, image.height, d.screen().root_depth) + bggc = window2.create_gc(foreground=0, background=0) bgpm.put_pil_image(bggc, 0, 0, image) window2.copy_area(bggc, bgpm, 0, 0, image.width, image.height, 0, 0) # bggc.free() @@ -130,4 +131,4 @@ def main(): sys.exit(0) if __name__ == "__main__": - main() \ No newline at end of file + main() From e98474e7c735c699402cc59f8348c512dfe06efd Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Thu, 14 Feb 2019 09:22:35 +0530 Subject: [PATCH 035/100] correcting the usage of string format command --- examples/xdamage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 646aedf1..898c7a89 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -70,7 +70,7 @@ def checkExt(disp): sys.exit(1) else: r = disp.damage_query_version() - print('DAMAGE version %d.%d'.format(r.major_version, r.minor_version)) + print('DAMAGE version {}.{}'.format(r.major_version, r.minor_version)) def main(): d = display.Display() From 2392580cd71e69e9b7b3ba88ff10c50ab0a5e658 Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Fri, 15 Feb 2019 16:38:56 +0530 Subject: [PATCH 036/100] function name checkExt->check_ext --- examples/xdamage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 898c7a89..91161578 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -60,7 +60,7 @@ def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): except Exception: traceback.print_exc() -def checkExt(disp): +def check_ext(disp): # Check for extension if not disp.has_extension('DAMAGE'): sys.stderr.write('server does not have the DAMAGE extension\n') From 88c038d4afb6640aed797f2ef5da03dd813517b9 Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Fri, 15 Feb 2019 22:11:22 +0530 Subject: [PATCH 037/100] Update xdamage.py --- examples/xdamage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 91161578..5a57b386 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -76,7 +76,7 @@ def main(): d = display.Display() root = d.screen().root - checkExt(d) + check_ext(d) colormap = d.screen().default_colormap red = colormap.alloc_named_color("red").pixel From 865f26f07e5f224017a619907d1ed7831e312ee4 Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Fri, 15 Feb 2019 23:49:25 +0530 Subject: [PATCH 038/100] removed all the debug print messages --- Xlib/ext/damage.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py index eeb7340b..0cde5ed0 100644 --- a/Xlib/ext/damage.py +++ b/Xlib/ext/damage.py @@ -94,7 +94,6 @@ def damage_create(self, level): drawable=self.id, level=level, ) - print('damage create') return did class DamageDestroy(rq.Request): @@ -111,7 +110,6 @@ def damage_destroy(self, damage): ) self.display.free_resource_id(damage) - print('damage destroy') class DamageSubtract(rq.Request): _request = rq.Struct(rq.Card8('opcode'), @@ -128,7 +126,6 @@ def damage_subtract(self, damage, repair=X.NONE, parts=X.NONE): damage=damage, repair=repair, parts=parts) - print('damage subtract') class DamageAdd(rq.Request): _request = rq.Struct(rq.Card8('opcode'), @@ -143,7 +140,6 @@ def damage_add(self, repair, parts): opcode=self.display.get_extension_major(extname), repair=repair, parts=parts) - print('damage add') # Events # From 2dde795cc2192d905b4e18e4ccf96c82cd0c7e8f Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 16 Feb 2019 11:26:07 +0100 Subject: [PATCH 039/100] NV-CONTROL: add Clock info and aligned method names to NVML --- Xlib/ext/nvcontrol.py | 35 +++++++++++++++++++++++------------ examples/nvcontrol.py | 17 +++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index c4120b66..3060d247 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -139,7 +139,7 @@ def get_gpu_uuid(self, target): return query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UUID) -def get_gpu_utilization(self, target): +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 != '': @@ -162,6 +162,16 @@ def get_performance_modes(self, target): 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) @@ -231,23 +241,23 @@ def get_used_dedicated_gpu_memory(self, target): return query_int_attribute(self, target, 0, NV_CTRL_USED_DEDICATED_GPU_MEMORY) -def get_pcie_current_link_width(self, target): +def get_curr_pcie_link_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) -def get_pcie_max_link_width(self, target): +def get_max_pcie_link_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) -def get_pcie_generation(self, target): +def get_curr_pcie_link_generation(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_GENERATION) -def get_video_encoder_utilization(self, target): +def get_encoder_utilization(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_ENCODER_UTILIZATION) -def get_video_decoder_utilization(self, target): +def get_decoder_utilization(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_DECODER_UTILIZATION) @@ -354,11 +364,11 @@ def init(disp, info): 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_pcie_current_link_width', get_pcie_current_link_width) - disp.extension_add_method('display', 'nvcontrol_get_pcie_max_link_width', get_pcie_max_link_width) - disp.extension_add_method('display', 'nvcontrol_get_pcie_generation', get_pcie_generation) - disp.extension_add_method('display', 'nvcontrol_get_video_encoder_utilization', get_video_encoder_utilization) - disp.extension_add_method('display', 'nvcontrol_get_video_decoder_utilization', get_video_decoder_utilization) + 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) @@ -375,8 +385,9 @@ def init(disp, info): 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_gpu_utilization', get_gpu_utilization) + 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', diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index d50d0ea7..dece439f 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -66,11 +66,11 @@ 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), - 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), - 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), - 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), - 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), - 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), + 'get_curr_pcie_link_width': display.nvcontrol_get_curr_pcie_link_width(gpu), + 'get_max_pcie_link_width': display.nvcontrol_get_max_pcie_link_width(gpu), + 'get_curr_pcie_link_generation': display.nvcontrol_get_curr_pcie_link_generation(gpu), + 'get_encoder_utilization': display.nvcontrol_get_encoder_utilization(gpu), + 'get_decoder_utilization': display.nvcontrol_get_decoder_utilization(gpu), 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu, perf_level), 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu, perf_level), @@ -83,10 +83,11 @@ 'get_driver_version': display.nvcontrol_get_driver_version(gpu), 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), - 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), + 'get_utilization_rates': display.nvcontrol_get_utilization_rates(gpu), 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu), - 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu), - 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu) + 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu, perf_level), + 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu, perf_level), + 'get_clock_info': display.nvcontrol_get_clock_info(gpu) } pprint(dic) From b8aa85cfae5c0b3c4b5a72b877727b9277649bcd Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 19 May 2019 21:05:45 -0400 Subject: [PATCH 040/100] XFixes: add XFixesSelectionNotify events These events can be used to tell when the owner of the clipboard selection has changed. Add an example that demonstrates usage. --- Xlib/ext/xfixes.py | 57 +++++++++++++++++++- examples/xfixes-selection-notify.py | 82 +++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100755 examples/xfixes-selection-notify.py diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 72feb6d4..5f2f6438 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -22,13 +22,22 @@ ''' A partial implementation of the XFIXES extension. Only the HideCursor and -ShowCursor requests are provided. +ShowCursor requests and SelectionNotify events are provided. ''' from Xlib.protocol import rq extname = 'XFIXES' +XFixesSelectionNotify = 0 + +XFixesSetSelectionOwnerNotifyMask = (1 << 0) +XFixesSelectionWindowDestroyNotifyMask = (1 << 1) +XFixesSelectionClientCloseNotifyMask = (1 << 2) + +XFixesSetSelectionOwnerNotify = 0 +XFixesSelectionWindowDestroyNotify = 1 +XFixesSelectionClientCloseNotify = 2 class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), @@ -80,8 +89,54 @@ def show_cursor(self): opcode=self.display.get_extension_major(extname), window=self) +class SelectSelectionInput(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + rq.Window('window'), + rq.Card32('selection'), + rq.Card32('mask') + ) + +def select_selection_input(self, window, selection, mask): + return SelectSelectionInput(opcode=self.display.get_extension_major(extname), + display=self.display, + window=window, + selection=selection, + mask=mask) + + +class SelectionNotify(rq.Event): + _code = None + _fields = rq.Struct(rq.Card8('type'), + rq.Card8('sub_code'), + rq.Card16('sequence_number'), + rq.Window('window'), + rq.Window('owner'), + rq.Card32('selection'), + rq.Card32('timestamp'), + rq.Card32('selection_timestamp'), + rq.Pad(8)) + + +class SetSelectionOwnerNotify(SelectionNotify): + pass + + +class SelectionWindowDestroyNotify(SelectionNotify): + pass + + +class SelectionClientCloseNotify(SelectionNotify): + pass + def init(disp, info): + disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input) disp.extension_add_method('display', 'xfixes_query_version', query_version) disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) + + disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify) + disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify) + disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify) diff --git a/examples/xfixes-selection-notify.py b/examples/xfixes-selection-notify.py new file mode 100755 index 00000000..6fa3f118 --- /dev/null +++ b/examples/xfixes-selection-notify.py @@ -0,0 +1,82 @@ +#!/usr/bin/python3 +# +# examples/xfixes-selection-notify.py -- demonstrate the XFIXES extension +# SelectionNotify event. +# +# Copyright (C) 2019 +# Tony Crisci +# +# 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 + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +import os +import time + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +from Xlib.display import Display +from Xlib.ext import xfixes + +def main(argv): + if len(sys.argv) < 2 or len(sys.argv) > 3: + sys.exit('usage: {0} SELECTION\n\n' + 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' + .format(sys.argv[0])) + + display = Display() + + sel_name = sys.argv[1] + sel_atom = display.get_atom(sel_name) + + if not display.has_extension('XFIXES'): + if display.query_extension('XFIXES') is None: + print('XFIXES extension not supported', file=sys.stderr) + return 1 + + xfixes_version = display.xfixes_query_version() + print('Found XFIXES version %s.%s' % ( + xfixes_version.major_version, + xfixes_version.minor_version, + ), file=sys.stderr) + + screen = display.screen() + + mask = xfixes.XFixesSetSelectionOwnerNotifyMask | \ + xfixes.XFixesSelectionWindowDestroyNotifyMask | \ + xfixes.XFixesSelectionClientCloseNotifyMask + + display.xfixes_select_selection_input(screen.root, sel_atom, mask) + + while True: + e = display.next_event() + print(e) + + if (e.type, e.sub_code) == display.extension_event.SetSelectionOwnerNotify: + print('SetSelectionOwner: owner=0x{0:08x}'.format(e.owner.id)) + elif (e.type, e.sub_code) == display.extension_event.SelectionWindowDestroyNotify: + print('SelectionWindowDestroy: owner=0x{0:08x}'.format(e.owner.id)) + elif (e.type, e.sub_code) == display.extension_event.SelectionClientCloseNotify: + print('SelectionClientClose: owner=0x{0:08x}'.format(e.owner.id)) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) From d1ca3c31a5443820803b821645b4315d6679054e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 23 May 2019 08:15:17 -0400 Subject: [PATCH 041/100] XFixes: simpler arg validation in selection example --- examples/xfixes-selection-notify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xfixes-selection-notify.py b/examples/xfixes-selection-notify.py index 6fa3f118..20728fbd 100755 --- a/examples/xfixes-selection-notify.py +++ b/examples/xfixes-selection-notify.py @@ -37,7 +37,7 @@ from Xlib.ext import xfixes def main(argv): - if len(sys.argv) < 2 or len(sys.argv) > 3: + if len(sys.argv) != 2: sys.exit('usage: {0} SELECTION\n\n' 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' .format(sys.argv[0])) From 4cb340def4b5ceebbe7efe740363b7e5c1dd3f4e Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 23 Jul 2019 14:25:35 -0700 Subject: [PATCH 042/100] examples: xdamage: fix NameErrors --- examples/xdamage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 5a57b386..3248a1ef 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -53,8 +53,8 @@ def blink(display, win, gc, cols): def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): try: - raw = win.get_image(ptX,ptY, ptW,ptH, X.ZPixmap, 0xffffffff) - image = Image.frombytes("RGB", (ptW, ptH), raw.data, "raw", "BGRX") + raw = win.get_image(pt_x, pt_y, pt_w, pt_h, X.ZPixmap, 0xffffffff) + image = Image.frombytes("RGB", (pt_w, pt_h), raw.data, "raw", "BGRX") return image except Exception: From ff757bee512c15db7e03bb957339e5e1d5d7315b Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 23 Jul 2019 14:25:53 -0700 Subject: [PATCH 043/100] examples: xdamage: fix Python3 compatibility --- examples/xdamage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 3248a1ef..46cbab9d 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -33,7 +33,12 @@ from Xlib import display, X, threaded,Xutil import time -import thread + +try: + import thread +except ModuleNotFoundError: + import _thread as thread + from Xlib.ext import damage from PIL import Image, ImageTk import traceback From f035a95370e3e231f8a60a08315fc4401e06a2c7 Mon Sep 17 00:00:00 2001 From: Gerardwx Date: Mon, 19 Aug 2019 15:35:20 -0400 Subject: [PATCH 044/100] Add check for older / non-compliant X servers --- Xlib/ext/xinput.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 1c95b54b..fee0d93c 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -647,8 +647,8 @@ def init(disp, info): disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) - - for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): - disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) - disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) - disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) + if hasattr(disp,"ge_add_event_data"): + for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): + disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) From e9d7fd34dc149e23312c0acdf4476842385d1daf Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 23 Oct 2019 05:24:30 +0200 Subject: [PATCH 045/100] Travis CI: Add Python 3.7 and 3.8 to the testing --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c54c9650..12858c99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ python: - "3.4" - "3.5" - "3.6" + - "3.7" + - "3.8" # command to install dependencies install: From a48536e136639cc0415713100b8b96d85c69d176 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 23 Oct 2019 10:32:10 +0200 Subject: [PATCH 046/100] Drop EOL Python 3.3 https://devguide.python.org/#status-of-python-branches --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12858c99..524f0998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" From 0432dc2462bc4fde9794da5d9872e1e61766d89b Mon Sep 17 00:00:00 2001 From: Vasily V Ryabov Date: Sun, 8 Dec 2019 14:54:12 +0300 Subject: [PATCH 047/100] Add 0.26 release notes and bump version. --- CHANGELOG.md | 19 +++++++++++++++++++ Xlib/__init__.py | 2 +- setup.cfg | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6711de85..1cd9e2a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ NEWS for Python X Library +Version 0.26 +============ + +Bug Fixes +--------- + +- support legacy X servers like RealVNC's one (by @Gerardwx) + +Extensions +-------------------- + +- enrich XFixes extension with XFixesSelectionNotify events (by @acrisci) +- add example xfixes-selection-notify.py (by @acrisci) +- fix two issues in NV-CONTROL extension (by @leinardi) +- add method get_clock_info into NV-CONTROL extension (by @leinardi) +- add default client version into Composite extension (by @jakogut) +- add Damage extension with the example (by @mgarg1 and @jakogut) + +--- Version 0.25 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index f023f80b..6164e53a 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 25) +__version__ = (0, 26) __version_extra__ = '' diff --git a/setup.cfg b/setup.cfg index ba1f408a..29a11ad0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,8 @@ classifiers = Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython Topic :: Software Development :: Libraries :: Python Modules Topic :: Software Development :: Libraries From 5665e46e6b9a17a8815f8ac45ed60249e3fd2b8c Mon Sep 17 00:00:00 2001 From: Sporif Date: Wed, 8 Jan 2020 21:14:53 +0000 Subject: [PATCH 048/100] NV-CONTROL: set offset for all perf levels --- Xlib/ext/nvcontrol.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 3060d247..7a21826c 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -273,6 +273,10 @@ 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 set_gpu_nvclock_offset_all_levels(self, target, offset): + return set_int_attribute(self, target, 0, NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS, 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) @@ -285,6 +289,10 @@ 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 set_mem_transfer_rate_offset_all_levels(self, target, offset): + return set_int_attribute(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS, 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) @@ -372,8 +380,10 @@ def init(disp, info): 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_set_gpu_nvclock_offset_all_levels', set_gpu_nvclock_offset_all_levels) 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_set_mem_transfer_rate_offset_all_levels', set_mem_transfer_rate_offset_all_levels) 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) From 1e5ff831b8be9ddf617a9a7ddb25e7928a533999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= Date: Sat, 21 Mar 2020 11:53:20 +0100 Subject: [PATCH 049/100] Fix TypeError in socket.error exception handling The socket.error, which is an alias to OSError since python 3.3, is not subscriptable (and its subclasses neither are). Hence, pass the entire exception message to close_internal(). In case of a socket.error in self.socket.send(), the former crashed with a TypeError. I strongly suspect that this closes issue #127. --- Xlib/protocol/display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 2f8a9e24..56623c35 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -582,7 +582,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) try: i = self.socket.send(self.data_send) except socket.error as err: - self.close_internal('server: %s' % err[1]) + self.close_internal('server: %s' % err) raise self.socket_error self.data_send = self.data_send[i:] @@ -600,7 +600,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) count = max(self.recv_buffer_size, count) bytes_recv = self.socket.recv(count) except socket.error as err: - self.close_internal('server: %s' % err[1]) + self.close_internal('server: %s' % err) raise self.socket_error if not bytes_recv: From 126ab5373ce9da61c26ad7e610b6c353a44ff900 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Tue, 7 Apr 2020 17:57:30 +0300 Subject: [PATCH 050/100] Prepare release 0.27. --- CHANGELOG.md | 14 ++++++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd9e2a6..6ead7502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ NEWS for Python X Library +Version 0.27 +============ + +Bug Fixes +--------- + +- fix TypeError in socket.error exception handling for Python 3.x (by @t-wissmann) + +Extensions +-------------------- + +- NV-CONTROL: set offset for all perf levels (by @Sporif) + +--- Version 0.26 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 6164e53a..f983e876 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 26) +__version__ = (0, 27) __version_extra__ = '' From 12101cc4a0bea2ea251d304562434d8d6b4627d9 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 10 Sep 2020 21:53:34 -0300 Subject: [PATCH 051/100] Add Xlib.ext.dpms Based on the documentation found here: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html It basically works, however there are some known issues: - Any rq.Request call (dpms_enable(), dpms_set_timeouts(), dpms_force_level()) only works if you call another rq.ReplyRequest function (dpms_get_version(), for example) afterwards. I tried to change them to use rq.ReplyRequest, but since they don't return anything they got stucked waiting for a response from X11. - DPMSInfo doesn't work. I don't have a clue why, I receive the following error when trying to call dpms_info(): ``` $ cat playground.py from Xlib import display d = display.Display() print(d.dpms_info()) $ python3 playground.py Traceback (most recent call last): File "playground.py", line 4, in print(d.dpms_info()) File "Xlib/display.py", line 225, in __getattr__ return types.MethodType(function, self) TypeError: first argument must be callable ``` So I decided to comment this function for now. --- Xlib/ext/__init__.py | 1 + Xlib/ext/dpms.py | 234 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 Xlib/ext/dpms.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index fbcc8e64..0da2800c 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -38,6 +38,7 @@ ('XInputExtension', 'xinput'), ('NV-CONTROL', 'nvcontrol'), ('DAMAGE', 'damage'), + ('DPMS', 'dpms'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py new file mode 100644 index 00000000..8420894f --- /dev/null +++ b/Xlib/ext/dpms.py @@ -0,0 +1,234 @@ +# Xlib.ext.dpms -- X Display Power Management Signaling +# +# Copyright (C) 2020 Thiago Kenji Okada +# +# 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 + +''' +This extension provides X Protocol control over the VESA Display +Power Management Signaling (DPMS) characteristics of video boards +under control of the X Window System. + +Documentation: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html +''' + +from Xlib import X +from Xlib.protocol import rq + +extname = 'DPMS' + + +# DPMS Extension Power Levels +# 0 DPMSModeOn In use +# 1 DPMSModeStandby Blanked, low power +# 2 DPMSModeSuspend Blanked, lower power +# 3 DPMSModeOff Shut off, awaiting activity +DPMSModeOn = 0 +DPMSModeStandby = 1 +DPMSModeSuspend = 2 +DPMSModeOff = 3 + +DPMSPowerLevel = ( + DPMSModeOn, + DPMSModeStandby, + DPMSModeSuspend, + DPMSModeOff, +) + + +class DPMSGetVersion(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + rq.Card16('major_version'), + rq.Card16('minor_version'), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card16('major_version'), + rq.Card16('minor_version'), + rq.Pad(20), + ) + + +def get_version(self): + return DPMSGetVersion(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSCapable(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Bool('capable'), + rq.Pad(23), + ) + + +def capable(self): + return DPMSCapable(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSGetTimeouts(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card16('standby_timeout'), + rq.Card16('suspend_timeout'), + rq.Card16('off_timeout'), + rq.Pad(18), + ) + + +def get_timeouts(self): + return DPMSGetTimeouts(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSSetTimeouts(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + rq.Card16('standby_timeout'), + rq.Card16('suspend_timeout'), + rq.Card16('off_timeout'), + rq.Pad(2) + ) + + +def set_timeouts(self, standby_timeout, suspend_timeout, off_timeout): + return DPMSSetTimeouts(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1, + standby_timeout=standby_timeout, + suspend_timeout=suspend_timeout, + off_timeout=off_timeout) + + +class DPMSEnable(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + ) + + +def enable(self): + return DPMSEnable(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSDisable(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(5), + rq.RequestLength(), + ) + + +def disable(self): + return DPMSDisable(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSForceLevel(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(6), + rq.RequestLength(), + rq.Resource('power_level', DPMSPowerLevel), + ) + + +def force_level(self, power_level): + return DPMSForceLevel(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1, + power_level=power_level) + + +class DPMSInfo(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(7), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Resource('power_level', DPMSPowerLevel), + rq.Bool('state'), + rq.Pad(21), + ) + + +def info(self): + return DPMSInfo(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +def init(disp, info): + disp.extension_add_method('display', 'dpms_get_version', get_version) + disp.extension_add_method('display', 'dpms_capable', capable) + disp.extension_add_method('display', 'dpms_get_timeouts', get_timeouts) + disp.extension_add_method('display', 'dpms_set_timeouts', set_timeouts) + disp.extension_add_method('display', 'dpms_enable', enable) + disp.extension_add_method('display', 'dpms_disable', disable) + disp.extension_add_method('display', 'dpms_force_level', force_level) + # TODO: Returns 'TypeError: first argument must be callable' on call + # disp.extension_add_method('display', 'dpms_info', info) From b484fc167ab664c4372e1e6f6063b8131b2782fa Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 10 Sep 2020 22:01:36 -0300 Subject: [PATCH 052/100] Add examples/dpms.py --- examples/dpms.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 examples/dpms.py diff --git a/examples/dpms.py b/examples/dpms.py new file mode 100644 index 00000000..5f93a068 --- /dev/null +++ b/examples/dpms.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# +# examples/dpms.py -- DPMS usage examples. +# +# Copyright (C) 2020 Thiago Kenji Okada +# +# 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 + +import time + +from Xlib import display +from Xlib.ext import dpms + + +class DPMSExamples(object): + def __init__(self): + self.d = display.Display() + # Making sure that DPMS is enabled + self.d.dpms_enable() + # For some reason, the call above needs another X11 call + # to actually trigger it + self.d.dpms_get_version() + + def dpms_info(self): + capable = self.d.dpms_capable() + timeouts = self.d.dpms_get_timeouts() + + return (capable, timeouts) + + def turn_off_display(self): + self.d.dpms_force_level(dpms.DPMSModeOff) + # For some reason, the call above needs another X11 call + # to actually trigger it + self.d.dpms_get_version() + + def turn_on_display(self): + self.d.dpms_force_level(dpms.DPMSModeOn) + # For some reason, the call above needs another X11 call + # to actually trigger it + self.d.dpms_get_version() + + +if __name__ == '__main__': + examples = DPMSExamples() + + capable, timeouts = examples.dpms_info() + + assert capable, 'DPMS is not supported in your system' + + print('Current DPMS timeouts:') + print('Standby: {}, Suspend: {}, Off: {}'.format( + timeouts.standby_timeout, + timeouts.suspend_timeout, + timeouts.off_timeout + )) + + print('\nThe next example will turn-off your screen, press Ctrl-C to cancel.') + time.sleep(2) + examples.turn_off_display() + + print('\nTurning it on again...') + time.sleep(2) + examples.turn_on_display() From 8a10823bbf9435d93a1d7a12791e9be8165fb580 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 11 Sep 2020 12:09:00 -0300 Subject: [PATCH 053/100] Enable and fix dpms_info() The problem was simple: info (function) was being shadowed by info (parameter of init()). Simple renaming the parameter works (and it is not used anyway). --- Xlib/ext/dpms.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py index 8420894f..dc06a654 100644 --- a/Xlib/ext/dpms.py +++ b/Xlib/ext/dpms.py @@ -209,7 +209,7 @@ class DPMSInfo(rq.ReplyRequest): rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Resource('power_level', DPMSPowerLevel), + rq.Card16('power_level'), rq.Bool('state'), rq.Pad(21), ) @@ -222,7 +222,7 @@ def info(self): minor_version=1) -def init(disp, info): +def init(disp, _info): disp.extension_add_method('display', 'dpms_get_version', get_version) disp.extension_add_method('display', 'dpms_capable', capable) disp.extension_add_method('display', 'dpms_get_timeouts', get_timeouts) @@ -230,5 +230,4 @@ def init(disp, info): disp.extension_add_method('display', 'dpms_enable', enable) disp.extension_add_method('display', 'dpms_disable', disable) disp.extension_add_method('display', 'dpms_force_level', force_level) - # TODO: Returns 'TypeError: first argument must be callable' on call - # disp.extension_add_method('display', 'dpms_info', info) + disp.extension_add_method('display', 'dpms_info', info) From 152a2510d6710ce1fa4b4c341750ee1c6d449987 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 11 Sep 2020 12:27:16 -0300 Subject: [PATCH 054/100] Update examples/dpms.py to call Display.sync() --- examples/dpms.py | 112 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 30 deletions(-) mode change 100644 => 100755 examples/dpms.py diff --git a/examples/dpms.py b/examples/dpms.py old mode 100644 new mode 100755 index 5f93a068..364c5472 --- a/examples/dpms.py +++ b/examples/dpms.py @@ -21,6 +21,7 @@ # Suite 330, # Boston, MA 02111-1307 USA +import random import time from Xlib import display @@ -30,49 +31,100 @@ class DPMSExamples(object): def __init__(self): self.d = display.Display() - # Making sure that DPMS is enabled - self.d.dpms_enable() - # For some reason, the call above needs another X11 call - # to actually trigger it - self.d.dpms_get_version() - def dpms_info(self): capable = self.d.dpms_capable() - timeouts = self.d.dpms_get_timeouts() + assert capable, 'DPMS is not supported in your system' + + self.initial_info = self.d.dpms_info() + self.initial_timeouts = self.d.dpms_get_timeouts() + + # Making sure that DPMS is enable for this examples + self.d.dpms_enable() + self.d.sync() + + def print_dpms(self): + current_info = self.d.dpms_info() + print('\nDPMS state: {}\nPower level: {}'.format(current_info.state, + current_info.power_level)) + current_timeouts = self.d.dpms_get_timeouts() + print('Standby: {}, Suspend: {}, Off: {}\n'.format(current_timeouts.standby_timeout, + current_timeouts.suspend_timeout, + current_timeouts.off_timeout)) + + def toggle_dpms(self): + current_info = self.d.dpms_info() + if current_info.state: + self.d.dpms_disable() + else: + self.d.dpms_enable() + + self.d.sync() + + def restore(self): + print('Restoring DPMS configuration') + self.d.dpms_set_timeouts(self.initial_timeouts.standby_timeout, + self.initial_timeouts.suspend_timeout, + self.initial_timeouts.off_timeout) + if self.initial_info.state: + self.d.dpms_enable() + else: + self.d.dpms_disable() - return (capable, timeouts) + self.d.sync() + + self.print_dpms() + + def set_random_timeouts(self): + # Can be any number greater than 0 + # Using 10 just to not turnoff the screen suddenly + standby_timeout = random.randint(10, 600) + # Shouldn't be smaller than standby_timeout + suspend_timeout = random.randint(standby_timeout, 600) + # Shouldn't be smaller than standby_timeout or suspend_timeout + off_timeout = random.randint(suspend_timeout, 600) + self.d.dpms_set_timeouts(standby_timeout, suspend_timeout, off_timeout) + self.d.sync() def turn_off_display(self): self.d.dpms_force_level(dpms.DPMSModeOff) - # For some reason, the call above needs another X11 call - # to actually trigger it - self.d.dpms_get_version() + self.d.sync() def turn_on_display(self): self.d.dpms_force_level(dpms.DPMSModeOn) - # For some reason, the call above needs another X11 call - # to actually trigger it - self.d.dpms_get_version() + self.d.sync() -if __name__ == '__main__': - examples = DPMSExamples() +def main(): + try: + examples = DPMSExamples() + + print('Initial state') + examples.print_dpms() - capable, timeouts = examples.dpms_info() + print('Setting random timeouts') + examples.set_random_timeouts() + examples.print_dpms() - assert capable, 'DPMS is not supported in your system' + print('The next example will turn-off your screen, press Ctrl-C to cancel.') + time.sleep(2) + examples.turn_off_display() - print('Current DPMS timeouts:') - print('Standby: {}, Suspend: {}, Off: {}'.format( - timeouts.standby_timeout, - timeouts.suspend_timeout, - timeouts.off_timeout - )) + print('Turning it on again...') + time.sleep(2) + examples.turn_on_display() - print('\nThe next example will turn-off your screen, press Ctrl-C to cancel.') - time.sleep(2) - examples.turn_off_display() + print() - print('\nTurning it on again...') - time.sleep(2) - examples.turn_on_display() + print('Toggle DPMS') + examples.toggle_dpms() + examples.print_dpms() + + print('Toggle it again') + examples.toggle_dpms() + examples.print_dpms() + finally: + examples.restore() + + +if __name__ == '__main__': + main() From 733556f8b40b2d2643830ac193a0ffdd6560dbfc Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Mon, 14 Sep 2020 14:34:32 -0300 Subject: [PATCH 055/100] Fix e-mail in DPMS extension --- Xlib/ext/dpms.py | 2 +- examples/dpms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py index dc06a654..3ff9a246 100644 --- a/Xlib/ext/dpms.py +++ b/Xlib/ext/dpms.py @@ -1,6 +1,6 @@ # Xlib.ext.dpms -- X Display Power Management Signaling # -# Copyright (C) 2020 Thiago Kenji Okada +# Copyright (C) 2020 Thiago Kenji Okada # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License diff --git a/examples/dpms.py b/examples/dpms.py index 364c5472..0a04be57 100755 --- a/examples/dpms.py +++ b/examples/dpms.py @@ -2,7 +2,7 @@ # # examples/dpms.py -- DPMS usage examples. # -# Copyright (C) 2020 Thiago Kenji Okada +# Copyright (C) 2020 Thiago Kenji Okada # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License From f0a846d8aa5bc18ee8e58339b11ae6d24dc4224c Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 17 Sep 2020 12:38:34 -0300 Subject: [PATCH 056/100] Update links in README --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e28f80cf..189c431b 100644 --- a/README.rst +++ b/README.rst @@ -75,10 +75,10 @@ Documentation ~~~~~~~~~~~~~ The reference manual is not finished by far, but is probably still useful. It -can be `browsed online `__. +can be `browsed online `__. There are also some `example programs `_ and, of course, -`the standard X11 documentation `__ applies. +`the standard X11 documentation `__ applies. Project status From 16de6b30f2dd38d914022d983a7b90d43d46f1c3 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 17 Sep 2020 12:41:17 -0300 Subject: [PATCH 057/100] Remove trailing whitespace, add DPMS to README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 189c431b..f5a92b14 100644 --- a/README.rst +++ b/README.rst @@ -70,7 +70,7 @@ There are three advantages of implementing a pure Python library: - Maintainability: It is much easier to develop and debug native Python modules than modules written in C. - + Documentation ~~~~~~~~~~~~~ @@ -92,7 +92,7 @@ starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been -implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, and XTEST) +implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, DPMS, and XTEST) patches for additions are very welcome. There are most likely still bugs, but the library is at least stable From c5768cf0b0411cf39e00cc72c97687420224053d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sat, 19 Sep 2020 23:43:18 +0300 Subject: [PATCH 058/100] Update CHANGELOG, version and list of extensions in README. --- CHANGELOG.md | 9 +++++++++ README.rst | 3 ++- Xlib/__init__.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ead7502..128a892d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.28 +============ + +Extensions +-------------------- + +- DPMS: Display Power Management Signaling (by @thiagokokada) + +--- Version 0.27 ============ diff --git a/README.rst b/README.rst index f5a92b14..8c06870e 100644 --- a/README.rst +++ b/README.rst @@ -92,7 +92,8 @@ starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been -implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, DPMS, and XTEST) +implemented (RECORD, SHAPE, Xinerama, Composite, RANDR, DAMAGE, +Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL and DPMS); patches for additions are very welcome. There are most likely still bugs, but the library is at least stable diff --git a/Xlib/__init__.py b/Xlib/__init__.py index f983e876..e38da5ea 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 27) +__version__ = (0, 28) __version_extra__ = '' From ecafb97693635e334d9837b69985ca22956f70df Mon Sep 17 00:00:00 2001 From: Adrian Room Date: Mon, 21 Sep 2020 14:51:25 +0100 Subject: [PATCH 059/100] Fix __repr__s Reprs should contain the name of the class not the class's whole string conversion. (args) -> SomeClass(args) --- Xlib/protocol/rq.py | 6 +++--- Xlib/xobject/resource.py | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 24042176..86cb2def 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1320,7 +1320,7 @@ def __str__(self): return str(self._data) def __repr__(self): - return '%s(%s)' % (self.__class__, repr(self._data)) + return '%s(%s)' % (self.__class__.__name__, repr(self._data)) def __lt__(self, other): if isinstance(other, DictWrapper): @@ -1400,7 +1400,7 @@ def _set_error(self, error): return 1 def __repr__(self): - return '<%s serial = %s, data = %s, error = %s>' % (self.__class__, self._serial, self._data, self._error) + return '<%s serial = %s, data = %s, error = %s>' % (self.__class__.__name__, self._serial, self._data, self._error) class Event(GetAttrData): @@ -1434,7 +1434,7 @@ def __repr__(self): kwlist.append('%s = %s' % (kw, repr(val))) kws = ', '.join(kwlist) - return '%s(%s)' % (self.__class__, kws) + return '%s(%s)' % (self.__class__.__name__, kws) def __lt__(self, other): if isinstance(other, Event): diff --git a/Xlib/xobject/resource.py b/Xlib/xobject/resource.py index 0492ffec..ea256ca1 100644 --- a/Xlib/xobject/resource.py +++ b/Xlib/xobject/resource.py @@ -45,11 +45,8 @@ def __ne__(self, obj): def __hash__(self): return int(self.id) - def __str__(self): - return '%s(0x%08x)' % (self.__class__, self.id) - def __repr__(self): - return '<%s 0x%08x>' % (self.__class__, self.id) + return '<%s 0x%08x>' % (self.__class__.__name__, self.id) def kill_client(self, onerror = None): request.KillClient(display = self.display, From 882714a336547ceaa1545cf68d0503cb75d11219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= Date: Fri, 20 Nov 2020 15:49:56 +0100 Subject: [PATCH 060/100] Use encode_array() in Drawable._get_struct_prop() The Xlib/protocol/rq.py file defines an helper function encode_array() that calls tostring() or tobytes() depending on which python version is used. The package maintainer Christoph Egger reported that the testsuite of the herbstluftwm project fails[1] with the error: def _get_struct_prop(self, pname, ptype, pstruct): r = self.get_property(pname, ptype, 0, pstruct.static_size // 4) if r and r.format == 32: > value = r.value.tostring() E AttributeError: 'array.array' object has no attribute 'tostring' /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:782: AttributeError Backtrace: ../tests/conftest.py:624: in is_window_urgent hints = window.get_wm_hints() /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:756: in get_wm_hints return self._get_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS, I assume it should be rq.encode_array() instead of .tostring() but I'm not terribly sure. [1] https://pbot.rmdir.de/u/4lU98VkXkdjSypXmdekh5g --- Xlib/xobject/drawable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 2f688c88..c36a9738 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -779,7 +779,7 @@ def get_wm_icon_size(self): def _get_struct_prop(self, pname, ptype, pstruct): r = self.get_property(pname, ptype, 0, pstruct.static_size // 4) if r and r.format == 32: - value = r.value.tostring() + value = rq.encode_array(r.value) if len(value) == pstruct.static_size: return pstruct.parse_binary(value, self.display)[0] From f2d092ee4b7eb8de3a1bc09b36f47595efd10b00 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 22 Nov 2020 14:30:20 +0300 Subject: [PATCH 061/100] Add Python 3.9 to Travis CI tests, bump version. --- .travis.yml | 1 + Xlib/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 524f0998..e7b949f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - "3.6" - "3.7" - "3.8" + - "3.9" # command to install dependencies install: diff --git a/Xlib/__init__.py b/Xlib/__init__.py index e38da5ea..2ff7aabc 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 28) +__version__ = (0, 29) __version_extra__ = '' From e04b89e373151db7d631f0a0aa9ca71e7342fd8d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 22 Nov 2020 14:40:54 +0300 Subject: [PATCH 062/100] Use encode_array() for array.array objects everywhere (.tostring() will be removed in Python 3.9). --- Xlib/ext/xinput.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index fee0d93c..e219bffe 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -236,7 +236,7 @@ def fun(val): else: mask_seq.extend(val) - return mask_seq.tostring(), len(mask_seq), None + return rq.encode_array(mask_seq), len(mask_seq), None EventMask = rq.Struct( DEVICE('deviceid'), From d1180422496bb057f0f665c968d912e59d23f5e8 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 22 Nov 2020 14:45:17 +0300 Subject: [PATCH 063/100] Update change log for 0.29. --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 128a892d..a5eba75f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.29 +============ + +Extensions +-------------------- + +- Drawable & XInput: Avoid using array.array.tostring() which wiil be removed in Python 3.9 (thanks @t-wissmann). + +--- Version 0.28 ============ From cae68404027cfb49f99e6353d45faf7feb29f8da Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 23 Nov 2020 17:15:07 +0200 Subject: [PATCH 064/100] Fix minor typo in documentation isntance -> instance --- doc/src/objects.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/objects.texi b/doc/src/objects.texi index 6d47137a..c6dfd7ee 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -1175,7 +1175,7 @@ Returns None or string. @end defmethod @defmethod Window get_wm_class ( ) -Returns None or (isntance, class) +Returns None or (instance, class) @end defmethod @defmethod Window set_wm_transient_for ( window, onerror = None ) From 376703ebb0069cf01727e22a679590fc14ac0152 Mon Sep 17 00:00:00 2001 From: Jimmy Loyola Date: Tue, 16 Mar 2021 11:45:27 +0100 Subject: [PATCH 065/100] Add missing parameters to xrandr delete_output_mode function --- Xlib/ext/randr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 0a1dfb9c..48f4b635 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -699,7 +699,7 @@ class DeleteOutputMode(rq.Request): rq.Card32('mode'), ) -def delete_output_mode(self): +def delete_output_mode(self, output, mode): return DeleteOutputMode( display=self.display, opcode=self.display.get_extension_major(extname), From 0f970167fc424c9dea1b404e0dd11417f8cb9f63 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 16:44:57 -0700 Subject: [PATCH 066/100] Add Xlib.ext.res Based on the xcb bindings sources and the protocol documentation: - https://www.x.org/releases/current/doc/resourceproto/resproto.txt - https://cgit.freedesktop.org/xcb/proto/tree/src/res.xml Verified that all methods are working with an example application. --- README.rst | 2 +- Xlib/ext/__init__.py | 1 + Xlib/ext/res.py | 285 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 Xlib/ext/res.py diff --git a/README.rst b/README.rst index 8c06870e..572e701f 100644 --- a/README.rst +++ b/README.rst @@ -93,7 +93,7 @@ starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been implemented (RECORD, SHAPE, Xinerama, Composite, RANDR, DAMAGE, -Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL and DPMS); +Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL, DPMS and XRes); patches for additions are very welcome. There are most likely still bugs, but the library is at least stable diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 0da2800c..71a855b0 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -39,6 +39,7 @@ ('NV-CONTROL', 'nvcontrol'), ('DAMAGE', 'damage'), ('DPMS', 'dpms'), + ('X-Resource', 'res'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/res.py b/Xlib/ext/res.py new file mode 100644 index 00000000..0a1ea79b --- /dev/null +++ b/Xlib/ext/res.py @@ -0,0 +1,285 @@ +# Xlib.ext.res -- X-Resource extension module +# +# Copyright (C) 2021 Aleksei Bavshin +# +# 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., +# 51 Franklin Street, +# Fifth Floor, +# Boston, MA 02110-1301 USA + +"""X-Resource extension allows a client to query the X server about its usage +of various resources. + +For detailed description see any of the following documents. +Protocol specification: + https://www.x.org/releases/current/doc/resourceproto/resproto.txt +XCB Protocol specification: + https://cgit.freedesktop.org/xcb/proto/tree/src/res.xml +""" +from Xlib.protocol import rq + +RES_MAJOR_VERSION = 1 +RES_MINOR_VERSION = 2 + +extname = "X-Resource" + +# v1.0 +ResQueryVersion = 0 +ResQueryClients = 1 +ResQueryClientResources = 2 +ResQueryClientPixmapBytes = 3 +# v1.2 +ResQueryClientIds = 4 +ResQueryResourceBytes = 5 + + +class QueryVersion(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryVersion), + rq.RequestLength(), + rq.Card8("client_major"), + rq.Card8("client_minor"), + rq.Pad(2)) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.Card16("server_major"), + rq.Card16("server_minor"), + rq.Pad(20)) + + +def query_version(self, client_major=RES_MAJOR_VERSION, + client_minor=RES_MINOR_VERSION): + """ Query the protocol version supported by the X server. + + The client sends the highest supported version to the server and the + server sends the highest version it supports, but no higher than the + requested version.""" + return QueryVersion( + display=self.display, + opcode=self.display.get_extension_major(extname), + client_major=client_major, + client_minor=client_minor) + + +Client = rq.Struct( + rq.Card32("resource_base"), + rq.Card32("resource_mask")) + + +class QueryClients(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClients), + rq.RequestLength()) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("clients", 4), + rq.Pad(20), + rq.List("clients", Client)) + + +def query_clients(self): + """Request the list of all currently connected clients.""" + return QueryClients( + display=self.display, + opcode=self.display.get_extension_major(extname)) + + +Type = rq.Struct( + rq.Card32("resource_type"), + rq.Card32("count")) + + +class QueryClientResources(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClientResources), + rq.RequestLength(), + rq.Card32("client")) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("types", 4), + rq.Pad(20), + rq.List("types", Type)) + + +def query_client_resources(self, client): + """Request the number of resources owned by a client. + + The server will return the counts of each type of resource. + """ + return QueryClientResources( + display=self.display, + opcode=self.display.get_extension_major(extname), + client=client) + + +class QueryClientPixmapBytes(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClientPixmapBytes), + rq.RequestLength(), + rq.Card32("client")) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.Card32("bytes"), + rq.Card32("bytes_overflow"), + rq.Pad(16)) + + +def query_client_pixmap_bytes(self, client): + """Query the pixmap usage of some client. + + The returned number is a sum of memory usage of each pixmap that can be + attributed to the given client. + """ + return QueryClientPixmapBytes( + display=self.display, + opcode=self.display.get_extension_major(extname), + client=client) + + +class SizeOf(rq.LengthOf): + """A SizeOf stores the size in bytes of some other Field whose size + may vary, e.g. List + """ + def __init__(self, name, size, item_size): + rq.LengthOf.__init__(self, name, size) + self.item_size = item_size + + def parse_value(self, length, display): + return length // self.item_size + + +ClientXIDMask = 1 << 0 +LocalClientPIDMask = 1 << 1 + + +ClientIdSpec = rq.Struct( + rq.Card32("client"), + rq.Card32("mask")) + + +ClientIdValue = rq.Struct( + rq.Object("spec", ClientIdSpec), + SizeOf("value", 4, 4), + rq.List("value", rq.Card32Obj)) + + +class QueryClientIds(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClientIds), + rq.RequestLength(), + rq.LengthOf("specs", 4), + rq.List("specs", ClientIdSpec)) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("ids", 4), + rq.Pad(20), + rq.List("ids", ClientIdValue)) + + +def query_client_ids(self, specs): + """Request to identify a given set of clients with some identification method. + + The request sends a list of specifiers that select clients and + identification methods to server. The server then tries to identify the + chosen clients using the identification methods specified for each client. + The server returns IDs for those clients that were successfully identified. + """ + return QueryClientIds( + display=self.display, + opcode=self.display.get_extension_major(extname), + specs=specs) + + +ResourceIdSpec = rq.Struct( + rq.Card32("resource"), + rq.Card32("type")) + + +ResourceSizeSpec = rq.Struct( + rq.Object("spec", ResourceIdSpec), + rq.Card32("bytes"), + rq.Card32("ref_count"), + rq.Card32("use_count")) + + +ResourceSizeValue = rq.Struct( + rq.Object("size", ResourceSizeSpec), + rq.LengthOf("cross_references", 4), + rq.List("cross_references", ResourceSizeSpec)) + + +class QueryResourceBytes(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryResourceBytes), + rq.RequestLength(), + rq.Card32("client"), + rq.LengthOf("specs", 4), + rq.List("specs", ResourceIdSpec)) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("sizes", 4), + rq.Pad(20), + rq.List("sizes", ResourceSizeValue)) + + +def query_resource_bytes(self, client, specs): + """Query the sizes of resources from X server. + + The request sends a list of specifiers that selects resources for size + calculation. The server tries to calculate the sizes of chosen resources + and returns an estimate for a resource only if the size could be determined + """ + return QueryResourceBytes( + display=self.display, + opcode=self.display.get_extension_major(extname), + client=client, + specs=specs) + + +def init(disp, info): + disp.extension_add_method("display", "res_query_version", query_version) + disp.extension_add_method("display", "res_query_clients", query_clients) + disp.extension_add_method("display", "res_query_client_resources", + query_client_resources) + disp.extension_add_method("display", "res_query_client_pixmap_bytes", + query_client_pixmap_bytes) + disp.extension_add_method("display", "res_query_client_ids", + query_client_ids) + disp.extension_add_method("display", "res_query_resource_bytes", + query_resource_bytes) From 1265f1f85307da6d617463c365efbeffeecf31a6 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 16:49:17 -0700 Subject: [PATCH 067/100] Add examples/xres.py to demonstrate and test X-Resource extension --- examples/xres.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 examples/xres.py diff --git a/examples/xres.py b/examples/xres.py new file mode 100755 index 00000000..b28d7c38 --- /dev/null +++ b/examples/xres.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# +# examples/xres.py -- demonstrate the X-Resource extension +# +# Copyright (C) 2021 Aleksei Bavshin +# +# 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., +# 51 Franklin Street, +# Fifth Floor, +# Boston, MA 02110-1301 USA + +import os +import sys + +# Change path so we find Xlib +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) + +from Xlib.display import Display +from Xlib.ext import res as XRes + + +def check_ext(disp, extname, version): + if disp.query_extension(extname) is None: + raise AssertionError("Server has {} extension".format(extname)) + + r = disp.res_query_version() + if (r.server_major, r.server_minor) < version: + raise AssertionError( + "Server has requested version {} of {} extension".format(version, extname) + ) + + +def query_client_id(display, wid): + specs = [{"client": wid, "mask": XRes.LocalClientPIDMask}] + r = display.res_query_client_ids(specs) + for id in r.ids: + if id.spec.client > 0 and id.spec.mask == XRes.LocalClientPIDMask: + for value in id.value: + return value + return None + + +def print_client_info(disp, client): + print("client: {}".format(client)) + + resources = disp.res_query_client_resources(client) + rc = [r.count for r in resources.types] + print("\tresouces: {} resources of {} types".format(sum(rc), len(rc))) + + pb = disp.res_query_client_pixmap_bytes(client) + print("\tpixmaps: {} bytes {} overflow".format(pb.bytes, pb.bytes_overflow)) + + pid = query_client_id(disp, client) + print("\tpid: {}".format(pid)) + + rb = disp.res_query_resource_bytes(client, [{"resource": 0, "type": 0}]) + sizes = [s.size.bytes for s in rb.sizes] + print("\t{} resources consume {} bytes".format(len(sizes), sum(sizes))) + + +def main(): + display = Display() + check_ext(display, XRes.extname, (1, 2)) + + clients = display.res_query_clients().clients + print("{} clients connected to the server".format(len(clients))) + + for client in clients: + print_client_info(display, client.resource_base) + + +if __name__ == "__main__": + main() From 317548f106c5b4e0b1aa9bc6e412721c948d4fa7 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 16:57:05 -0700 Subject: [PATCH 068/100] Xlib.ext.res: inline struct ResourceIdSpec to work around parser bug Fixes following error: ``` Traceback (most recent call last): File "examples/xres.py", line 85, in main() File "examples/xres.py", line 81, in main print_client_info(display, client.resource_base) File "examples/xres.py", line 68, in print_client_info rb = window.res_query_resource_bytes([{"resource": 0, "type": 0}]) File "examples/../Xlib/ext/res.py", line 268, in query_resource_bytes return QueryResourceBytes( File "examples/../Xlib/protocol/rq.py", line 1369, in __init__ self.reply() File "examples/../Xlib/protocol/rq.py", line 1381, in reply self._display.send_and_recv(request = self._serial) File "examples/../Xlib/protocol/display.py", line 612, in send_and_recv gotreq = self.parse_response(request) File "examples/../Xlib/protocol/display.py", line 704, in parse_response gotreq = self.parse_request_response(request) or gotreq File "examples/../Xlib/protocol/display.py", line 792, in parse_request_response req._parse_response(self.data_recv[:self.recv_packet_len]) File "examples/../Xlib/protocol/rq.py", line 1393, in _parse_response self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1) File "examples/../Xlib/protocol/rq.py", line 1203, in parse_binary ret[f.name], data = f.parse_binary_value(data, display, File "examples/../Xlib/protocol/rq.py", line 533, in parse_binary_value ret[i], data = self.type.parse_binary(data, display) File "examples/../Xlib/protocol/rq.py", line 1192, in parse_binary field_val = f.parse_value(field_val, display) File "examples/../Xlib/protocol/rq.py", line 604, in parse_value return self.type.parse_value(val, display) File "examples/../Xlib/protocol/rq.py", line 1126, in parse_value field_val = f.parse_value(field_val, display, rawdict=rawdict) TypeError: parse_value() got an unexpected keyword argument 'rawdict' ``` --- Xlib/ext/res.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/res.py b/Xlib/ext/res.py index 0a1ea79b..f2c4e9fe 100644 --- a/Xlib/ext/res.py +++ b/Xlib/ext/res.py @@ -228,7 +228,10 @@ def query_client_ids(self, specs): ResourceSizeSpec = rq.Struct( - rq.Object("spec", ResourceIdSpec), + # inline struct ResourceIdSpec to work around + # a parser bug with nested objects + rq.Card32("resource"), + rq.Card32("type"), rq.Card32("bytes"), rq.Card32("ref_count"), rq.Card32("use_count")) From 06c0cf0c6aa66d871685b3763acf7c45ac595243 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 17:44:31 -0700 Subject: [PATCH 069/100] Add XRes to run_examples.py --- examples/run_examples.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/run_examples.py b/examples/run_examples.py index f97a4e0b..9c834dcd 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -77,6 +77,10 @@ def test_xlsatoms(self): """ Run xlsatoms.py -- show list atoms on X server """ self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) + def test_xres(self): + """ Run xres.py -- demonstrate the X-Resource extension """ + self.assertEqual(run_example(examples_folder + "xres.py"), 0) + if __name__ == '__main__': unittest.main() From 3d28d6bf9ab5f4d5e4a48c863f90c95b4f7eca30 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sat, 15 May 2021 21:22:25 +0300 Subject: [PATCH 070/100] Update CHANGELOG, bump version to 0.30 --- CHANGELOG.md | 10 ++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5eba75f..024c3ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ NEWS for Python X Library +Version 0.30 +============ + +Extensions +-------------------- + +- XResource: first implementation (thanks @alebastr). +- XRandr: add missing parameters to delete_output_mode function (thanks @jimmy-loyola). + +--- Version 0.29 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 2ff7aabc..d6af5d61 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 29) +__version__ = (0, 30) __version_extra__ = '' From 6781fd3f8cdbf7f2af7dd2830013f0fdcc0ec41a Mon Sep 17 00:00:00 2001 From: Davydov Denis Date: Wed, 23 Jun 2021 16:00:08 +0300 Subject: [PATCH 071/100] - added xinput event methods - added xinput property event data --- .gitignore | 4 +- Xlib/ext/xinput.py | 123 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ac3327fb..d8efd36c 100644 --- a/.gitignore +++ b/.gitignore @@ -59,7 +59,9 @@ docs/_build/ target/ # IntelliJ - .idea/ +# Visual Studio Code +.vscode/ + /.mypy_cache/ diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index e219bffe..f9218064 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -158,6 +158,8 @@ DEVICE = rq.Card16 DEVICEUSE = rq.Card8 +PROPERTY_TYPE_FLOAT = 'FLOAT' + class FP1616(rq.Int32): def check_value(self, value): @@ -426,6 +428,114 @@ def query_device(self, deviceid): deviceid=deviceid, ) +class XIListProperties(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(56), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Pad(2), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.LengthOf('atoms', 2), + rq.Pad(22), + rq.List('atoms', rq.Card32Obj), + ) + +def list_device_properties(self, deviceid): + return XIListProperties( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + ) + +class XIGetProperty(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(59), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Card8('delete'), + rq.Pad(1), + rq.Card32('property'), + rq.Card32('type'), + rq.Card32('offset'), + rq.Card32('length'), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('type'), + rq.Card32('bytes_after'), + rq.LengthOf('value', 4), + rq.Format('value', 1), + rq.Pad(11), + rq.PropertyData('value') + ) + +def get_device_property(self, deviceid, property, type, offset, length, delete=False): + return XIGetProperty( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + property=property, + type=type, + offset=offset, + length=length, + delete=delete, + ) + +class XIChangeProperty(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(57), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Card8('mode'), + rq.Format('value', 1), + rq.Card32('property'), + rq.Card32('type'), + rq.LengthOf('value', 4), + rq.PropertyData('value'), + ) + +def change_device_property(self, deviceid, property, type, mode, value): + return XIChangeProperty( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + property=property, + type=type, + mode=mode, + value=value, + ) + +class XIDeleteProperty(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(58), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Pad(2), + rq.Card32('property'), + ) + +def delete_device_property(self, deviceid, property): + return XIDeleteProperty( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + property=property, + ) + class XIGrabDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), @@ -639,6 +749,14 @@ def ungrab_keycode(self, deviceid, keycode, modifiers): rq.List('classes', ClassInfo), ) +PropertyEventData = rq.Struct( + DEVICEID('deviceid'), + rq.Card32('time'), + rq.Card32('property'), + rq.Card8('what'), + rq.Pad(11), +) + def init(disp, info): disp.extension_add_method('display', 'xinput_query_version', query_version) disp.extension_add_method('window', 'xinput_select_events', select_events) @@ -647,8 +765,13 @@ def init(disp, info): disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) + disp.extension_add_method('display', 'xinput_get_device_property', get_device_property) + disp.extension_add_method('display', 'xinput_list_device_properties', list_device_properties) + disp.extension_add_method('display', 'xinput_change_device_property', change_device_property) + disp.extension_add_method('display', 'xinput_delete_device_property', delete_device_property) if hasattr(disp,"ge_add_event_data"): for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) + disp.ge_add_event_data(info.major_opcode, PropertyEvent, PropertyEventData) From a734526ed33fe446396e32649e8895dde679f52c Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 2 Jul 2021 13:29:24 +0300 Subject: [PATCH 072/100] Update CHANGELOG, bump version to 0.31 --- CHANGELOG.md | 9 +++++++++ Xlib/__init__.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 024c3ea3..b960a8d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.31 +============ + +Extensions +-------------------- + +- XInput: add event methods (thanks @dd4e). + +--- Version 0.30 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index d6af5d61..89473730 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 30) +__version__ = (0, 31) __version_extra__ = '' From 1a3031544bb25464c4744edae39ac02b0e730f13 Mon Sep 17 00:00:00 2001 From: "B. Blechschmidt" Date: Sun, 26 Sep 2021 11:45:21 +0200 Subject: [PATCH 073/100] Add support for FamilyServerInterpreted and FamilyInternetV6 --- Xlib/X.py | 2 ++ Xlib/display.py | 5 +++-- Xlib/protocol/request.py | 3 ++- Xlib/xauth.py | 2 ++ doc/src/objects.texi | 6 ++++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Xlib/X.py b/Xlib/X.py index 3105e798..1a09e392 100644 --- a/Xlib/X.py +++ b/Xlib/X.py @@ -197,6 +197,8 @@ FamilyInternet = 0 FamilyDECnet = 1 FamilyChaos = 2 +FamilyServerInterpreted = 5 +FamilyInternetV6 = 6 PropertyNewValue = 0 PropertyDelete = 1 ColormapUninstalled = 0 diff --git a/Xlib/display.py b/Xlib/display.py index beaeaad6..ead0185c 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -849,7 +849,8 @@ def get_screen_saver(self): def change_hosts(self, mode, host_family, host, onerror = None): """mode is either X.HostInsert or X.HostDelete. host_family is - one of X.FamilyInternet, X.FamilyDECnet or X.FamilyChaos. + one of X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, + X.FamilyServerInterpreted or X.FamilyInternetV6. host is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address.""" @@ -868,7 +869,7 @@ def list_hosts(self): The hosts on the access list. Each entry has the following attributes: family - X.FamilyInternet, X.FamilyDECnet, or X.FamilyChaos. + X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, X.FamilyServerInterpreted or X.FamilyInternetV6. name A list of byte values, the coding depends on family. For the Internet family, it is the 4 bytes of an IPv4 address. diff --git a/Xlib/protocol/request.py b/Xlib/protocol/request.py index efe62ddb..b431e137 100644 --- a/Xlib/protocol/request.py +++ b/Xlib/protocol/request.py @@ -1640,7 +1640,8 @@ class ChangeHosts(rq.Request): rq.Opcode(109), rq.Set('mode', 1, (X.HostInsert, X.HostDelete)), rq.RequestLength(), - rq.Set('host_family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos)), + rq.Set('host_family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, + X.FamilyServerInterpreted, X.FamilyInternetV6)), rq.Pad(1), rq.LengthOf('host', 2), rq.List('host', rq.Card8Obj) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index 63eb7ef7..2ed7dd52 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -27,6 +27,8 @@ FamilyInternet = X.FamilyInternet FamilyDECnet = X.FamilyDECnet FamilyChaos = X.FamilyChaos +FamilyServerInterpreted = X.FamilyServerInterpreted +FamilyInternetV6 = X.FamilyInternetV6 FamilyLocal = 256 class Xauthority(object): diff --git a/doc/src/objects.texi b/doc/src/objects.texi index c6dfd7ee..094bf95c 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -678,7 +678,8 @@ XGetScreenSaver(3X11) for details. @var{mode} is either @code{X.HostInsert} or @code{X.HostDelete}. @var{host_family} is one of @code{X.FamilyInternet}, -@code{X.FamilyDECnet} or @code{X.FamilyChaos}. +@code{X.FamilyDECnet}, @code{X.FamilyChaos}, @code{X.FamilyServerInterpreted} +or @code{X.FamilyInternetV6}. @var{host} is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address. @@ -699,7 +700,8 @@ The hosts on the access list. Each entry has the following attributes: @table @code @item family -@code{X.FamilyInternet}, @code{X.FamilyDECnet}, or @code{X.FamilyChaos}. +@code{X.FamilyInternet}, @code{X.FamilyDECnet}, @code{X.FamilyChaos}, +@code{X.FamilyServerInterpreted} or @code{X.FamilyInternetV6}. @item name A list of byte values, the coding depends on @code{family}. For the From 0527e0f04de9b278b3d19c98b6aecfa3c014778b Mon Sep 17 00:00:00 2001 From: PythonCoderAS <13932583+PythonCoderAS@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:42:22 -0500 Subject: [PATCH 074/100] Include note about OS support --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 572e701f..ad040fe4 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,9 @@ Requirements The Python X Library requires Python 2.7 or newer. It has been tested to various extents with Python 2.7 and 3.3 through 3.6. +The Python X Library will only work on systems that have an X server installed, +such as most Linux distros, but will not work on Windows or MacOS. + Installation ~~~~~~~~~~~~ From fc47fde63d5a00a4100d05ebfeb48db088aca186 Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:22:24 +0200 Subject: [PATCH 075/100] Update xf86.py with new keysyms Suspend, hibernate, touchpad controls, microphone toggle, WWAN, RFKill, Audio preset, rotation lock toggle and full screen. These "new" keysyms were taken from `/usr/include/X11/XF86keysym.h` --- Xlib/keysymdef/xf86.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Xlib/keysymdef/xf86.py b/Xlib/keysymdef/xf86.py index 2640535c..e8610c09 100644 --- a/Xlib/keysymdef/xf86.py +++ b/Xlib/keysymdef/xf86.py @@ -159,6 +159,25 @@ XK_XF86_Yellow = 0x1008FFA5 XK_XF86_Blue = 0x1008FFA6 +XK_XF86_Suspend = 0x1008FFA7 +XK_XF86_Hibernate = 0x1008FFA8 +XK_XF86_TouchpadToggle = 0x1008FFA9 +XK_XF86_TouchpadOn = 0x1008FFB0 +XK_XF86_TouchpadOff = 0x1008FFB1 + +XK_XF86_AudioMicMute = 0x1008FFB2 + +XK_XF86_Keyboard = 0x1008FFB3 + +XK_XF86_WWAN = 0x1008FFB4 +XK_XF86_RFKill = 0x1008FFB5 + +XK_XF86_AudioPreset = 0x1008FFB6 + +XK_XF86_RotationLockToggle = 0x1008FFB7 + +XK_XF86_FullScreen = 0x1008FFB8 + XK_XF86_Switch_VT_1 = 0x1008FE01 XK_XF86_Switch_VT_2 = 0x1008FE02 XK_XF86_Switch_VT_3 = 0x1008FE03 From bb8685acf3351e10b3182034724dc16fa0a11630 Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:32:51 +0200 Subject: [PATCH 076/100] Added the four remaining XF86 keysyms to xf86.py ModeLock, MonBrightnessCycle, LogWindowTree, LogGrabInfo --- Xlib/keysymdef/xf86.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Xlib/keysymdef/xf86.py b/Xlib/keysymdef/xf86.py index e8610c09..4ccf12a7 100644 --- a/Xlib/keysymdef/xf86.py +++ b/Xlib/keysymdef/xf86.py @@ -1,8 +1,11 @@ -XK_XF86_MonBrightnessUp = 0x1008FF02 -XK_XF86_MonBrightnessDown = 0x1008FF03 -XK_XF86_KbdLightOnOff = 0x1008FF04 -XK_XF86_KbdBrightnessUp = 0x1008FF05 -XK_XF86_KbdBrightnessDown = 0x1008FF06 +XK_XF86_ModeLock = 0x1008FF01 + +XK_XF86_MonBrightnessUp = 0x1008FF02 +XK_XF86_MonBrightnessDown = 0x1008FF03 +XK_XF86_KbdLightOnOff = 0x1008FF04 +XK_XF86_KbdBrightnessUp = 0x1008FF05 +XK_XF86_KbdBrightnessDown = 0x1008FF06 +XK_XF86_MonBrightnessCycle = 0x1008FF07 XK_XF86_Standby = 0x1008FF10 XK_XF86_AudioLowerVolume = 0x1008FF11 @@ -195,3 +198,5 @@ XK_XF86_ClearGrab = 0x1008FE21 XK_XF86_Next_VMode = 0x1008FE22 XK_XF86_Prev_VMode = 0x1008FE23 +XK_XF86_LogWindowTree = 0x1008FE24 +XK_XF86_LogGrabInfo = 0x1008FE25 From c9d2428e4c3e956c06c2cb2c2b75fa3e3333635f Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Wed, 27 Apr 2022 05:17:06 +0000 Subject: [PATCH 077/100] Add screensaver extension --- Xlib/ext/__init__.py | 1 + Xlib/ext/screensaver.py | 198 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 Xlib/ext/screensaver.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 71a855b0..37229bac 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -40,6 +40,7 @@ ('DAMAGE', 'damage'), ('DPMS', 'dpms'), ('X-Resource', 'res'), + ('MIT-SCREEN-SAVER', 'screensaver'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/screensaver.py b/Xlib/ext/screensaver.py new file mode 100644 index 00000000..90fb68a6 --- /dev/null +++ b/Xlib/ext/screensaver.py @@ -0,0 +1,198 @@ +# Xlib.ext.screensaver -- X ScreenSaver extension module +# +# Copyright (C) 2022 Vladimir Panteleev +# +# 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., +# 51 Franklin Street, +# Fifth Floor, +# Boston, MA 02110-1301 USA + +"""This extension allows registering the client as an X screensaver, +or query information about the current screensaver. + +For detailed description see any of the following documents. +Protocol specification: + https://www.x.org/releases/X11R7.7/doc/scrnsaverproto/saver.html +XCB Protocol specification: + https://cgit.freedesktop.org/xcb/proto/tree/src/screensaver.xml + +""" + +from Xlib import X +from Xlib.protocol import rq, structs + +extname = 'MIT-SCREEN-SAVER' + +# Event members +NotifyMask = 1 +CycleMask = 2 + +# Notify state +StateOff = 0 +StateOn = 1 +StateCycle = 2 + +# Notify kind +KindBlanked = 0 +KindInternal = 1 +KindExternal = 2 + +class QueryVersion(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + rq.Card8('major_version'), + rq.Card8('minor_version'), + rq.Pad(2), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card8('major_version'), + rq.Card8('minor_version'), + rq.Pad(22), + ) + +def query_version(self): + return QueryVersion(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=0) + + +class QueryInfo(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + rq.Drawable('drawable'), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('state'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Window('saver_window'), + rq.Card32('til_or_since'), + rq.Card32('idle'), + rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), + rq.Card8('kind'), + rq.Pad(10), + ) + +def query_info(self): + return QueryInfo(display=self.display, + opcode=self.display.get_extension_major(extname), + drawable=self, + ) + + +class SelectInput(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + rq.Drawable('drawable'), + rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), + ) + +def select_input(self, mask): + return SelectInput(display=self.display, + opcode=self.display.get_extension_major(extname), + drawable=self, + event_mask=mask, + ) + + +class SetAttributes(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + rq.Drawable('drawable'), + rq.Int16('x'), + rq.Int16('y'), + rq.Card16('width'), + rq.Card16('height'), + rq.Card16('border_width'), + rq.Set('window_class', 1, (X.CopyFromParent, X.InputOutput, X.InputOnly)), + rq.Card8('depth'), + rq.Card32('visual'), + structs.WindowValues('attrs'), + ) + +def set_attributes(self, x, y, width, height, border_width, + window_class = X.CopyFromParent, + depth = X.CopyFromParent, + visual = X.CopyFromParent, + onerror = None, + **keys): + return SetAttributes(display=self.display, + onerror = onerror, + opcode=self.display.get_extension_major(extname), + drawable=self, + x = x, + y = y, + width = width, + height = height, + border_width = border_width, + window_class = window_class, + depth = depth, + visual = visual, + attrs = keys) + + +class UnsetAttributes(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + rq.Drawable('drawable'), + ) + +def unset_attributes(self, onerror = None): + return UnsetAttributes(display=self.display, + onerror = onerror, + opcode=self.display.get_extension_major(extname), + drawable=self) + + +class Notify(rq.Event): + _code = None + _fields = rq.Struct( + rq.Card8('type'), + rq.Set('state', 1, (StateOff, StateOn, StateCycle)), + rq.Card16('sequence_number'), + rq.Card32('timestamp'), + rq.Window('root'), + rq.Window('window'), + rq.Set('kind', 1, (KindBlanked, KindInternal, KindExternal)), + rq.Bool('forced'), + rq.Pad(14), + ) + +def init(disp, info): + disp.extension_add_method('display', 'screensaver_query_version', query_version) + disp.extension_add_method('drawable', 'screensaver_query_info', query_info) + disp.extension_add_method('drawable', 'screensaver_select_input', select_input) + disp.extension_add_method('drawable', 'screensaver_set_attributes', set_attributes) + disp.extension_add_method('drawable', 'screensaver_unset_attributes', unset_attributes) + + disp.extension_add_event(info.first_event + 0, Notify) From e8cf018557470a2735315c8ba5327cfee8a8124f Mon Sep 17 00:00:00 2001 From: Dan Isla Date: Fri, 4 Feb 2022 08:14:20 +0000 Subject: [PATCH 078/100] XFixes: add support for XFixesCursorNotify --- Xlib/ext/xfixes.py | 61 ++++++++++++++++++++++++++- examples/xfixes-cursor-notify.py | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100755 examples/xfixes-cursor-notify.py diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 5f2f6438..59f9277b 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -25,19 +25,23 @@ ShowCursor requests and SelectionNotify events are provided. ''' -from Xlib.protocol import rq +from Xlib import X +from Xlib.protocol import rq, structs extname = 'XFIXES' XFixesSelectionNotify = 0 +XFixesCursorNotify = 1 XFixesSetSelectionOwnerNotifyMask = (1 << 0) XFixesSelectionWindowDestroyNotifyMask = (1 << 1) XFixesSelectionClientCloseNotifyMask = (1 << 2) +XFixesDisplayCursorNotifyMask = (1 << 0) XFixesSetSelectionOwnerNotify = 0 XFixesSelectionWindowDestroyNotify = 1 XFixesSelectionClientCloseNotify = 2 +XFixesDisplayCursorNotify = 0 class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), @@ -131,12 +135,67 @@ class SelectionClientCloseNotify(SelectionNotify): pass +class SelectCursorInput(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + rq.Window('window'), + rq.Card32('mask') + ) + +def select_cursor_input(self, window, mask): + return SelectCursorInput(opcode=self.display.get_extension_major(extname), + display=self.display, + window=window, + cursor_serial=0, + mask=mask) + + +class GetCursorImage(rq.ReplyRequest): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength() + ) + _reply = rq.Struct(rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Int16('x'), + rq.Int16('y'), + rq.Card16('width'), + rq.Card16('height'), + rq.Card16('xhot'), + rq.Card16('yhot'), + rq.Card32('cursor_serial'), + rq.Pad(8), + rq.List('cursor_image', rq.Card32) + ) + +def get_cursor_image(self, window): + return GetCursorImage(opcode=self.display.get_extension_major(extname), + display=self.display, + ) + + +class DisplayCursorNotify(rq.Event): + _code = None + _fields = rq.Struct(rq.Card8('type'), + rq.Card8('sub_code'), + rq.Card16('sequence_number'), + rq.Window('window'), + rq.Card32('cursor_serial'), + rq.Card32('timestamp')) + + def init(disp, info): disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input) disp.extension_add_method('display', 'xfixes_query_version', query_version) disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) + disp.extension_add_method('display', 'xfixes_select_cursor_input', select_cursor_input) + disp.extension_add_method('display', 'xfixes_get_cursor_image', get_cursor_image) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify) + disp.extension_add_subevent(info.first_event + XFixesCursorNotify, XFixesDisplayCursorNotify, DisplayCursorNotify) diff --git a/examples/xfixes-cursor-notify.py b/examples/xfixes-cursor-notify.py new file mode 100755 index 00000000..cc443fe9 --- /dev/null +++ b/examples/xfixes-cursor-notify.py @@ -0,0 +1,72 @@ +#!/usr/bin/python3 +# +# examples/xfixes-cursor-notify.py -- demonstrate the XFIXES extension +# CursorNotify event. +# +# Copyright (C) 2022 +# Dan Isla +# +# 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 + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +from Xlib.display import Display +from Xlib.ext import xfixes + +def main(): + display = Display() + + if not display.has_extension('XFIXES'): + if display.query_extension('XFIXES') is None: + print('XFIXES extension not supported') + return 1 + + xfixes_version = display.xfixes_query_version() + print('Found XFIXES version {}.{}'.format( + xfixes_version.major_version, + xfixes_version.minor_version + )) + + screen = display.screen() + + display.xfixes_select_cursor_input(screen.root, xfixes.XFixesDisplayCursorNotifyMask) + + cursor_cache = {} + + while True: + e = display.next_event() + print(e) + + if (e.type, e.sub_code) == display.extension_event.DisplayCursorNotify: + print("DisplayCursorNotify: cursor_serial={}".format(e.cursor_serial)) + image = display.xfixes_get_cursor_image(screen.root) + cached = False + if cursor_cache.get(image.cursor_serial): + cached = True + else: + cursor_cache[image.cursor_serial] = image.cursor_image + + print("Cursor position={},{}, size={}x{}, xyhot={},{}, cursor_serial={}, cached={}".format( + image.x, image.y, image.width,image.height, image.xhot, image.yhot, image.cursor_serial, cached + )) + + +if __name__ == "__main__": + sys.exit(main()) From c53a13ff61a0eecef23819141a4cf182055f8b3f Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Mon, 6 Jun 2022 18:31:46 -0400 Subject: [PATCH 079/100] Fix screensaver protocol mismatch The protocol encoding specified in the X11 documentation differs from the actual XCB protocol that Xorg uses. This makes `query_version()` report the wrong version and `query_info()` fail by trying to unpack too many bytes. --- Xlib/ext/screensaver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/screensaver.py b/Xlib/ext/screensaver.py index 90fb68a6..12f4325c 100644 --- a/Xlib/ext/screensaver.py +++ b/Xlib/ext/screensaver.py @@ -64,9 +64,9 @@ class QueryVersion(rq.ReplyRequest): rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Card8('major_version'), - rq.Card8('minor_version'), - rq.Pad(22), + rq.Card16('major_version'), + rq.Card16('minor_version'), + rq.Pad(20), ) def query_version(self): @@ -94,7 +94,7 @@ class QueryInfo(rq.ReplyRequest): rq.Card32('idle'), rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), rq.Card8('kind'), - rq.Pad(10), + rq.Pad(7), ) def query_info(self): From 0feed9097dc8f1012edd7dfe0c849def601b97d0 Mon Sep 17 00:00:00 2001 From: Peter Ye Date: Sun, 10 Jul 2022 22:12:41 -0400 Subject: [PATCH 080/100] Use archived link for X documentation resource --- doc/src/concepts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/concepts.texi b/doc/src/concepts.texi index 8c9f08b0..d71f62fe 100644 --- a/doc/src/concepts.texi +++ b/doc/src/concepts.texi @@ -9,4 +9,4 @@ Here you might find an introduction to X concepts sometime in the future. For now, I just refer to the introduction parts of the standard X documentation. A vast collection of X documentation links can be -found at @uref{http://www.rahul.net/kenton/xsites.html}. +found at @uref{https://web.archive.org/web/20201228053920/http://www.rahul.net/kenton/xsites.html}. From 93b294742c77e7b92bfc685e3a3f8d1b481d8cf9 Mon Sep 17 00:00:00 2001 From: Majiir Paktu Date: Fri, 15 Jul 2022 21:42:13 -0400 Subject: [PATCH 081/100] xauth: fix for auth entry having no display number --- Xlib/xauth.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index 2ed7dd52..303bd491 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -120,6 +120,8 @@ def get_best_auth(self, family, address, dispno, matches = {} for efam, eaddr, enum, ename, edata in self.entries: + if enum == b'' and ename not in matches: + enum = num if efam == family and eaddr == address and num == enum: matches[ename] = edata From 75100a2fe0847753cbf51e41f1adeb14fe8cc20a Mon Sep 17 00:00:00 2001 From: allfro Date: Mon, 9 May 2022 17:03:00 -0400 Subject: [PATCH 082/100] Update rq.py Fixes return type inconsistency with the `pack_value` for class `Object`. When using an `Object` field embedded in a request `pack_value` croaks because it calls to_binary which returns a byte buffer instead of a 3-value tuple. This fix addresses the issue. --- Xlib/protocol/rq.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 86cb2def..8a0cd6b0 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -604,7 +604,8 @@ def parse_value(self, val, display): return self.type.parse_value(val, display) def pack_value(self, val): - return self.type.pack_value(val) + val = self.type.pack_value(val) + return val, len(val), None def check_value(self, val): if isinstance(val, tuple): From b1bc5624b79a7a02eca3287be71a7fa58e328ec5 Mon Sep 17 00:00:00 2001 From: allfro Date: Mon, 9 May 2022 17:16:32 -0400 Subject: [PATCH 083/100] Update randr.py Add version 1.5 support for RRSetMonitor RRGetMonitors and RRDeleteMonitors --- Xlib/ext/randr.py | 96 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 48f4b635..ba37d60c 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -25,7 +25,7 @@ This implementation is based off version 1.3 of the XRandR protocol, and may not be compatible with other versions. -Version 1.2 of the protocol is documented at: +Version 1.5 of the protocol is documented at: http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt Version 1.3.1 here: @@ -168,6 +168,19 @@ rq.Card32('matrix33'), ) +MonitorInfo = rq.Struct( + rq.Card32('name'), + rq.Bool('primary'), + rq.Bool('automatic'), + rq.LengthOf('crtcs', 2), + rq.Int16('x'), + rq.Int16('y'), + rq.Card16('width_in_pixels'), + rq.Card16('height_in_pixels'), + rq.Card32('width_in_millimeters'), + rq.Card32('height_in_millimeters'), + rq.List('crtcs', rq.Card32Obj) +) # Requests # @@ -197,7 +210,7 @@ def query_version(self): display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, - minor_version=3, + minor_version=5, ) @@ -1078,6 +1091,76 @@ def get_output_primary(self): ) +# Version 1.5 methods + +class GetMonitors(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(42), + rq.RequestLength(), + rq.Window('window'), + rq.Bool('is_active'), + rq.Pad(3) + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('timestamp'), + rq.LengthOf('monitors', 4), + rq.Card32('outputs'), + rq.Pad(12), + rq.List('monitors', MonitorInfo) + ) + + +def get_monitors(self, is_active=True): + return GetMonitors( + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + is_active=is_active + ) + +class SetMonitor(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(43), + rq.RequestLength(), + rq.Window('window'), + rq.Object('monitor_info', MonitorInfo) + ) + + +def set_monitor(self, monitor_info): + return SetMonitor( + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + monitor_info=monitor_info + ) + + +class DeleteMonitor(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(44), + rq.RequestLength(), + rq.Window('window'), + rq.Card32('name') + ) + + +def delete_monitor(self, name): + return DeleteMonitor( + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + name=name + ) + # Events # class ScreenChangeNotify(rq.Event): @@ -1149,8 +1232,8 @@ class OutputPropertyNotify(rq.Event): rq.Card8('state'), rq.Pad(11), ) - - + + # Initialization # def init(disp, info): @@ -1186,6 +1269,11 @@ def init(disp, info): disp.extension_add_method('display', 'xrandr_get_panning', get_panning) disp.extension_add_method('display', 'xrandr_set_panning', set_panning) + # version 1.5 compatible + disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) + disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) + disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) + disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) # add RRNotify events (1 event code with 3 subcodes) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) From b8835036e2be7c0deb46e66db4eb7564437c8fdb Mon Sep 17 00:00:00 2001 From: James Longmore Date: Sun, 11 Sep 2022 14:59:17 +1000 Subject: [PATCH 084/100] Address comments in python-xlib/python-xlib#224 --- Xlib/ext/randr.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index ba37d60c..d054de0e 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -22,7 +22,7 @@ """RandR - provide access to the RandR extension information. -This implementation is based off version 1.3 of the XRandR protocol, and may +This implementation is based off version 1.5 of the XRandR protocol, and may not be compatible with other versions. Version 1.5 of the protocol is documented at: @@ -1232,8 +1232,6 @@ class OutputPropertyNotify(rq.Event): rq.Card8('state'), rq.Pad(11), ) - - # Initialization # def init(disp, info): @@ -1269,17 +1267,20 @@ def init(disp, info): disp.extension_add_method('display', 'xrandr_get_panning', get_panning) disp.extension_add_method('display', 'xrandr_set_panning', set_panning) - # version 1.5 compatible - disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) - disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) - disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) - - disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) - # add RRNotify events (1 event code with 3 subcodes) - disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) - disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) - disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) - - #disp.extension_add_error(BadRROutput, BadRROutputError) - #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) - #disp.extension_add_error(BadRRMode, BadRRModeError) + # If the server is running RANDR 1.5+, enable 1.5 compatible methods and events + version = query_version(disp) + if version.major_version == 1 and version.minor_version >= 5: + # version 1.5 compatible + disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) + disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) + disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) + + disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) + # add RRNotify events (1 event code with 3 subcodes) + disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) + disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) + disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) + + #disp.extension_add_error(BadRROutput, BadRROutputError) + #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) + #disp.extension_add_error(BadRRMode, BadRRModeError) From 29d67c733a49c26956a9b0eed08f2a9fe98f315d Mon Sep 17 00:00:00 2001 From: James Longmore Date: Sat, 17 Sep 2022 11:08:14 +1000 Subject: [PATCH 085/100] Revert changes to rq.py --- Xlib/protocol/rq.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 8a0cd6b0..86cb2def 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -604,8 +604,7 @@ def parse_value(self, val, display): return self.type.parse_value(val, display) def pack_value(self, val): - val = self.type.pack_value(val) - return val, len(val), None + return self.type.pack_value(val) def check_value(self, val): if isinstance(val, tuple): From c87624dd6ec780417e2d32529976d65fed344045 Mon Sep 17 00:00:00 2001 From: James Longmore Date: Sat, 17 Sep 2022 11:11:18 +1000 Subject: [PATCH 086/100] Add Randr error classes and register them during init --- Xlib/ext/randr.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index d054de0e..256e3dee 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -34,6 +34,7 @@ """ +from tkinter import W from Xlib import X from Xlib.protocol import rq, structs @@ -122,6 +123,12 @@ BadRRCrtc = 1 BadRRMode = 2 +# Error classes # +class BadRROutputError(Exception): pass + +class BadRRCrtcError(Exception): pass + +class BadRRModeError(Exception): pass # Data Structures # @@ -1281,6 +1288,6 @@ def init(disp, info): disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) - #disp.extension_add_error(BadRROutput, BadRROutputError) - #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) - #disp.extension_add_error(BadRRMode, BadRRModeError) + disp.extension_add_error(BadRROutput, BadRROutputError) + disp.extension_add_error(BadRRCrtc, BadRRCrtcError) + disp.extension_add_error(BadRRMode, BadRRModeError) From 5a7ebe72c4281b3f5f875223c312a220bdd524e4 Mon Sep 17 00:00:00 2001 From: Matt Alexander Date: Mon, 31 Oct 2022 16:43:11 -0500 Subject: [PATCH 087/100] Fix Issue 233: Rename `add_extension_error` method --- Xlib/display.py | 4 ++-- Xlib/ext/damage.py | 2 +- test/test_xlib_display.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index ead0185c..e0f7b5c8 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -340,8 +340,8 @@ def extension_add_subevent(self, code, subcode, evt, name = None): # extension dict maintained in the display object setattr(self.extension_event, name, (code,subcode)) - def add_extension_error(self, code, err): - """add_extension_error(code, err) + def extension_add_error(self, code, err): + """extension_add_error(code, err) Add an extension error. CODE is the numeric code, and ERR is the error class. diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py index 0cde5ed0..60c56606 100644 --- a/Xlib/ext/damage.py +++ b/Xlib/ext/damage.py @@ -179,4 +179,4 @@ def init(disp, info): disp.extension_add_event(info.first_event + DamageNotifyCode, DamageNotify) - disp.add_extension_error(code=BadDamageCode, err=BadDamageError) + disp.extension_add_error(code=BadDamageCode, err=BadDamageError) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index fb617a3a..61994617 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -87,7 +87,7 @@ def test_cannot_add_existing_font_method(self): self.assertRaises(AssertionError, self.display.extension_add_method, "font", "__init__", lambda x: x) def test_can_add_extension_error(self): - self.display.add_extension_error(1, Xlib.error.XError) + self.display.extension_add_error(1, Xlib.error.XError) self.assertEqual(self.display.display.error_classes[1], Xlib.error.XError) def test_keycode_to_keysym_for_invalid_index(self): From 333fbcbc93501c86d84a70d704746360ee640dff Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Tue, 1 Nov 2022 13:18:12 +0300 Subject: [PATCH 088/100] Update CHANGELOG, bump version to 0.32 --- CHANGELOG.md | 18 ++++++++++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b960a8d9..cac28024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ NEWS for Python X Library +Version 0.32 +============ + +Bug Fixes +--------- + +- Use archived link for X documentation resource (thanks @yaxollum). +- Fix for auth entry having no display number (thanks @Majiir). +- Fix return type inconsistency with the `pack_value` for class `Object` (thanks @allfro). +- Rename `add_extension_error` method to `extension_add_error` (thanks @mattalexx). + +Extensions +-------------------- + +- screensaver: fix screensaver protocol mismatch (thanks @yut23). +- XRandr: add version 1.5 support for RRSetMonitor RRGetMonitors and RRDeleteMonitors (thanks @allfro and @jklong). + +--- Version 0.31 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 89473730..9db8beec 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 31) +__version__ = (0, 32) __version_extra__ = '' From 32fafd9c92fab359b85bf3460c8af8347cad4ed5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 4 Nov 2022 18:45:10 -0400 Subject: [PATCH 089/100] Removed unused imports --- Xlib/ext/composite.py | 1 - Xlib/ext/damage.py | 1 - Xlib/ext/dpms.py | 1 - Xlib/ext/randr.py | 2 +- Xlib/ext/record.py | 1 - Xlib/ext/xfixes.py | 3 +-- 6 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index 0e10b635..5909b31e 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -33,7 +33,6 @@ graphics. """ -from Xlib import X from Xlib.protocol import rq from Xlib.xobject import drawable diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py index 60c56606..126d8507 100644 --- a/Xlib/ext/damage.py +++ b/Xlib/ext/damage.py @@ -22,7 +22,6 @@ from Xlib import X from Xlib.protocol import rq, structs -from Xlib.xobject import resource from Xlib.error import XError extname = 'DAMAGE' diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py index 3ff9a246..20b570bc 100644 --- a/Xlib/ext/dpms.py +++ b/Xlib/ext/dpms.py @@ -27,7 +27,6 @@ Documentation: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html ''' -from Xlib import X from Xlib.protocol import rq extname = 'DPMS' diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 256e3dee..61ce727d 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -34,7 +34,7 @@ """ -from tkinter import W +W = "w" from Xlib import X from Xlib.protocol import rq, structs diff --git a/Xlib/ext/record.py b/Xlib/ext/record.py index bb53ec19..638a5b38 100644 --- a/Xlib/ext/record.py +++ b/Xlib/ext/record.py @@ -19,7 +19,6 @@ # Suite 330, # Boston, MA 02111-1307 USA -from Xlib import X from Xlib.protocol import rq extname = 'RECORD' diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 59f9277b..8b3c35fe 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -25,8 +25,7 @@ ShowCursor requests and SelectionNotify events are provided. ''' -from Xlib import X -from Xlib.protocol import rq, structs +from Xlib.protocol import rq extname = 'XFIXES' From 1791c97c3470c19e0645de2d32bfbeb0212b9b4e Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 13:45:42 -0500 Subject: [PATCH 090/100] Update Xlib/ext/randr.py --- Xlib/ext/randr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 61ce727d..4003c8af 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -34,7 +34,6 @@ """ -W = "w" from Xlib import X from Xlib.protocol import rq, structs From dd01cee066fa1fd37a146b29bc3686abbd85877d Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:22:25 -0500 Subject: [PATCH 091/100] Update Xlib/ext/randr.py --- Xlib/ext/randr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 4003c8af..9cbfe2da 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -35,7 +35,7 @@ from Xlib import X -from Xlib.protocol import rq, structs +from Xlib.protocol import rq extname = 'RANDR' From a9890197d9c65753462f3e2f505b5e3750bf8842 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:24:42 -0500 Subject: [PATCH 092/100] Update xinerama.py --- Xlib/ext/xinerama.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Xlib/ext/xinerama.py b/Xlib/ext/xinerama.py index f0546707..dcb78b89 100644 --- a/Xlib/ext/xinerama.py +++ b/Xlib/ext/xinerama.py @@ -35,7 +35,6 @@ returns the state information - because that's what libXinerama does.""" -from Xlib import X from Xlib.protocol import rq, structs extname = 'XINERAMA' From cf11374a42c656f0bb691f2f49f9e4d0fe32bb5e Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:29:12 -0500 Subject: [PATCH 093/100] Update rq.py --- Xlib/protocol/rq.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 86cb2def..c1eba34b 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -24,7 +24,6 @@ import traceback import struct from array import array -import types # Python 2/3 compatibility. from six import PY3, binary_type, byte2int, indexbytes, iterbytes From b091980a349fb32a2d96824f144d7131732c8158 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:32:05 -0500 Subject: [PATCH 094/100] Update drawable.py --- Xlib/xobject/drawable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index c36a9738..3a56f532 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -from Xlib import X, Xatom, Xutil +from Xlib import X, Xatom from Xlib.protocol import request, rq # Other X resource objects From 06cd8219872d422baa5a926d2dea11579d2bc8ad Mon Sep 17 00:00:00 2001 From: Yasushi Itoh Date: Sun, 2 Jan 2022 10:04:33 +0900 Subject: [PATCH 095/100] Avoid to use fcntl module on some environments --- Xlib/support/unix_connect.py | 47 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index c2261dae..bd690c18 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -23,23 +23,6 @@ import os import platform import socket - -# FCNTL is deprecated from Python 2.2, so only import it if we doesn't -# get the names we need. Furthermore, FD_CLOEXEC seems to be missing -# in Python 2.2. - -import fcntl - -if hasattr(fcntl, 'F_SETFD'): - F_SETFD = fcntl.F_SETFD - if hasattr(fcntl, 'FD_CLOEXEC'): - FD_CLOEXEC = fcntl.FD_CLOEXEC - else: - FD_CLOEXEC = 1 -else: - from FCNTL import F_SETFD, FD_CLOEXEC - - from Xlib import error, xauth @@ -93,11 +76,13 @@ def _get_tcp_socket(host, dno): s.connect((host, 6000 + dno)) return s + def _get_unix_socket(address): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(address) return s + def get_socket(dname, protocol, host, dno): assert protocol in SUPPORTED_PROTOCOLS try: @@ -127,11 +112,37 @@ def get_socket(dname, protocol, host, dno): raise error.DisplayConnectionError(dname, str(val)) # Make sure that the connection isn't inherited in child processes. - fcntl.fcntl(s.fileno(), F_SETFD, FD_CLOEXEC) + _ensure_not_inheritable(s) return s +def _ensure_not_inheritable(sock): + # According to PEP446, in Python 3.4 and above, + # it is not inherited in child processes by default. + # However, just in case, we explicitly make it non-inheritable. + # Also, we don't use the code like the following, + # because there would be no possibility of backporting to past versions. + # if sys.version_info.major == 3 and sys.version_info.minor >= 4: + # sock.set_inheritable(False) + # return + # We just check if the socket has `set_inheritable`. + if hasattr(sock, 'set_inheritable'): + sock.set_inheritable(False) + return + + # On Windows, + # Python doesn't support fcntl module because Windows doesn't have fcntl API. + # At least by not importing fcntl, we will be able to import python-xlib on Windows. + if platform.system() == 'Windows': + # so.. unfortunately, for Python 3.3 and below, on Windows, + # we can't make sure that the connection isn't inherited in child processes for now. + return + + import fcntl + fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) + + def new_get_auth(sock, dname, protocol, host, dno): assert protocol in SUPPORTED_PROTOCOLS # Translate socket address into the xauth domain From 1127b311b3dce054eebc2deabc6f96b41310b92e Mon Sep 17 00:00:00 2001 From: Yasushi Itoh Date: Sun, 2 Jan 2022 17:40:10 +0900 Subject: [PATCH 096/100] Change a test behavior for unix_connect.get_socket --- test/test_unix_connect.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/test_unix_connect.py b/test/test_unix_connect.py index 7680ba5b..3199fa5f 100644 --- a/test/test_unix_connect.py +++ b/test/test_unix_connect.py @@ -72,8 +72,8 @@ def _get_socket(socket_type, raises, *params): def path_exists(returns, path): calls.append(('os.path.exists', path)) return returns - def fcntl(*args): - calls.append(('fcntl',) + args) + def ensure_not_inheritable(*args): + calls.append(('ensure_not_inheritable',) + args) for params, allow_unix, unix_addr_exists, allow_tcp, expect_connection_error, expected_calls in ( # Successful explicit TCP socket connection. (('tcp/host:6', None, 'host', 6), False, False, True, False, [ @@ -141,7 +141,7 @@ def fcntl(*args): partial(_get_socket, 'tcp', not allow_tcp)), \ patch('os.path.exists', partial(path_exists, unix_addr_exists)), \ - patch('fcntl.fcntl', fcntl): + patch('Xlib.support.unix_connect._ensure_not_inheritable', ensure_not_inheritable): del calls[:] if expect_connection_error: with self.assertRaises(DisplayConnectionError): @@ -149,9 +149,7 @@ def fcntl(*args): else: s = unix_connect.get_socket(*params) self.assertIsInstance(s, FakeSocket) - expected_calls.append(('fcntl', 42, - unix_connect.F_SETFD, - unix_connect.FD_CLOEXEC)) + expected_calls.append(('ensure_not_inheritable', s)) self.assertEqual(calls, expected_calls) From 9f406d4e50a4b947915739ea4e1068b78fd5910d Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 19:22:09 -0500 Subject: [PATCH 097/100] Prefer `bool` over `Literal[0, 1, None]` --- Xlib/display.py | 8 ++++---- Xlib/error.py | 2 +- Xlib/protocol/display.py | 28 ++++++++++++++-------------- Xlib/protocol/rq.py | 20 ++++++++++---------- Xlib/xobject/drawable.py | 6 +++--- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index e0f7b5c8..87b9aa61 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -71,7 +71,7 @@ def __init__(self, *args, **keys): protocol_display.Display.__init__(self, *args, **keys) self._atom_cache = {} - def get_atom(self, atomname, only_if_exists=0): + def get_atom(self, atomname, only_if_exists=False): if atomname in self._atom_cache: return self._atom_cache[atomname] @@ -473,7 +473,7 @@ def rebind_string(self, keysym, newstring): ### X requests ### - def intern_atom(self, name, only_if_exists = 0): + def intern_atom(self, name, only_if_exists = False): """Intern the string name, returning its atom number. If only_if_exists is true and the atom does not already exist, it will not be created and X.NONE is returned.""" @@ -482,7 +482,7 @@ def intern_atom(self, name, only_if_exists = 0): only_if_exists = only_if_exists) return r.atom - def get_atom(self, atom, only_if_exists = 0): + def get_atom(self, atom, only_if_exists = False): """Alias for intern_atom, using internal cache""" return self.display.get_atom(atom, only_if_exists) @@ -501,7 +501,7 @@ def get_selection_owner(self, selection): selection = selection) return r.owner - def send_event(self, destination, event, event_mask = 0, propagate = 0, + def send_event(self, destination, event, event_mask = 0, propagate = False, onerror = None): """Send a synthetic event to the window destination which can be a window object, or X.PointerWindow or X.InputFocus. event is the diff --git a/Xlib/error.py b/Xlib/error.py index cb6d0d07..3b6e13f8 100644 --- a/Xlib/error.py +++ b/Xlib/error.py @@ -70,7 +70,7 @@ class XError(rq.GetAttrData, Exception): ) def __init__(self, display, data): - self._data, data = self._fields.parse_binary(data, display, rawdict = 1) + self._data, _ = self._fields.parse_binary(data, display, rawdict = True) def __str__(self): s = [] diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 56623c35..4bd939e9 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -214,7 +214,7 @@ def next_event(self): # Call send_and_recv, which will return when # something has occured - self.send_and_recv(event = 1) + self.send_and_recv(event = True) # Before looping around, lock the event queue against # modifications. @@ -240,7 +240,7 @@ def pending_events(self): # Make a send_and_recv pass, receiving any events self.send_recv_lock.acquire() - self.send_and_recv(recv = 1) + self.send_and_recv(recv = True) # Lock the queue, get the event count, and unlock again. self.event_queue_write_lock.acquire() @@ -252,7 +252,7 @@ def pending_events(self): def flush(self): self.check_for_error() self.send_recv_lock.acquire() - self.send_and_recv(flush = 1) + self.send_and_recv(flush = True) def close(self): self.flush() @@ -384,7 +384,7 @@ def close_internal(self, whom): self.socket_error_lock.release() - def send_and_recv(self, flush = None, event = None, request = None, recv = None): + def send_and_recv(self, flush = False, event = False, request = None, recv = False): """send_and_recv(flush = None, event = None, request = None, recv = None) Perform I/O, or wait for some other thread to do it for us. @@ -689,8 +689,8 @@ def parse_response(self, request): return self.parse_connection_setup() # Parse ordinary server response - gotreq = 0 - while 1: + gotreq = False + while True: if self.data_recv: # Check the first byte to find out what kind of response it is rtype = byte2int(self.data_recv) @@ -772,7 +772,7 @@ def parse_error_response(self, request): else: self.default_error_handler(e) - return 0 + return False def default_error_handler(self, err): @@ -937,7 +937,7 @@ def parse_connection_setup(self): # Only the ConnectionSetupRequest has been sent so far r = self.sent_requests[0] - while 1: + while True: # print 'data_send:', repr(self.data_send) # print 'data_recv:', repr(self.data_recv) @@ -946,7 +946,7 @@ def parse_connection_setup(self): # The full response haven't arrived yet if len(self.data_recv) < alen: - return 0 + return False # Connection failed or further authentication is needed. # Set reason to the reason string @@ -956,22 +956,22 @@ def parse_connection_setup(self): # Else connection succeeded, parse the reply else: x, d = r._success_reply.parse_binary(self.data_recv[:alen], - self, rawdict = 1) + self, rawdict = True) r._data.update(x) del self.sent_requests[0] self.data_recv = self.data_recv[alen:] - return 1 + return True else: # The base reply is 8 bytes long if len(self.data_recv) < 8: - return 0 + return False r._data, d = r._reply.parse_binary(self.data_recv[:8], - self, rawdict = 1) + self, rawdict = True) self.data_recv = self.data_recv[8:] # Loop around to see if we have got the additional data @@ -1066,7 +1066,7 @@ def __init__(self, display, *args, **keys): # Don't bother about locking, since no other threads have # access to the display yet - display.request_queue.append((self, 1)) + display.request_queue.append((self, True)) # However, we must lock send_and_recv, but we don't have # to loop. diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index c1eba34b..5fff5e77 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -118,7 +118,7 @@ class Field(object): check_value = None parse_value = None - keyword_args = 0 + keyword_args = False def __init__(self): pass @@ -723,7 +723,7 @@ def pack_value(self, value): class ValueList(Field): structcode = None - keyword_args = 1 + keyword_args = True default = 'usekeywords' def __init__(self, name, mask, pad, *fields): @@ -1088,7 +1088,7 @@ def pack_value(self, value): raise BadDataError('%s is not a tuple or a list' % (value)) - def parse_value(self, val, display, rawdict = 0): + def parse_value(self, val, display, rawdict = False): """This function is used by List and Object fields to convert Struct objects with no var_fields into Python values. @@ -1131,9 +1131,9 @@ def parse_value(self, val, display, rawdict = 0): return DictWrapper(ret) return ret - def parse_binary(self, data, display, rawdict = 0): + def parse_binary(self, data, display, rawdict = False): - """values, remdata = s.parse_binary(data, display, rawdict = 0) + """values, remdata = s.parse_binary(data, display, rawdict = False) Convert a binary representation of the structure into Python values. @@ -1354,16 +1354,16 @@ def _set_error(self, error): return 0 class ReplyRequest(GetAttrData): - def __init__(self, display, defer = 0, *args, **keys): + def __init__(self, display, defer = False, *args, **keys): self._display = display self._binary = self._request.to_binary(*args, **keys) self._serial = None - self._data = None + self._data = {} self._error = None self._response_lock = lock.allocate_lock() - self._display.send_request(self, 1) + self._display.send_request(self, True) if not defer: self.reply() @@ -1389,7 +1389,7 @@ def reply(self): def _parse_response(self, data): self._response_lock.acquire() - self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1) + self._data, d = self._reply.parse_binary(data, self._display, rawdict = True) self._response_lock.release() def _set_error(self, error): @@ -1408,7 +1408,7 @@ def __init__(self, binarydata = None, display = None, if binarydata: self._binary = binarydata self._data, data = self._fields.parse_binary(binarydata, display, - rawdict = 1) + rawdict = True) # split event type into type and send_event bit self._data['send_event'] = not not self._data['type'] & 0x80 self._data['type'] = self._data['type'] & 0x7f diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 3a56f532..f8e625f6 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -451,7 +451,7 @@ def delete_property(self, property, onerror = None): window = self.id, property = property) - def get_property(self, property, property_type, offset, length, delete = 0): + def get_property(self, property, property_type, offset, length, delete = False): r = request.GetProperty(display = self.display, delete = delete, window = self.id, @@ -516,7 +516,7 @@ def convert_selection(self, selection, target, property, time, onerror = None): property = property, time = time) - def send_event(self, event, event_mask = 0, propagate = 0, onerror = None): + def send_event(self, event, event_mask = 0, propagate = False, onerror = None): request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, @@ -629,7 +629,7 @@ def set_input_focus(self, revert_to, time, onerror = None): focus = self.id, time = time) - def clear_area(self, x = 0, y = 0, width = 0, height = 0, exposures = 0, onerror = None): + def clear_area(self, x = 0, y = 0, width = 0, height = 0, exposures = False, onerror = None): request.ClearArea(display = self.display, onerror = onerror, exposures = exposures, From fdf873908ed300d4af685fe889079df0f5b7845f Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 18 Nov 2022 15:42:54 -0500 Subject: [PATCH 098/100] fix accidental data change --- Xlib/protocol/display.py | 2 +- Xlib/protocol/rq.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 4bd939e9..0d910dab 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -402,7 +402,7 @@ def send_and_recv(self, flush = False, event = False, request = None, recv = Fal To wait for an event to be received, event should be true. To wait for a response to a certain request (either an error - or a response), request should be set the that request's + or a response), request should be set to that request's serial number. To just read any pending data from the server, recv should be true. diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 5fff5e77..8bc82059 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1358,7 +1358,7 @@ def __init__(self, display, defer = False, *args, **keys): self._display = display self._binary = self._request.to_binary(*args, **keys) self._serial = None - self._data = {} + self._data = None self._error = None self._response_lock = lock.allocate_lock() From b04e96a39b8ae0b82c52d0385d1edc1d8f96cb6a Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Thu, 15 Dec 2022 22:07:31 +0100 Subject: [PATCH 099/100] Change parentheses to brackets in LICENSE --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 19e30718..d762d815 100644 --- a/LICENSE +++ b/LICENSE @@ -6,9 +6,9 @@ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -(This is the first released version of the Lesser GPL. It also counts +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.) + the version number 2.1.] Preamble From 4e8bbf8fc4941e5da301a8b3db8d27e98de68666 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 25 Dec 2022 21:49:10 +0300 Subject: [PATCH 100/100] Update CHANGELOG, bump version to 0.33 --- CHANGELOG.md | 14 ++++++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cac28024..74eb66b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ NEWS for Python X Library +Version 0.33 +============ + +Bug Fixes +--------- + +- Removed unused imports (thanks @Avasam). +- Avoid to use fcntl module on some environments (thanks @i2y). +- Change a test behavior for `unix_connect.get_socket` (thanks @i2y). +- Fix accidental data change (thanks @Avasam). +- Prefer `bool` over `Literal[0, 1, None]` (thanks @Avasam). +- Change parentheses to brackets in LICENSE (thanks @mtelka). + +--- Version 0.32 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 9db8beec..28a0e017 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 32) +__version__ = (0, 33) __version_extra__ = ''