diff options
Diffstat (limited to '')
-rw-r--r-- | src/blueshift_drm.pyx | 71 |
1 files changed, 34 insertions, 37 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) |