diff options
author | Mattias Andrée <maandree@kth.se> | 2016-12-19 08:14:23 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-12-19 08:14:23 +0100 |
commit | 0d24c34d7fea73a0002a79e995f7c7f30b03a054 (patch) | |
tree | 01b6394e5f8b39047ed731ce82ffb193edef5b57 /src/redshift.c | |
parent | Merge pull request #295 from arnej/windowsfix (diff) | |
download | redshift-ng-0d24c34d7fea73a0002a79e995f7c7f30b03a054.tar.gz redshift-ng-0d24c34d7fea73a0002a79e995f7c7f30b03a054.tar.bz2 redshift-ng-0d24c34d7fea73a0002a79e995f7c7f30b03a054.tar.xz |
Add coopgamma backend
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/redshift.c')
-rw-r--r-- | src/redshift.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/redshift.c b/src/redshift.c index bf741bb..423ad5c 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -58,6 +58,10 @@ #include "gamma-dummy.h" +#ifdef ENABLE_COOPGAMMA +# include "gamma-coopgamma.h" +#endif + #ifdef ENABLE_DRM # include "gamma-drm.h" #endif @@ -98,6 +102,9 @@ /* Union of state data for gamma adjustment methods */ typedef union { +#ifdef ENABLE_COOPGAMMA + coopgamma_state_t coopgamma; +#endif #ifdef ENABLE_DRM drm_state_t drm; #endif @@ -118,6 +125,18 @@ typedef union { /* Gamma adjustment method structs */ static const gamma_method_t gamma_methods[] = { +#ifdef ENABLE_COOPGAMMA + { + "coopgamma", 1, + (gamma_method_init_func *)coopgamma_init, + (gamma_method_start_func *)coopgamma_start, + (gamma_method_free_func *)coopgamma_free, + (gamma_method_print_help_func *)coopgamma_print_help, + (gamma_method_set_option_func *)coopgamma_set_option, + (gamma_method_restore_func *)coopgamma_restore, + (gamma_method_set_temperature_func *)coopgamma_set_temperature + }, +#endif #ifdef ENABLE_DRM { "drm", 0, @@ -292,15 +311,6 @@ static const location_provider_t location_providers[] = { #define SLEEP_DURATION 5000 #define SLEEP_DURATION_SHORT 100 -/* Program modes. */ -typedef enum { - PROGRAM_MODE_CONTINUAL, - PROGRAM_MODE_ONE_SHOT, - PROGRAM_MODE_PRINT, - PROGRAM_MODE_RESET, - PROGRAM_MODE_MANUAL -} program_mode_t; - /* Transition scheme. The solar elevations at which the transition begins/ends, and the association color settings. */ @@ -606,9 +616,9 @@ provider_try_start(const location_provider_t *provider, } static int -method_try_start(const gamma_method_t *method, - gamma_state_t *state, - config_ini_state_t *config, char *args) +method_try_start(const gamma_method_t *method, gamma_state_t *state, + program_mode_t mode, config_ini_state_t *config, + char *args) { int r; @@ -673,7 +683,7 @@ method_try_start(const gamma_method_t *method, } /* Start method. */ - r = method->start(state); + r = method->start(state, mode); if (r < 0) { method->free(state); fprintf(stderr, _("Failed to start adjustment method %s.\n"), @@ -1488,8 +1498,8 @@ main(int argc, char *argv[]) if (mode != PROGRAM_MODE_PRINT) { if (method != NULL) { /* Use method specified on command line. */ - r = method_try_start(method, &state, &config_state, - method_args); + r = method_try_start(method, &state, mode, + &config_state, method_args); if (r < 0) exit(EXIT_FAILURE); } else { /* Try all methods, use the first that works. */ @@ -1497,7 +1507,8 @@ main(int argc, char *argv[]) const gamma_method_t *m = &gamma_methods[i]; if (!m->autostart) continue; - r = method_try_start(m, &state, &config_state, NULL); + r = method_try_start(m, &state, mode, + &config_state, NULL); if (r < 0) { fputs(_("Trying next method...\n"), stderr); continue; |