From e24b59a81ec415636415224ffe52faa773cb84f1 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 28 Aug 2014 04:37:41 +0200 Subject: dummy method: error testing in crtc info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/lib/gamma-dummy.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/lib/gamma-dummy.c b/src/lib/gamma-dummy.c index f74e099..a590a93 100644 --- a/src/lib/gamma-dummy.c +++ b/src/lib/gamma-dummy.c @@ -654,10 +654,9 @@ int libgamma_dummy_get_crtc_information(libgamma_crtc_information_t* restrict th libgamma_crtc_state_t* restrict crtc, int32_t fields) { libgamma_dummy_crtc_t* restrict data = crtc->data; + int supported = libgamma_dummy_configurations.capabilities.crtc_information; int e = 0; - /* TODO Validate fields. */ - /* Copy over information. */ *this = data->info; @@ -678,22 +677,32 @@ int libgamma_dummy_get_crtc_information(libgamma_crtc_information_t* restrict th memcpy(this->connector_name, data->info.connector_name, (n + 1) * sizeof(char)); } - /* Test errors. */ - e |= this->edid_error; - e |= this->width_mm_error; - e |= this->height_mm_error; - e |= this->gamma_size_error; - e |= this->gamma_depth_error; - e |= this->gamma_support_error; - e |= this->subpixel_order_error; - e |= this->active_error; - e |= this->connector_name_error; - e |= this->connector_type_error; - /* Parse EDID. */ if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_EDID ^ LIBGAMMA_CRTC_INFO_EDID))) e |= libgamma_parse_edid(this, fields); + /* Test errors. */ +#define _E(FIELD, VAR) \ + ((fields & FIELD) ? ((supported & FIELD) ? VAR : (VAR = LIBGAMMA_CRTC_INFO_NOT_SUPPORTED)) : 0) + e |= _E(LIBGAMMA_CRTC_INFO_EDID, this->edid_error); + e |= _E(LIBGAMMA_CRTC_INFO_WIDTH_MM, this->width_mm_error); + e |= _E(LIBGAMMA_CRTC_INFO_HEIGHT_MM, this->height_mm_error); + e |= _E(LIBGAMMA_CRTC_INFO_GAMMA_SIZE, this->gamma_size_error); + e |= _E(LIBGAMMA_CRTC_INFO_GAMMA_DEPTH, this->gamma_depth_error); + e |= _E(LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT, this->gamma_support_error); + e |= _E(LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER, this->subpixel_order_error); + e |= _E(LIBGAMMA_CRTC_INFO_ACTIVE, this->active_error); + e |= _E(LIBGAMMA_CRTC_INFO_CONNECTOR_NAME, this->connector_name_error); + e |= _E(LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE, this->connector_type_error); + + if ((fields & LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID) && !(supported & LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID)) + e |= this->width_mm_edid_error = LIBGAMMA_CRTC_INFO_NOT_SUPPORTED; + if ((fields & LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID) && !(supported & LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID)) + e |= this->height_mm_edid_error = LIBGAMMA_CRTC_INFO_NOT_SUPPORTED; + if ((fields & LIBGAMMA_CRTC_INFO_GAMMA) && !(supported & LIBGAMMA_CRTC_INFO_GAMMA)) + e |= this->gamma_error = LIBGAMMA_CRTC_INFO_NOT_SUPPORTED; +#undef _E + return e ? -1 : 0; } -- cgit v1.2.3-70-g09d2