I'm using libdrm in effort to change gamma on my Chromebook. I find that when I call drmModeCrtcSetGamma, I get a "Permission denied" error, regardless of whether I run my program with sudo. See line 91 of my source code if you like:

github.com/entrity/chromeos_gamma/blob/b5738b5c12575dbb4c66060502d1e3bd4381fe3e/drm.c#L91

So I insert a call to drmSetMaster(dat->fd) above drmModeCrtcSetGamma, and that results in an "Invalid argument" error. What is the correct approach, please? Documentation seems rather sparse, with the best I've seen being this:

wnwolf.com/display/2012/09/05/libdrm-samples/

(Sorry for the non-linking URLs. I don't have enough rep to post URLs.)