summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-05 02:24:39 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-05 02:24:39 +0200
commit233a40052651c9ca908266623fe189bb794d04fe (patch)
tree5269e05cd5ff04a1468ec2b8b001b2c149ae9e67 /src
parentdocument (diff)
downloadblueshift-233a40052651c9ca908266623fe189bb794d04fe.tar.gz
blueshift-233a40052651c9ca908266623fe189bb794d04fe.tar.bz2
blueshift-233a40052651c9ca908266623fe189bb794d04fe.tar.xz
portability
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/blueshift_drm.pyx71
-rw-r--r--src/blueshift_randr.pyx31
-rw-r--r--src/blueshift_vidmode.pyx32
3 files changed, 63 insertions, 71 deletions
diff --git a/src/blueshift_drm.pyx b/src/blueshift_drm.pyx
index c8770c0..b0b4fdd 100644
--- a/src/blueshift_drm.pyx
+++ b/src/blueshift_drm.pyx
@@ -17,6 +17,7 @@
cimport cython
from libc.stdlib cimport malloc, free
+from libc.stdint cimport *
cdef extern void blueshift_drm_close()
@@ -79,9 +80,7 @@ Return the size of the gamma ramps on a CRTC
'''
cdef extern int blueshift_drm_get_gamma_ramps(int connection, int crtc_index, int gamma_size,
- unsigned short int* red,
- unsigned short int* green,
- unsigned short int* blue)
+ uint16_t* red, uint16_t* green, uint16_t* blue)
'''
Get the current gamma ramps of a monitor
@@ -95,9 +94,7 @@ Get the current gamma ramps of a monitor
'''
cdef extern int blueshift_drm_set_gamma_ramps(int connection, int crtc_index, int gamma_size,
- unsigned short int* red,
- unsigned short int* green,
- unsigned short int* blue)
+ uint16_t* red, uint16_t* green, uint16_t* blue)
'''
Set the gamma ramps of the of a monitor
@@ -196,9 +193,9 @@ Get the extended display identification data for the monitor connected to a conn
-cdef unsigned short int* r_shared
-cdef unsigned short int* g_shared
-cdef unsigned short int* b_shared
+cdef uint16_t* r_shared
+cdef uint16_t* g_shared
+cdef uint16_t* b_shared
r_shared = NULL
g_shared = NULL
b_shared = NULL
@@ -302,19 +299,19 @@ def drm_get_gamma_ramps(int connection, int crtc_index, int gamma_size, threadsa
@return :(r:list<int>, g:list<int>, b:list<int>)? The current red, green and blue colour curves
'''
global r_shared, g_shared, b_shared
- cdef unsigned short int* r
- cdef unsigned short int* g
- cdef unsigned short int* b
+ cdef uint16_t* r
+ cdef uint16_t* g
+ cdef uint16_t* b
if not threadsafe:
if r_shared is NULL:
- r_shared = <unsigned short int*>malloc(gamma_size * 2)
+ r_shared = <uint16_t*>malloc(gamma_size * sizeof(uint16_t))
if g_shared is NULL:
- g_shared = <unsigned short int*>malloc(gamma_size * 2)
+ g_shared = <uint16_t*>malloc(gamma_size * sizeof(uint16_t))
if b_shared is NULL:
- b_shared = <unsigned short int*>malloc(gamma_size * 2)
- r = <unsigned short int*>malloc(gamma_size * 2) if threadsafe else r_shared
- g = <unsigned short int*>malloc(gamma_size * 2) if threadsafe else g_shared
- b = <unsigned short int*>malloc(gamma_size * 2) if threadsafe else b_shared
+ b_shared = <uint16_t*>malloc(gamma_size * sizeof(uint16_t))
+ r = <uint16_t*>malloc(gamma_size * sizeof(uint16_t)) if threadsafe else r_shared
+ g = <uint16_t*>malloc(gamma_size * sizeof(uint16_t)) if threadsafe else g_shared
+ b = <uint16_t*>malloc(gamma_size * sizeof(uint16_t)) if threadsafe else b_shared
if (r is NULL) or (g is NULL) or (b is NULL):
raise MemoryError()
rc = blueshift_drm_get_gamma_ramps(connection, crtc_index, gamma_size, r, g, b)
@@ -341,30 +338,30 @@ def drm_set_gamma_ramps(int connection, crtc_indices, int gamma_size, r_curve, g
'''
Set the gamma ramps of the of a monitor
- @param connection The identifier for the connection to the card
- @param crtc_index:list<int> The index of the CRTC to read from
- @param gamma_size The size a gamma ramp
- @param r_curve:list<unsigned short int> The red gamma ramp
- @param g_curve:list<unsigned short int> The green gamma ramp
- @param b_curve:list<unsigned short int> The blue gamma ramp
- @param threadsafe:bool Whether to decrease memory efficiency and performace so
- multiple threads can use DRM concurrently
- @return :int Zero on success
+ @param connection The identifier for the connection to the card
+ @param crtc_index:list<int> The index of the CRTC to read from
+ @param gamma_size The size a gamma ramp
+ @param r_curve:list<int> The red gamma ramp
+ @param g_curve:list<int> The green gamma ramp
+ @param b_curve:list<int> The blue gamma ramp
+ @param threadsafe:bool Whether to decrease memory efficiency and performace so
+ multiple threads can use DRM concurrently
+ @return :int Zero on success
'''
global r_shared, g_shared, b_shared
- cdef unsigned short int* r
- cdef unsigned short int* g
- cdef unsigned short int* b
+ cdef uint16_t* r
+ cdef uint16_t* g
+ cdef uint16_t* b
if not threadsafe:
if r_shared is NULL:
- r_shared = <unsigned short int*>malloc(gamma_size * 2)
+ r_shared = <uint16_t*>malloc(gamma_size * sizeof(uint16_t))
if g_shared is NULL:
- g_shared = <unsigned short int*>malloc(gamma_size * 2)
+ g_shared = <uint16_t*>malloc(gamma_size * sizeof(uint16_t))
if b_shared is NULL:
- b_shared = <unsigned short int*>malloc(gamma_size * 2)
- r = <unsigned short int*>malloc(gamma_size * 2) if threadsafe else r_shared
- g = <unsigned short int*>malloc(gamma_size * 2) if threadsafe else g_shared
- b = <unsigned short int*>malloc(gamma_size * 2) if threadsafe else b_shared
+ b_shared = <uint16_t*>malloc(gamma_size * sizeof(uint16_t))
+ r = <uint16_t*>malloc(gamma_size * sizeof(uint16_t)) if threadsafe else r_shared
+ g = <uint16_t*>malloc(gamma_size * sizeof(uint16_t)) if threadsafe else g_shared
+ b = <uint16_t*>malloc(gamma_size * sizeof(uint16_t)) if threadsafe else b_shared
if (r is NULL) or (g is NULL) or (b is NULL):
raise MemoryError()
for i in range(gamma_size):
@@ -483,7 +480,7 @@ def drm_get_edid(int connection, int connector_index):
cdef bytes rc
size = 256
- edid = <char*>malloc(size + 1)
+ edid = <char*>malloc((size + 1) * sizeof(char))
if edid is NULL:
raise MemoryError()
got = blueshift_drm_get_edid(connection, connector_index, edid, size, 1)
diff --git a/src/blueshift_randr.pyx b/src/blueshift_randr.pyx
index 7e8a1a9..de6c54f 100644
--- a/src/blueshift_randr.pyx
+++ b/src/blueshift_randr.pyx
@@ -17,6 +17,7 @@
cimport cython
from libc.stdlib cimport malloc, free
+from libc.stdint cimport *
cdef extern int blueshift_randr_open(int use_screen, char* display)
@@ -28,7 +29,7 @@ Start stage of colour curve control
@return Zero on success
'''
-cdef extern unsigned short int* blueshift_randr_read(int use_crtc)
+cdef extern uint16_t* blueshift_randr_read(int use_crtc)
'''
Gets the current colour curves
@@ -40,9 +41,7 @@ Gets the current colour curves
'''
cdef extern int blueshift_randr_apply(unsigned long long int use_crtcs,
- unsigned short int* r_curve,
- unsigned short int* g_curve,
- unsigned short int* b_curve)
+ uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
'''
Apply stage of colour curve control
@@ -60,17 +59,17 @@ Resource freeing stage of colour curve control
-cdef unsigned short int* r_c
+cdef uint16_t* r_c
'''
Storage space for the red colour curve in C native data structure
'''
-cdef unsigned short int* g_c
+cdef uint16_t* g_c
'''
Storage space for the green colour curve in C native data structure
'''
-cdef unsigned short int* b_c
+cdef uint16_t* b_c
'''
Storage space for the blue colour curve in C native data structure
'''
@@ -91,9 +90,9 @@ def randr_open(int use_screen, display):
if display is not None:
display_ = display
# Allocate the storage space for the C native colour curves
- r_c = <unsigned short int*>malloc(256 * 2)
- g_c = <unsigned short int*>malloc(256 * 2)
- b_c = <unsigned short int*>malloc(256 * 2)
+ r_c = <uint16_t*>malloc(256 * sizeof(uint16_t))
+ g_c = <uint16_t*>malloc(256 * sizeof(uint16_t))
+ b_c = <uint16_t*>malloc(256 * sizeof(uint16_t))
# Check for out-of-memory error
if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
raise MemoryError()
@@ -108,7 +107,7 @@ def randr_read(int use_crtc):
@param use_crtc The CRTC to use
@return :(r:list<int>, g:list<int>, b:list<int>) The current red, green and blue colour curves
'''
- cdef unsigned short int* got
+ cdef uint16_t* got
# Read the current curves
got = blueshift_randr_read(use_crtc)
if got is NULL:
@@ -131,11 +130,11 @@ def randr_apply(unsigned long long use_crtcs, r_curve, g_curve, b_curve):
'''
Apply stage of colour curve control
- @param use_crtcs Mask of CRTC:s to use
- @param r_curve:list<unsigned short int> The red colour curve
- @param g_curve:list<unsigned short int> The green colour curve
- @param b_curve:list<unsigned short int> The blue colour curve
- @return Zero on success
+ @param use_crtcs Mask of CRTC:s to use
+ @param r_curve:list<int> The red colour curve
+ @param g_curve:list<int> The green colour curve
+ @param b_curve:list<int> The blue colour curve
+ @return Zero on success
'''
# Convert curves to 16-bit C integers
for i in range(256):
diff --git a/src/blueshift_vidmode.pyx b/src/blueshift_vidmode.pyx
index a4be816..4133548 100644
--- a/src/blueshift_vidmode.pyx
+++ b/src/blueshift_vidmode.pyx
@@ -17,6 +17,7 @@
cimport cython
from libc.stdlib cimport malloc, free
+from libc.stdint cimport *
cdef extern int blueshift_vidmode_open(int use_screen, char* display)
@@ -28,10 +29,7 @@ Start stage of colour curve control
@return Zero on error, otherwise the size of colours curves
'''
-cdef extern int blueshift_vidmode_read(int use_crtc,
- unsigned short int* r_curve,
- unsigned short int* g_curve,
- unsigned short int* b_curve)
+cdef extern int blueshift_vidmode_read(int use_crtc, uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
'''
Gets the current colour curves
@@ -43,9 +41,7 @@ Gets the current colour curves
'''
cdef extern int blueshift_vidmode_apply(unsigned long long int use_crtcs,
- unsigned short int* r_curve,
- unsigned short int* g_curve,
- unsigned short int* b_curve)
+ uint16_t* r_curve, uint16_t* g_curve, uint16_t* b_curve)
'''
Apply stage of colour curve control
@@ -70,17 +66,17 @@ The size of the curves
vidmode_gamma_size = 0
-cdef unsigned short int* r_c
+cdef uint16_t* r_c
'''
Storage space for the red colour curve in C native data structure
'''
-cdef unsigned short int* g_c
+cdef uint16_t* g_c
'''
Storage space for the green colour curve in C native data structure
'''
-cdef unsigned short int* b_c
+cdef uint16_t* b_c
'''
Storage space for the blue colour curve in C native data structure
'''
@@ -101,9 +97,9 @@ def vidmode_open(int use_screen, display):
if display is not None:
display_ = display
# Allocate the storage space for the C native colour curves
- r_c = <unsigned short int*>malloc(256 * 2)
- g_c = <unsigned short int*>malloc(256 * 2)
- b_c = <unsigned short int*>malloc(256 * 2)
+ r_c = <uint16_t*>malloc(256 * sizeof(uint16_t))
+ g_c = <uint16_t*>malloc(256 * sizeof(uint16_t))
+ b_c = <uint16_t*>malloc(256 * sizeof(uint16_t))
# Check for out-of-memory error
if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
raise MemoryError()
@@ -136,11 +132,11 @@ def vidmode_apply(unsigned long long use_crtcs, r_curve, g_curve, b_curve):
'''
Apply stage of colour curve control
- @param use_crtcs Mask of CRTC:s to use
- @param r_curve:list<unsigned short int> The red colour curve
- @param g_curve:list<unsigned short int> The green colour curve
- @param b_curve:list<unsigned short int> The blue colour curve
- @return Zero on success
+ @param use_crtcs Mask of CRTC:s to use
+ @param r_curve:list<int> The red colour curve
+ @param g_curve:list<int> The green colour curve
+ @param b_curve:list<int> The blue colour curve
+ @return Zero on success
'''
# Convert curves to 16-bit C integers
for i in range(256):