aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_get_crtc_information.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-06 16:52:22 +0100
committerMattias Andrée <maandree@kth.se>2021-03-06 16:52:22 +0100
commitadb5b26bd94e0b90966307274f8fd6cada0fdb92 (patch)
tree423d934f23abd225213c4d1228de5249f0b2e43d /libgamma_get_crtc_information.c
parentUpdate todo (diff)
downloadlibgamma-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 '')
-rw-r--r--libgamma_get_crtc_information.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/libgamma_get_crtc_information.c b/libgamma_get_crtc_information.c
index 5c7e2fe..58011dd 100644
--- a/libgamma_get_crtc_information.c
+++ b/libgamma_get_crtc_information.c
@@ -6,23 +6,46 @@
* Read information about a CRTC
*
* @param this Instance of a data structure to fill with the information about the CRTC
+ * @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 crtc The state of the CRTC whose information should be read
* @param fields OR:ed identifiers for the information about the CRTC that should be read
* @return Zero on success, -1 on error; on error refer to the error reports in `this`
*/
int
-libgamma_get_crtc_information(libgamma_crtc_information_t *restrict this, libgamma_crtc_state_t *restrict crtc, int32_t fields)
+libgamma_get_crtc_information(libgamma_crtc_information_t *restrict this, size_t size,
+ libgamma_crtc_state_t *restrict crtc, unsigned long long fields)
{
+ libgamma_crtc_information_t info_;
+ int r, (*func)(libgamma_crtc_information_t *restrict, libgamma_crtc_state_t *restrict, unsigned long long);
+
this->edid = NULL;
this->connector_name = NULL;
switch (crtc->partition->site->method) {
#define X(CONST, CNAME, ...)\
case CONST:\
- return libgamma_##CNAME##_get_crtc_information(this, crtc, fields);
+ func = libgamma_##CNAME##_get_crtc_information;\
+ break;
LIST_AVAILABLE_METHODS(X)
#undef X
default:
return LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD;
}
+
+ if (size == sizeof(info_)) {
+ r = func(this, crtc, fields);
+ this->struct_version = LIBGAMMA_CRTC_INFORMATION_STRUCT_VERSION;
+ return r;
+ } else {
+ info_.struct_version = LIBGAMMA_CRTC_INFORMATION_STRUCT_VERSION;
+ r = func(&info_, crtc, fields);
+ if (size < sizeof(info_)) {
+ memcpy(this, &info_, size);
+ } else {
+ memcpy(this, &info_, sizeof(info_));
+ memset(&((char *)this)[size], 0, size - sizeof(info_));
+ }
+ return r;
+ }
}