diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-17 16:42:49 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-17 16:42:49 +0200 |
commit | 671efca852ff4aefe653579136ee9b43dbc88324 (patch) | |
tree | 2b4739606b6b82a4256fbf41668cc7c556748bdf /src/coopgamma-server | |
parent | Restructure (diff) | |
download | coopgammad-671efca852ff4aefe653579136ee9b43dbc88324.tar.gz coopgammad-671efca852ff4aefe653579136ee9b43dbc88324.tar.bz2 coopgammad-671efca852ff4aefe653579136ee9b43dbc88324.tar.xz |
Continue restructure
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/coopgamma-server')
-rw-r--r-- | src/coopgamma-server/server.c | 39 | ||||
-rw-r--r-- | src/coopgamma-server/server.h | 8 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/coopgamma-server/server.c b/src/coopgamma-server/server.c index 8d56119..e0a5188 100644 --- a/src/coopgamma-server/server.c +++ b/src/coopgamma-server/server.c @@ -333,3 +333,42 @@ int flush_filters(struct output* restrict output, size_t first_updated) return 0; } + + +/** + * Preserve current gamma ramps at priority 0 for all outputs + * + * @return Zero on success, -1 on error + */ +int preserve_gamma(void) +{ + size_t i; + + for (i = 0; i < outputs_n; i++) + { + struct filter filter = { + .client = -1, + .priority = 0, + .class = NULL, + .lifespan = LIFESPAN_UNTIL_REMOVAL, + .ramps = NULL + }; + outputs[i].table_filters = calloc(4, sizeof(*(outputs[i].table_filters))); + outputs[i].table_sums = calloc(4, sizeof(*(outputs[i].table_sums))); + outputs[i].table_alloc = 4; + outputs[i].table_size = 1; + filter.class = memdup(PKGNAME "::" COMMAND "::preserved", sizeof(PKGNAME "::" COMMAND "::preserved")); + if (filter.class == NULL) + return -1; + filter.ramps = memdup(outputs[i].saved_ramps.u8.red, outputs[i].ramps_size); + if (filter.ramps == NULL) + return -1; + outputs[i].table_filters[0] = filter; + COPY_RAMP_SIZES(&(outputs[i].table_sums[0].u8), outputs + i); + if (!gamma_ramps_unmarshal(outputs[i].table_sums, outputs[i].saved_ramps.u8.red, outputs[i].ramps_size)) + return -1; + } + + return 0; +} + diff --git a/src/coopgamma-server/server.h b/src/coopgamma-server/server.h index 971f7df..4e3bed6 100644 --- a/src/coopgamma-server/server.h +++ b/src/coopgamma-server/server.h @@ -89,5 +89,13 @@ GCC_ONLY(__attribute__((nonnull))) int flush_filters(struct output* restrict output, size_t first_updated); +/** + * Preserve current gamma ramps at priority 0 for all outputs + * + * @return Zero on success, -1 on error + */ +int preserve_gamma(void); + + #endif |