diff options
Diffstat (limited to 'src/gamma-drm.c')
-rw-r--r-- | src/gamma-drm.c | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/src/gamma-drm.c b/src/gamma-drm.c index ea31367..03454ae 100644 --- a/src/gamma-drm.c +++ b/src/gamma-drm.c @@ -45,26 +45,20 @@ struct gamma_state { static int -drm_init(struct gamma_state **state) +drm_create(struct gamma_state **state_out) { - struct gamma_state *s; - - /* Initialize state. */ - *state = malloc(sizeof(**state)); - if (*state == NULL) return -1; - - s = *state; - s->card_num = 0; - s->crtc_num = -1; - s->fd = -1; - s->res = NULL; - s->crtcs = NULL; - + struct gamma_state *state; + state = *state_out = emalloc(sizeof(**state_out)); + state->card_num = 0; + state->crtc_num = -1; + state->fd = -1; + state->res = NULL; + state->crtcs = NULL; return 0; } static int -drm_start(struct gamma_state *state, enum program_mode mode) +drm_start(struct gamma_state *state) { /* Acquire access to a graphics card. */ long maxlen = strlen(DRM_DIR_NAME) + strlen(DRM_DEV_NAME) + 10; @@ -72,8 +66,6 @@ drm_start(struct gamma_state *state, enum program_mode mode) int crtc_count; struct drm_crtc_state *crtcs; - (void) mode; - sprintf(pathname, DRM_DEV_NAME, DRM_DIR_NAME, state->card_num); state->fd = open(pathname, O_RDWR | O_CLOEXEC); @@ -248,8 +240,7 @@ drm_set_option(struct gamma_state *state, const char *key, const char *value) } static int -drm_set_temperature( - struct gamma_state *state, const struct colour_setting *setting, int preserve) +drm_apply(struct gamma_state *state, const struct colour_setting *setting, int preserve) { struct drm_crtc_state *crtcs = state->crtcs; uint32_t last_gamma_size = 0; @@ -292,13 +283,4 @@ drm_set_temperature( } -const struct gamma_method drm_gamma_method = { - "drm", 0, - &drm_init, - &drm_start, - &drm_free, - &drm_print_help, - &drm_set_option, - &drm_restore, - &drm_set_temperature -}; +const struct gamma_method drm_gamma_method = GAMMA_METHOD_INIT("drm", 0, drm); |