summaryrefslogtreecommitdiffstats
path: root/src/blueshift_vidmode_c.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-23 10:49:36 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-23 10:49:36 +0100
commit50ef1eed478d758dbd2aa4cddb57a7c6eb562ed8 (patch)
treee4b3dc2e55122811eb83b825220486ff9fa4fd34 /src/blueshift_vidmode_c.c
parentdoc some solar functions (diff)
downloadblueshift-50ef1eed478d758dbd2aa4cddb57a7c6eb562ed8.tar.gz
blueshift-50ef1eed478d758dbd2aa4cddb57a7c6eb562ed8.tar.bz2
blueshift-50ef1eed478d758dbd2aa4cddb57a7c6eb562ed8.tar.xz
c side of reading curves
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/blueshift_vidmode_c.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/blueshift_vidmode_c.c b/src/blueshift_vidmode_c.c
index b160e7e..b53a23d 100644
--- a/src/blueshift_vidmode_c.c
+++ b/src/blueshift_vidmode_c.c
@@ -115,6 +115,45 @@ int blueshift_vidmode_open(int use_screen)
/**
+ * Gets the current colour curves
+ *
+ * @param use_crtc The CRTC to use
+ * @return {the size of the red curve, *the red curve,
+ * the size of the green curve, *the green curve,
+ * the size of the blue curve, *the blue curve}, needs to be free:d
+ */
+uint16_t* blueshift_vidmode_read(int use_crtc)
+{
+ (void) use_crtc;
+
+ /* Read curves */
+
+ uint16_t* r_gamma = ((uint16_t*)malloc((3 + 3 * curve_size) * sizeof(uint16_t))) + 1;
+ uint16_t* g_gamma = r_gamma + curve_size + 1;
+ uint16_t* b_gamma = g_gamma + curve_size + 1;
+ if (r_gamma == NULL)
+ {
+ fprintf(stderr, "Out of memory\n");
+ XCloseDisplay(display);
+ return NULL;
+ }
+
+ if (XF86VidModeGetGammaRamp(display, screen, curve_size, r_gamma, g_gamma, b_gamma) == 0)
+ {
+ fprintf(stderr, "VidMode gamma query failed\n");
+ free(r_gamma);
+ XCloseDisplay(display);
+ return NULL;
+ }
+
+ *(r_gamma - 1) = curve_size;
+ *(g_gamma - 1) = curve_size;
+ *(b_gamma - 1) = curve_size;
+ return r_gamma;
+}
+
+
+/**
* Apply stage of colour curve control
*
* @param use_crtcs Mask of CRTC:s to use