From e7414dd28460f6e364e5bb57b22c4a798be8d386 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 13 Mar 2014 18:31:12 +0100 Subject: add function for applying curves with drm 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 | 8 +++++--- src/monitor.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/blueshift_drm.pyx b/src/blueshift_drm.pyx index 001ec41..3576744 100644 --- a/src/blueshift_drm.pyx +++ b/src/blueshift_drm.pyx @@ -157,12 +157,12 @@ def drm_get_gamma_ramps(int connection, int crtc_index, int gamma_size): return None -def drm_set_gamma_ramps(int connection, int crtc_index, int gamma_size, r_curve, g_curve, b_curve): +def drm_set_gamma_ramps(int connection, crtc_indices, int gamma_size, r_curve, g_curve, b_curve): ''' Set the gamma ramps of the of a monitor @param connection The identifier for the connection to the card - @param crtc_index The index of the CRTC to read from + @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 @@ -181,7 +181,9 @@ def drm_set_gamma_ramps(int connection, int crtc_index, int gamma_size, r_curve, r[i] = r_curve[i] & 0xFFFF g[i] = g_curve[i] & 0xFFFF b[i] = b_curve[i] & 0xFFFF - rc = blueshift_drm_set_gamma_ramps(connection, crtc_index, gamma_size, r, g, b) + rc = 0 + for crtc_index in crtc_indices: + rc |= blueshift_drm_set_gamma_ramps(connection, crtc_index, gamma_size, r, g, b) free(r) free(g) free(b) diff --git a/src/monitor.py b/src/monitor.py index 01c70d0..3947435 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -197,6 +197,21 @@ def vidmode(*crtcs, screen = 0): pass # Happens on exit by TERM signal +def drm(*crtcs, card = 0): + ''' + Applies colour curves using DRM + + @param crtcs:*int The CRT controllers to use, all are used if none are specified + @param card:int The card that the monitors belong to + ''' + connection = drm_manager.open_card(card) + (R_curve, G_curve, B_curve) = translate_to_integers() + try: + drm_set_gamma_ramps(connection, list(crtcs), i_size, R_curve, G_curve, B_curve) + except OverflowError: + pass # Happens on exit by TERM signal + + def print_curves(*crtcs, screen = 0, compact = False): ''' Prints the curves to stdout -- cgit v1.2.3-70-g09d2