diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-24 02:30:43 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-24 02:30:43 +0200 |
commit | 003965a79b4f9f4b2f84a7574f6760632a00b889 (patch) | |
tree | ad669e9ba43329f69b957dea125968ef78a79dee /src | |
parent | gamma-x-randr: read connector info (diff) | |
download | libgamma-003965a79b4f9f4b2f84a7574f6760632a00b889.tar.gz libgamma-003965a79b4f9f4b2f84a7574f6760632a00b889.tar.bz2 libgamma-003965a79b4f9f4b2f84a7574f6760632a00b889.tar.xz |
gamma-x-randr use connector name to get connector type
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/gamma-x-randr.c | 38 | ||||
-rw-r--r-- | src/libgamma-method.h | 4 |
2 files changed, 40 insertions, 2 deletions
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 @@ -424,6 +424,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 * * @param this Instance of a data structure to fill with the information about the 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; /** |