From 233a40052651c9ca908266623fe189bb794d04fe Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 5 Apr 2014 02:24:39 +0200 Subject: portability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blueshift_drm.pyx | 71 ++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'src/blueshift_drm.pyx') 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, g:list, b:list)? 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 = malloc(gamma_size * 2) + r_shared = malloc(gamma_size * sizeof(uint16_t)) if g_shared is NULL: - g_shared = malloc(gamma_size * 2) + g_shared = malloc(gamma_size * sizeof(uint16_t)) if b_shared is NULL: - b_shared = malloc(gamma_size * 2) - r = malloc(gamma_size * 2) if threadsafe else r_shared - g = malloc(gamma_size * 2) if threadsafe else g_shared - b = malloc(gamma_size * 2) if threadsafe else b_shared + b_shared = malloc(gamma_size * sizeof(uint16_t)) + r = malloc(gamma_size * sizeof(uint16_t)) if threadsafe else r_shared + g = malloc(gamma_size * sizeof(uint16_t)) if threadsafe else g_shared + b = 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 The index of the CRTC to read from - @param gamma_size The size a gamma ramp - @param r_curve:list The red gamma ramp - @param g_curve:list The green gamma ramp - @param b_curve:list 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 The index of the CRTC to read from + @param gamma_size The size a gamma ramp + @param r_curve:list The red gamma ramp + @param g_curve:list The green gamma ramp + @param b_curve:list 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 = malloc(gamma_size * 2) + r_shared = malloc(gamma_size * sizeof(uint16_t)) if g_shared is NULL: - g_shared = malloc(gamma_size * 2) + g_shared = malloc(gamma_size * sizeof(uint16_t)) if b_shared is NULL: - b_shared = malloc(gamma_size * 2) - r = malloc(gamma_size * 2) if threadsafe else r_shared - g = malloc(gamma_size * 2) if threadsafe else g_shared - b = malloc(gamma_size * 2) if threadsafe else b_shared + b_shared = malloc(gamma_size * sizeof(uint16_t)) + r = malloc(gamma_size * sizeof(uint16_t)) if threadsafe else r_shared + g = malloc(gamma_size * sizeof(uint16_t)) if threadsafe else g_shared + b = 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 = malloc(size + 1) + edid = malloc((size + 1) * sizeof(char)) if edid is NULL: raise MemoryError() got = blueshift_drm_get_edid(connection, connector_index, edid, size, 1) -- cgit v1.2.3-70-g09d2