aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-02 07:15:33 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-02 07:15:33 +0200
commitdc23100deca3d750aa56b7f246da307f2feb9310 (patch)
treebb6cf8387c534d2f903a016939279bbdae7e3667
parentm (diff)
downloadpylibgamma-dc23100deca3d750aa56b7f246da307f2feb9310.tar.gz
pylibgamma-dc23100deca3d750aa56b7f246da307f2feb9310.tar.bz2
pylibgamma-dc23100deca3d750aa56b7f246da307f2feb9310.tar.xz
misc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/libgamma_error.py73
-rw-r--r--src/libgamma_method.py195
-rw-r--r--src/libgamma_native_facade.pyx167
3 files changed, 357 insertions, 78 deletions
diff --git a/src/libgamma_error.py b/src/libgamma_error.py
index 7b16886..865d666 100644
--- a/src/libgamma_error.py
+++ b/src/libgamma_error.py
@@ -134,16 +134,16 @@ def value_of_error(name : str) -> int:
-LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD = -1
+LIBGAMMA_ERRNO_SET = -1
'''
-The selected adjustment method does not exist
-or has been excluded at compile-time.
+`errno` has be set with a standard error number
+to indicate the what has gone wrong.
'''
-LIBGAMMA_ERRNO_SET = -2
+LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD = -2
'''
-`errno` has be set with a standard error number
-to indicate the what has gone wrong.
+The selected adjustment method does not exist
+or has been excluded at compile-time.
'''
LIBGAMMA_NO_SUCH_SITE = -3
@@ -419,3 +419,64 @@ number your program thinks it should be sould
update your program for new errors.
'''
+
+
+class LibgammaError(Exception):
+ '''
+ libgamma error class.
+
+ @variable errno The error code.
+ @variable strerror The name of the error.
+ '''
+
+ def __init__(self, errno : int, strerror : str):
+ '''
+ Constructor.
+
+ @param errno The error code.
+ @param strerror The name of the error.
+ '''
+ self.errno = errno
+ self.strerror = strerror
+
+ def __str__(self) -> str:
+ '''
+ Return the name of the error.
+
+ @return The name of the error.
+ '''
+ return self.strerror
+
+
+ def __repr__(self) -> str:
+ '''
+ Create a string representation of the error.
+
+ @return A string representation of the error.
+ '''
+ return 'LibgammaError(%i, %s)' % (self.errno, repr(self.strerror))
+
+
+
+def create_error(error_code : int) -> Exception:
+ '''
+ Create an exception from an error code.
+
+ @param error_code The error code.
+ @return :OSError|LibgammaError The error as a throwable object.
+ '''
+ if error_code == LIBGAMMA_ERRNO_SET:
+ import ctypes
+ error_code = ctypes.get_errno()
+
+ if error_code >= 0:
+ import c
+ e = OSError()
+ e.errno = error_code
+ e.strerror = c.strerror(e.errno)
+ else:
+ strerror = name_of_error(error_code)
+ e = LibgammaError(error_code, strerror)
+
+ return e
+
diff --git a/src/libgamma_method.py b/src/libgamma_method.py
index 67993f4..ffdf5f0 100644
--- a/src/libgamma_method.py
+++ b/src/libgamma_method.py
@@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
'''
+from libgamma_error import create_error
+
LIBGAMMA_METHOD_DUMMY = 0
@@ -813,3 +815,196 @@ class GammaRamps:
'''
raise AttributeError('cannot change depth')
+
+
+class Site:
+ '''
+ Site state.
+
+ On operating systems that integrate a graphical environment
+ there is usually just one site. However, one systems with
+ pluggable graphics, like Unix-like systems such as GNU/Linux
+ and the BSD:s, there can usually be any (feasible) number of
+ sites. In X.org parlance they are called displays.
+
+ @variable method:int The adjustment method of the site
+ @variable site:str? The site identifier
+ @variable partitions_available:int The number of paritions available in the site
+ '''
+
+ def __init__(self, method : int, site : str = None):
+ '''
+ Constructor.
+
+ @param method:int The adjustment method of the site
+ @param site:str? The site identifier
+ '''
+ from libgamma_native_facade import libgamma_native_site_create
+ (self.__state, n) = libgamma_native_site_create(method, site)
+ if self.__state == 0:
+ raise create_error(n)
+ self.partitions_available = n
+ self.method = method
+ self.site = site
+
+
+ def __del__(self):
+ '''
+ This function is called when the object is not longer in use.
+ '''
+ from libgamma_native_facade import libgamma_native_site_free
+ libgamma_native_site_free(self.__state)
+
+
+ def restore(self):
+ '''
+ Restore the gamma ramps all CRTC:s with the site to the system settings.
+ '''
+ from libgamma_native_facade import libgamma_native_site_restore
+ r = libgamma_native_site_restore(self.__state)
+ if not r == 0:
+ raise create_error(r)
+
+
+class Partition:
+ '''
+ Partition state.
+
+ Probably the majority of display server only one partition
+ per site. However, X.org can, and traditional used to have
+ on multi-headed environments, multiple partitions per site.
+ In X.org partitions are called 'screens'. It is not to be
+ confused with monitor. A screen is a collection of monitors,
+ and the mapping from monitors to screens is a surjection.
+ On hardware-level adjustment methods, such as Direct
+ Rendering Manager, a partition is a graphics card
+
+ @variable site:Site The site of the partition
+ @variable partition:int The index of the partition
+ @variable crtcs_available:int The number of CRTC:s available in the parition.
+ '''
+
+ def __init__(self, site : Site, partition : int):
+ '''
+ Constructor.
+
+ @param site The site the of the partition
+ @param partition The index of the partition
+ '''
+ from libgamma_native_facade import libgamma_native_partition_create
+ (self.__state, n) = libgamma_native_partition_create(site, partition)
+ if self.__state == 0:
+ raise create_error(n)
+ self.crtcs_available = n
+ self.site = site
+ self.partition = partition
+
+
+ def __del__(self):
+ '''
+ This function is called when the object is not longer in use.
+ '''
+ from libgamma_native_facade import libgamma_native_partition_free
+ libgamma_native_partition_free(self.__state)
+
+
+ def restore(self):
+ '''
+ Restore the gamma ramps all CRTC:s with the partition to the system settings.
+ '''
+ from libgamma_native_facade import libgamma_native_partition_restore
+ r = libgamma_native_partition_restore(self.__state)
+ if not r == 0:
+ raise create_error(r)
+
+
+class CRTC:
+ '''
+ Cathode ray tube controller state.
+
+ The CRTC controls the gamma ramps for the
+ monitor that is plugged in to the connector
+ that the CRTC belongs to.
+
+ @variable partition:Partition The partition of the CRTC
+ @variable crtc:int The index of the CRTC
+ '''
+
+ def __init__(self, partition : Partition, crtc : int):
+ '''
+ Constructor.
+
+ @param partition The partition the of the CRTC
+ @param crtc The index of the CRTC
+ '''
+ from libgamma_native_facade import libgamma_native_crtc_create
+ (self.__state, n) = libgamma_native_crtc_create(partition, crtc)
+ if self.__state == 0:
+ raise create_error(n)
+ self.partition = partition
+ self.crtc = crtc
+
+
+ def __del__(self):
+ '''
+ This function is called when the object is not longer in use.
+ '''
+ from libgamma_native_facade import libgamma_native_crtc_free
+ libgamma_native_crtc_free(self.__state)
+
+
+ def restore(self):
+ '''
+ Restore the gamma ramps for a CRTC to the system settings for that CRTC.
+ '''
+ from libgamma_native_facade import libgamma_native_crtc_restore
+ r = libgamma_native_crtc_restore(self.__state)
+ if not r == 0:
+ raise create_error(r)
+
+
+ def information(fields : int) -> tuple:
+ '''
+ Read information about a CRTC.
+
+ @param field OR:ed identifiers for the information
+ about the CRTC that should be read.
+ @return :(:CRTCInformation, :bool) The information about the CRTC and
+ whether no errors occurred.
+ '''
+ from libgamma_native_facade import libgamma_native_get_crtc_information
+ (data, e) = libgamma_native_get_crtc_information(self.__state, fields)
+ return (CRTCInformation(data), e == 0)
+
+
+ def get_gamma(ramps : GammaRamps):
+ '''
+ Get the current gamma ramps for the CRTC.
+
+ @param ramps The gamma ramps to fill with the current values.
+ '''
+ if ramps.depth == 8: r = libgamma_native_crtc_get_gamma_ramps8(self.__state, ramps.__ramp)
+ elif ramps.depth == 16: r = libgamma_native_crtc_get_gamma_ramps16(self.__state, ramps.__ramp)
+ elif ramps.depth == 32: r = libgamma_native_crtc_get_gamma_ramps32(self.__state, ramps.__ramp)
+ elif ramps.depth == 64: r = libgamma_native_crtc_get_gamma_ramps64(self.__state, ramps.__ramp)
+ elif ramps.depth == -1: r = libgamma_native_crtc_get_gamma_rampsf(self.__state, ramps.__ramp)
+ elif ramps.depth == -2: r = libgamma_native_crtc_get_gamma_rampsd(self.__state, ramps.__ramp)
+ if not r == 0:
+ raise create_error(r)
+
+
+ def set_gamma(ramps : GammaRamps):
+ '''
+ Set gamma ramps for the CRTC.
+
+ @param ramps The gamma ramps to apply.
+ '''
+ if ramps.depth == 8: r = libgamma_native_crtc_set_gamma_ramps8(self.__state, ramps.__ramp)
+ elif ramps.depth == 16: r = libgamma_native_crtc_set_gamma_ramps16(self.__state, ramps.__ramp)
+ elif ramps.depth == 32: r = libgamma_native_crtc_set_gamma_ramps32(self.__state, ramps.__ramp)
+ elif ramps.depth == 64: r = libgamma_native_crtc_set_gamma_ramps64(self.__state, ramps.__ramp)
+ elif ramps.depth == -1: r = libgamma_native_crtc_set_gamma_rampsf(self.__state, ramps.__ramp)
+ elif ramps.depth == -2: r = libgamma_native_crtc_set_gamma_rampsd(self.__state, ramps.__ramp)
+ if not r == 0:
+ raise create_error(r)
+
diff --git a/src/libgamma_native_facade.pyx b/src/libgamma_native_facade.pyx
index 33ba606..41ab169 100644
--- a/src/libgamma_native_facade.pyx
+++ b/src/libgamma_native_facade.pyx
@@ -22,6 +22,7 @@ cimport cython
from libc.stddef cimport size_t
from libc.stdlib cimport malloc, free
from libc.stdint cimport int32_t, uint8_t, uint16_t, uint32_t, uint64_t
+from libc.errno cimport errno
ctypedef int libgamma_subpixel_order_t
@@ -634,7 +635,7 @@ Release all resources in an information data structure for a CRTC.
cdef extern int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t* this, libgamma_gamma_ramps8_t* ramps)
'''
-Get current the gamma ramps for a CRTC, 8-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values
@@ -657,7 +658,7 @@ Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
cdef extern int libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t* this, libgamma_gamma_ramps16_t* ramps)
'''
-Get current the gamma ramps for a CRTC, 16-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values
@@ -680,7 +681,7 @@ Set the gamma ramps for a CRTC, 16-bit gamma-depth version.
cdef extern int libgamma_crtc_get_gamma_ramps32(libgamma_crtc_state_t* this, libgamma_gamma_ramps32_t* ramps)
'''
-Get current the gamma ramps for a CRTC, 32-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
@@ -703,7 +704,7 @@ Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
cdef extern int libgamma_crtc_get_gamma_ramps64(libgamma_crtc_state_t* this, libgamma_gamma_ramps64_t* ramps)
'''
-Get current the gamma ramps for a CRTC, 64-bit gamma-depth version.
+Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
@@ -737,7 +738,7 @@ Set the gamma ramps for a CRTC, `float` version.
cdef extern int libgamma_crtc_get_gamma_rampsf(libgamma_crtc_state_t* this, libgamma_gamma_rampsf_t* ramps)
'''
-Get current the gamma ramps for a CRTC, `float` version.
+Get the current gamma ramps for a CRTC, `float` version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
@@ -749,7 +750,7 @@ Get current the gamma ramps for a CRTC, `float` version.
cdef extern int libgamma_crtc_get_gamma_rampsd(libgamma_crtc_state_t* this, libgamma_gamma_rampsd_t* ramps)
'''
-Get current the gamma ramps for a CRTC, `double` version.
+Get the current gamma ramps for a CRTC, `double` version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
@@ -821,7 +822,7 @@ def libgamma_native_method_capabilities(method : int) -> tuple:
Return the capabilities of an adjustment method.
@param method The adjustment method (display server and protocol).
- @return :(int, int) Input parameters for `MethodCapabilities.__init__`
+ @return :(int, int) Input parameters for `MethodCapabilities.__init__`.
'''
cdef libgamma_method_capabilities_t caps
libgamma_method_capabilities(&caps, <int>method)
@@ -888,7 +889,9 @@ def libgamma_native_site_create(method : int, site : str) -> tuple:
or allocate on the stack. Note however that it will
not be `free`:d if this function fails.
@return :(site:int, partitions:int) First value: The created site, zero on error
- Second value: The number of partitions in the site, -1 on error
+ Second value: The number of partitions in the site,
+ on error: the value of the error identifier
+ provided by this library or `errno`.
'''
cdef libgamma_site_state_t* this
cdef char* site_
@@ -907,9 +910,9 @@ def libgamma_native_site_create(method : int, site : str) -> tuple:
for i in range(len(site_bs)):
site_[i] = <char>(site_bs[i])
r = int(libgamma_site_initialise(this, <int>method, site_))
- if r < 0:
+ if not r == 0:
libgamma_site_free(this)
- return (0, -1)
+ return (0, int(errno) if r == -1 else r)
return (int(this_address), int(this.partitions_available))
@@ -932,14 +935,15 @@ def libgamma_native_site_restore(this : int) -> int:
Restore the gamma ramps all CRTC:s with a site to the system settings.
@param this The site state.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef libgamma_site_state_t* this_
this_address = <size_t>this
this_ = <libgamma_site_state_t*><void*>this_address
- return int(libgamma_site_restore(this_))
+ r = int(libgamma_site_restore(this_))
+ return int(errno) if r == -1 else r
@@ -950,7 +954,9 @@ def libgamma_native_partition_create(site : int, partition : int) -> tuple:
@param site The site state for the site that the partition belongs to.
@param partition The index of the partition within the site.
@return :(site:int, partitions:int) First value: The created partition, zero on error
- Second value: The number of CRTC:s in the partition, -1 on error
+ Second value: The number of CRTC:s in the partition,
+ on error: the value of the error identifier
+ provided by this library or `errno`.
'''
cdef libgamma_partition_state_t* this
cdef libgamma_site_state_t* site_
@@ -963,9 +969,9 @@ def libgamma_native_partition_create(site : int, partition : int) -> tuple:
raise MemoryError()
this_address = <size_t><void*>this
r = int(libgamma_partition_initialise(this, site_, <size_t>partition))
- if r < 0:
+ if not r == 0:
libgamma_partition_free(this)
- return (0, -1)
+ return (0, int(errno) if r == -1 else r)
return (int(this_address), int(this.crtcs_available))
@@ -988,24 +994,27 @@ def libgamma_native_partition_restore(this : int) -> int:
Restore the gamma ramps all CRTC:s with a partition to the system settings.
@param this The partition state.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef libgamma_partition_state_t* this_
this_address = <size_t>this
this_ = <libgamma_partition_state_t*><void*>this_address
- return int(libgamma_partition_restore(this_))
+ r = int(libgamma_partition_restore(this_))
+ return int(errno) if r == -1 else r
-def libgamma_native_crtc_create(partition : int, crtc : int) -> int:
+def libgamma_native_crtc_create(partition : int, crtc : int) -> tuple:
'''
Create an allocated CRTC state.
- @param partition The partition state for the partition that the CRTC belongs to.
- @param crtc The index of the CRTC within the partition.
- @return The created CRTC, zero on error
+ @param partition The partition state for the partition that the CRTC belongs to.
+ @param crtc The index of the CRTC within the partition.
+ @return :(int, int) First value: The created CRTC, zero on error.
+ Second value: Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef libgamma_crtc_state_t* this
cdef libgamma_partition_state_t* partition_
@@ -1018,10 +1027,10 @@ def libgamma_native_crtc_create(partition : int, crtc : int) -> int:
raise MemoryError()
this_address = <size_t><void*>this
r = int(libgamma_crtc_initialise(this, partition_, <size_t>crtc))
- if r < 0:
+ if not r == 0:
libgamma_crtc_free(this)
- return 0
- return int(this_address)
+ return (0, int(errno) if r == -1 else r)
+ return (int(this_address), 0)
def libgamma_native_crtc_free(this : int):
@@ -1043,14 +1052,15 @@ def libgamma_native_crtc_restore(this : int) -> int:
Restore the gamma ramps for a CRTC to the system settings for that CRTC.
@param this The CRTC state
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef libgamma_crtc_state_t* this_
this_address = <size_t>this
this_ = <libgamma_crtc_state_t*><void*>this_address
- return int(libgamma_crtc_restore(this_))
+ r = int(libgamma_crtc_restore(this_))
+ return int(errno) if r == -1 else r
@@ -1061,7 +1071,8 @@ def libgamma_native_get_crtc_information(crtc : int, fields : int) -> tuple:
@param crtc The state of the CRTC whose information should be read.
@param field OR:ed identifiers for the information about the CRTC that should be read.
@return :(list, :int) First value: Input parametrs for `CRTCInformation.__init__`
- Second value: Zero on success, -1 on error. On error refer to the error reports in the return.
+ Second value: Zero on success, -1 on error. On error refer to
+ the error reports in the return.
'''
cdef libgamma_crtc_information_t info
cdef size_t crtc_address
@@ -1116,12 +1127,12 @@ def libgamma_native_get_crtc_information(crtc : int, fields : int) -> tuple:
def libgamma_native_crtc_get_gamma_ramps8(this : int, ramps : int) -> int:
'''
- Get current the gamma ramps for a CRTC, 8-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1131,7 +1142,8 @@ def libgamma_native_crtc_get_gamma_ramps8(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps8_t*><void*>ramps_address
- return int(libgamma_crtc_get_gamma_ramps8(this_, ramps_))
+ r = int(libgamma_crtc_get_gamma_ramps8(this_, ramps_))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps8(this : int, ramps : int) -> int:
@@ -1140,8 +1152,8 @@ def libgamma_native_crtc_set_gamma_ramps8(this : int, ramps : int) -> int:
@param this The CRTC state.
@param ramps The gamma ramps to apply.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1151,18 +1163,19 @@ def libgamma_native_crtc_set_gamma_ramps8(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps8_t*><void*>ramps_address
- return int(libgamma_crtc_set_gamma_ramps8(this_, ramps_[0]))
+ r = int(libgamma_crtc_set_gamma_ramps8(this_, ramps_[0]))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_get_gamma_ramps16(this : int, ramps : int) -> int:
'''
- Get current the gamma ramps for a CRTC, 16-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1172,7 +1185,8 @@ def libgamma_native_crtc_get_gamma_ramps16(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps16_t*><void*>ramps_address
- return int(libgamma_crtc_get_gamma_ramps16(this_, ramps_))
+ r = int(libgamma_crtc_get_gamma_ramps16(this_, ramps_))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps16(this : int, ramps : int) -> int:
@@ -1181,8 +1195,8 @@ def libgamma_native_crtc_set_gamma_ramps16(this : int, ramps : int) -> int:
@param this The CRTC state.
@param ramps The gamma ramps to apply.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1192,18 +1206,19 @@ def libgamma_native_crtc_set_gamma_ramps16(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps16_t*><void*>ramps_address
- return int(libgamma_crtc_set_gamma_ramps16(this_, ramps_[0]))
+ r = int(libgamma_crtc_set_gamma_ramps16(this_, ramps_[0]))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_get_gamma_ramps32(this : int, ramps : int) -> int:
'''
- Get current the gamma ramps for a CRTC, 32-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1213,7 +1228,8 @@ def libgamma_native_crtc_get_gamma_ramps32(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps32_t*><void*>ramps_address
- return int(libgamma_crtc_get_gamma_ramps32(this_, ramps_))
+ r = int(libgamma_crtc_get_gamma_ramps32(this_, ramps_))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps32(this : int, ramps : int) -> int:
@@ -1222,8 +1238,8 @@ def libgamma_native_crtc_set_gamma_ramps32(this : int, ramps : int) -> int:
@param this The CRTC state.
@param ramps The gamma ramps to apply.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1233,18 +1249,19 @@ def libgamma_native_crtc_set_gamma_ramps32(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps32_t*><void*>ramps_address
- return int(libgamma_crtc_set_gamma_ramps32(this_, ramps_[0]))
+ r = int(libgamma_crtc_set_gamma_ramps32(this_, ramps_[0]))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_get_gamma_ramps64(this : int, ramps : int) -> int:
'''
- Get current the gamma ramps for a CRTC, 64-bit gamma-depth version.
+ Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1254,7 +1271,8 @@ def libgamma_native_crtc_get_gamma_ramps64(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps64_t*><void*>ramps_address
- return int(libgamma_crtc_get_gamma_ramps64(this_, ramps_))
+ r = int(libgamma_crtc_get_gamma_ramps64(this_, ramps_))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_ramps64(this : int, ramps : int) -> int:
@@ -1263,8 +1281,8 @@ def libgamma_native_crtc_set_gamma_ramps64(this : int, ramps : int) -> int:
@param this The CRTC state.
@param ramps The gamma ramps to apply.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1274,18 +1292,19 @@ def libgamma_native_crtc_set_gamma_ramps64(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_ramps64_t*><void*>ramps_address
- return int(libgamma_crtc_set_gamma_ramps64(this_, ramps_[0]))
+ r = int(libgamma_crtc_set_gamma_ramps64(this_, ramps_[0]))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_get_gamma_rampsf(this : int, ramps : int) -> int:
'''
- Get current the gamma ramps for a CRTC, `float` version.
+ Get the current gamma ramps for a CRTC, `float` version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1295,7 +1314,8 @@ def libgamma_native_crtc_get_gamma_rampsf(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_rampsf_t*><void*>ramps_address
- return int(libgamma_crtc_get_gamma_rampsf(this_, ramps_))
+ r = int(libgamma_crtc_get_gamma_rampsf(this_, ramps_))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_rampsf(this : int, ramps : int) -> int:
@@ -1304,8 +1324,8 @@ def libgamma_native_crtc_set_gamma_rampsf(this : int, ramps : int) -> int:
@param this The CRTC state.
@param ramps The gamma ramps to apply.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1315,18 +1335,19 @@ def libgamma_native_crtc_set_gamma_rampsf(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_rampsf_t*><void*>ramps_address
- return int(libgamma_crtc_set_gamma_rampsf(this_, ramps_[0]))
+ r = int(libgamma_crtc_set_gamma_rampsf(this_, ramps_[0]))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_get_gamma_rampsd(this : int, ramps : int) -> int:
'''
- Get current the gamma ramps for a CRTC, `double` version.
+ Get the current gamma ramps for a CRTC, `double` version.
@param this The CRTC state.
@param ramps The gamma ramps to fill with the current values.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1336,7 +1357,8 @@ def libgamma_native_crtc_get_gamma_rampsd(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_rampsd_t*><void*>ramps_address
- return int(libgamma_crtc_get_gamma_rampsd(this_, ramps_))
+ r = int(libgamma_crtc_get_gamma_rampsd(this_, ramps_))
+ return int(errno) if r == -1 else r
def libgamma_native_crtc_set_gamma_rampsd(this : int, ramps : int) -> int:
@@ -1345,8 +1367,8 @@ def libgamma_native_crtc_set_gamma_rampsd(this : int, ramps : int) -> int:
@param this The CRTC state.
@param ramps The gamma ramps to apply.
- @return Zero on success, otherwise (negative) the value of an
- error identifier provided by this library.
+ @return Zero on success, otherwise the value of an error
+ identifier provided by this library or `errno`.
'''
cdef size_t this_address
cdef size_t ramps_address
@@ -1356,5 +1378,6 @@ def libgamma_native_crtc_set_gamma_rampsd(this : int, ramps : int) -> int:
ramps_address = <size_t>ramps
this_ = <libgamma_crtc_state_t*><void*>this_address
ramps_ = <libgamma_gamma_rampsd_t*><void*>ramps_address
- return int(libgamma_crtc_set_gamma_rampsd(this_, ramps_[0]))
+ r = int(libgamma_crtc_set_gamma_rampsd(this_, ramps_[0]))
+ return int(errno) if r == -1 else r