diff options
author | Mattias Andrée <maandree@kth.se> | 2021-03-06 16:52:22 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-03-06 16:52:22 +0100 |
commit | adb5b26bd94e0b90966307274f8fd6cada0fdb92 (patch) | |
tree | 423d934f23abd225213c4d1228de5249f0b2e43d /libgamma_method_capabilities.c | |
parent | Update todo (diff) | |
download | libgamma-adb5b26bd94e0b90966307274f8fd6cada0fdb92.tar.gz libgamma-adb5b26bd94e0b90966307274f8fd6cada0fdb92.tar.bz2 libgamma-adb5b26bd94e0b90966307274f8fd6cada0fdb92.tar.xz |
Add chroma and white point support from EDID, add version support to methods caps and CRTC info, support EDID 1.4, and support EDID with extensions
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libgamma_method_capabilities.c')
-rw-r--r-- | libgamma_method_capabilities.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/libgamma_method_capabilities.c b/libgamma_method_capabilities.c index d5bdb93..6c44056 100644 --- a/libgamma_method_capabilities.c +++ b/libgamma_method_capabilities.c @@ -6,23 +6,43 @@ * Return the capabilities of an adjustment method * * @param this The data structure to fill with the method's capabilities + * @param size Should be `sizeof(*this)`, used to let the library know which version + * of the structure is used so that it does not write outside of it * @param method The adjustment method (display server and protocol) * @return Zero on success, otherwise (negative) the value of an * error identifier provided by this library */ int -libgamma_method_capabilities(libgamma_method_capabilities_t *restrict this, int method) +libgamma_method_capabilities(libgamma_method_capabilities_t *restrict this, size_t size, int method) { + libgamma_method_capabilities_t caps_; + void (*func)(libgamma_method_capabilities_t *restrict); + memset(this, 0, sizeof(*this)); switch (method) { #define X(CONST, CNAME, ...)\ case CONST:\ - libgamma_##CNAME##_method_capabilities(this);\ - return 0; + func = libgamma_##CNAME##_method_capabilities;\ + break; LIST_AVAILABLE_METHODS(X) #undef X default: return LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD; } + + if (size == sizeof(caps_)) { + func(this); + this->struct_version = LIBGAMMA_METHOD_CAPABILITIES_STRUCT_VERSION; + } else { + func(&caps_); + caps_.struct_version = LIBGAMMA_METHOD_CAPABILITIES_STRUCT_VERSION; + if (size < sizeof(caps_)) { + memcpy(this, &caps_, size); + } else { + memcpy(this, &caps_, sizeof(caps_)); + memset(&((char *)this)[size], 0, size - sizeof(caps_)); + } + } + this->crtc_information__old = (int32_t)this->crtc_information; } |