From 003965a79b4f9f4b2f84a7574f6760632a00b889 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 24 May 2014 02:30:43 +0200 Subject: gamma-x-randr use connector name to get connector type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/gamma-x-randr.c | 38 +++++++++++++++++++++++++++++++++++++- src/libgamma-method.h | 4 +++- 2 files changed, 40 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gamma-x-randr.c b/src/gamma-x-randr.c index cc30307..161443b 100644 --- a/src/gamma-x-randr.c +++ b/src/gamma-x-randr.c @@ -423,6 +423,41 @@ static int read_output_data(libgamma_crtc_information_t* restrict out, xcb_randr } +/** + * Determine the connector type from the connector name + * + * @param this The CRTC information to use and extend + * @param Non-zero on error + */ +static int get_connector_type(libgamma_crtc_information_t* restrict this) +{ + if ((this->connector_type_error = this->connector_name_error)) + return -1; + +#define __select(name, type) \ + if (strstr(this->connector_name, name "-") == this->connector_name) \ + return this->connector_type = LIBGAMMA_CONNECTOR_TYPE_##type, 0 + + __select ("None", Unknown); + __select ("VGA", VGA); + __select ("DVI-I", DVII); + __select ("DVI-D", DVID); + __select ("DVI-A", DVIA); + __select ("Composite", Composite); + __select ("S-Video", SVIDEO); + __select ("Component", Component); + __select ("LFP", LFP); + __select ("Proprietary", Unknown); + __select ("HDMI", HDMI); + __select ("DisplayPort", DisplayPort); + +#undef __select + + this->connector_name_error = LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED; + return -1; +} + + /** * Read information about a CRTC * @@ -455,8 +490,9 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict /* FIXME output */ - e |= this->connector_type = -1; /* FIXME */ e |= this->connector_name_error = -1; /* FIXME */ + if ((fields & CRTC_INFO_CONNECTOR_TYPE)) + e |= get_connector_type(this); e |= read_output_data(this, output); if ((fields & (CRTC_INFO_WIDTH_MM | CRTC_INFO_HEIGHT_MM))) e |= this->width_mm_error | this->height_mm_error; diff --git a/src/libgamma-method.h b/src/libgamma-method.h index c1b58b2..0b60b4b 100644 --- a/src/libgamma-method.h +++ b/src/libgamma-method.h @@ -335,12 +335,14 @@ typedef enum libgamma_connector_type LIBGAMMA_CONNECTOR_TYPE_Component, LIBGAMMA_CONNECTOR_TYPE_9PinDIN, LIBGAMMA_CONNECTOR_TYPE_DisplayPort, + LIBGAMMA_CONNECTOR_TYPE_HDMI, LIBGAMMA_CONNECTOR_TYPE_HDMIA, LIBGAMMA_CONNECTOR_TYPE_HDMIB, LIBGAMMA_CONNECTOR_TYPE_TV, LIBGAMMA_CONNECTOR_TYPE_eDP, LIBGAMMA_CONNECTOR_TYPE_VIRTUAL, - LIBGAMMA_CONNECTOR_TYPE_DSI + LIBGAMMA_CONNECTOR_TYPE_DSI, + LIBGAMMA_CONNECTOR_TYPE_LFP } libgamma_connector_type_t; /** -- cgit v1.2.3-70-g09d2