diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/gamma-linux-drm.c | 19 | ||||
-rw-r--r-- | src/lib/gamma-x-randr.c | 19 | ||||
-rw-r--r-- | src/lib/libgamma-method.h | 30 |
3 files changed, 35 insertions, 33 deletions
diff --git a/src/lib/gamma-linux-drm.c b/src/lib/gamma-linux-drm.c index 2644da8..3c421e7 100644 --- a/src/lib/gamma-linux-drm.c +++ b/src/lib/gamma-linux-drm.c @@ -579,15 +579,14 @@ static int read_connector_data(libgamma_crtc_state_t* restrict crtc, libgamma_cr const char* connector_name_base = NULL; /* Get some information that does not require too much work. */ - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM | LIBGAMMA_CRTC_INFO_HEIGHT_MM | LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE | - LIBGAMMA_CRTC_INFO_ACTIVE | LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER))) + if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_ACTIVE | LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR))) { /* Get whether or not a monitor is plugged in. */ out->active = connector->connection == DRM_MODE_CONNECTED; out->active_error = connector->connection == DRM_MODE_UNKNOWNCONNECTION ? LIBGAMMA_STATE_UNKNOWN : 0; if (out->active == 0) { - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM | LIBGAMMA_CRTC_INFO_HEIGHT_MM | LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER))) + if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT | LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER))) out->width_mm_error = out->height_mm_error = out->subpixel_order_error = LIBGAMMA_NOT_CONNECTED; goto not_connected; } @@ -701,16 +700,8 @@ int libgamma_linux_drm_get_crtc_information(libgamma_crtc_information_t* restric /* We need to free the EDID after us if it is not explicitly requested. */ free_edid = (fields & LIBGAMMA_CRTC_INFO_EDID) == 0; - /* Figure out what fields we need to get the data for to get the data for other fields. */ - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID | LIBGAMMA_CRTC_INFO_GAMMA))) - fields |= LIBGAMMA_CRTC_INFO_EDID; - if ((fields & LIBGAMMA_CRTC_INFO_CONNECTOR_NAME)) - fields |= LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE; - if (LIBGAMMA_CRTC_INFO_EDID | LIBGAMMA_CRTC_INFO_WIDTH_MM | LIBGAMMA_CRTC_INFO_HEIGHT_MM | LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER) - fields |= LIBGAMMA_CRTC_INFO_ACTIVE; - /* Figure out whether we require the connector to get all information we want. */ - require_connector = fields & (LIBGAMMA_CRTC_INFO_ACTIVE | LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE); + require_connector = fields & (LIBGAMMA_CRTC_INFO_MACRO_ACTIVE | LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR); if (require_connector == 0) goto cont; @@ -724,7 +715,7 @@ int libgamma_linux_drm_get_crtc_information(libgamma_crtc_information_t* restric goto cont; } e |= read_connector_data(crtc, this, connector, fields); - if ((fields & LIBGAMMA_CRTC_INFO_EDID) == 0) + if ((fields & LIBGAMMA_CRTC_INFO_MACRO_EDID) == 0) goto cont; if (this->active_error || (this->active == 0)) { @@ -739,7 +730,7 @@ int libgamma_linux_drm_get_crtc_information(libgamma_crtc_information_t* restric this->gamma_error = this->width_mm_edid_error = this->height_mm_edid_error = this->edid_error; goto cont; } - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID | LIBGAMMA_CRTC_INFO_GAMMA))) + if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_EDID ^ LIBGAMMA_CRTC_INFO_EDID))) e |= libgamma_parse_edid(this, fields); cont: e |= (fields & LIBGAMMA_CRTC_INFO_GAMMA_SIZE) ? get_gamma_ramp_size(this, crtc) : 0; diff --git a/src/lib/gamma-x-randr.c b/src/lib/gamma-x-randr.c index f907cdd..1f4a098 100644 --- a/src/lib/gamma-x-randr.c +++ b/src/lib/gamma-x-randr.c @@ -132,7 +132,8 @@ static int translate_error(int error_code, int default_error, int return_errno) void libgamma_x_randr_method_capabilities(libgamma_method_capabilities_t* restrict this) { char* display = getenv("DISPLAY"); - /* Support for all information except active status and gamma ramp support. */ + /* Support for all information except active status and gamma ramp support. + Active status can be queried but it is not guaranteed produces an up to date result. */ this->crtc_information = LIBGAMMA_CRTC_INFO_MACRO_EDID | LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT | LIBGAMMA_CRTC_INFO_MACRO_RAMP @@ -759,16 +760,8 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict /* We need to free the EDID after us if it is not explicitly requested. */ free_edid = (fields & LIBGAMMA_CRTC_INFO_EDID) == 0; - /* Figure out what fields we need to get the data for to get the data for other fields. */ - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID | LIBGAMMA_CRTC_INFO_GAMMA))) - fields |= LIBGAMMA_CRTC_INFO_EDID; - if ((fields & LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE)) - fields |= LIBGAMMA_CRTC_INFO_CONNECTOR_NAME; - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM | LIBGAMMA_CRTC_INFO_HEIGHT_MM | LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER))) - fields |= LIBGAMMA_CRTC_INFO_ACTIVE; - /* Jump if the output information is not required. */ - if ((fields & (LIBGAMMA_CRTC_INFO_ACTIVE | LIBGAMMA_CRTC_INFO_CONNECTOR_NAME)) == 0) + if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_ACTIVE | LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR)) == 0) goto cont; /* Get connector and connector information. */ @@ -805,11 +798,11 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict if ((fields & LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE)) e |= get_connector_type(this); e |= read_output_data(this, output_info); - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM | LIBGAMMA_CRTC_INFO_HEIGHT_MM))) + if ((fields & LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT)) e |= this->width_mm_error | this->height_mm_error; e |= (fields & LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER) ? this->subpixel_order_error : 0; - if ((fields & LIBGAMMA_CRTC_INFO_EDID) == 0) + if ((fields & LIBGAMMA_CRTC_INFO_MACRO_EDID) == 0) goto cont; if (this->active == 0) { @@ -823,7 +816,7 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict this->gamma_error = this->width_mm_edid_error = this->height_mm_edid_error = this->edid_error; goto cont; } - if ((fields & (LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID | LIBGAMMA_CRTC_INFO_GAMMA))) + if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_EDID ^ LIBGAMMA_CRTC_INFO_EDID))) e |= libgamma_parse_edid(this, fields); cont: diff --git a/src/lib/libgamma-method.h b/src/lib/libgamma-method.h index df95f87..9eedc03 100644 --- a/src/lib/libgamma-method.h +++ b/src/lib/libgamma-method.h @@ -543,20 +543,28 @@ typedef enum libgamma_subpixel_order #define LIBGAMMA_CRTC_INFO_COUNT 13 /** + * Macro for both `libgamma_crtc_information_t` fields + * that can specify the size of the monitor's viewport + * as specified in the monitor's Extended Display + * Information Data. + */ +#define LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT ( LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID \ + | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID ) + +/** * Macro for all `libgamma_crtc_information_t` fields * that can be filled if the adjustment method have * support for reading the monitors' Extended Display * Information Data. */ -#define LIBGAMMA_CRTC_INFO_MACRO_EDID ( LIBGAMMA_CRTC_INFO_EDID \ - | LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID \ - | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID \ - | LIBGAMMA_CRTC_INFO_GAMMA ) +#define LIBGAMMA_CRTC_INFO_MACRO_EDID ( LIBGAMMA_CRTC_INFO_EDID \ + | LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT \ + | LIBGAMMA_CRTC_INFO_GAMMA ) /** * Macro for both `libgamma_crtc_information_t` fields - * that can specify the size of the monitors viewport - * is provided by the adjustment method without this + * that can specify the size of the monitor's viewport + * as provided by the adjustment method without this * library having to parse the monitor's Extended Display * Information Data. */ @@ -577,6 +585,16 @@ typedef enum libgamma_subpixel_order #define LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR ( LIBGAMMA_CRTC_INFO_CONNECTOR_NAME \ | LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE ) +/** + * Macro for the `libgamma_crtc_information_t` fields + * that required there is a monitor attached to the connector, + * and that status itself. + */ +#define LIBGAMMA_CRTC_INFO_MACRO_ACTIVE ( LIBGAMMA_CRTC_INFO_MACRO_EDID \ + | LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT \ + | LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER \ + | LIBGAMMA_CRTC_INFO_ACTIVE ) + /** |