summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-12 04:59:55 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-12 04:59:55 +0100
commit63f9e547a22be704d5b6a3362008963926179f44 (patch)
tree4f26f733f27b11b8a5951852b8781b1a98f3bc35
parentmap to crtc (diff)
downloadblueshift-63f9e547a22be704d5b6a3362008963926179f44.tar.gz
blueshift-63f9e547a22be704d5b6a3362008963926179f44.tar.bz2
blueshift-63f9e547a22be704d5b6a3362008963926179f44.tar.xz
read gamma ramps
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/blueshift_drm_c.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/blueshift_drm_c.c b/src/blueshift_drm_c.c
index dcba7c5..8cb45c4 100644
--- a/src/blueshift_drm_c.c
+++ b/src/blueshift_drm_c.c
@@ -181,10 +181,41 @@ int main(int argc, char** argv)
drmModeEncoder* encoder = drmModeGetEncoder(drm_fd, connector->encoder_id);
uint32_t crtc_id = encoder->crtc_id;
int crtc;
+
drmModeFreeEncoder(encoder);
for (crtc = 0; crtc < drm_res->count_crtcs; crtc++)
if (*(drm_res->crtcs + crtc) == crtc_id)
- printf("CRTC: %i\n", crtc);
+ {
+ printf("CRTC: %i\n", crtc);
+ break;
+ }
+
+ if (crtc < drm_res->count_crtcs)
+ {
+ int gamma_size = blueshift_drm_gamma_size(crtc);
+ uint16_t* red = alloca(gamma_size * sizeof(uint16_t));
+ uint16_t* green = alloca(gamma_size * sizeof(uint16_t));
+ uint16_t* blue = alloca(gamma_size * sizeof(uint16_t));
+ int j;
+
+ /* We need to initialise it to avoid valgrind warnings */
+ for (j = 0; j < gamma_size; j++)
+ *(red + j) = *(green + j) = *(blue + j) = 0;
+
+ if (!drmModeCrtcGetGamma(drm_fd, crtc_id, gamma_size, red, green, blue))
+ {
+ printf("Red:");
+ for (j = 0; j < gamma_size; j++)
+ printf(" %u", *(red + j));
+ printf("\nGreen:");
+ for (j = 0; j < gamma_size; j++)
+ printf(" %u", *(green + j));
+ printf("\nBlue:");
+ for (j = 0; j < gamma_size; j++)
+ printf(" %u", *(blue + j));
+ printf("\n");
+ }
+ }
}
static const char* types[] = {"Unknown", "VGA", "DVII", "DVID", "DVIA", "Composite", "SVIDEO", "LVDS",
"Component", "9PinDIN", "DisplayPort", "HDMIA", "HDMIB", "TV", "eDP",