From a6878274d3d6fa6a572277388437ab0cfc1a6ed4 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 16 Aug 2015 00:50:15 +0300 Subject: [PATCH] Expose output connector name and id --- include/wlc/wlc.h | 6 ++++++ lib/chck/src | 2 +- src/compositor/output.c | 41 +++++++++++++++++++++++++++++++++++++- src/compositor/output.h | 20 +++++++++++++++++++ src/platform/backend/drm.c | 2 ++ src/platform/backend/x11.c | 8 +++++--- 6 files changed, 74 insertions(+), 5 deletions(-) diff --git a/include/wlc/wlc.h b/include/wlc/wlc.h index cb9334a..91b5f04 100644 --- a/include/wlc/wlc.h +++ b/include/wlc/wlc.h @@ -211,6 +211,12 @@ const wlc_handle* wlc_get_outputs(size_t *out_memb); /** Get focused output. */ wlc_handle wlc_get_focused_output(void); +/** Get connector name. */ +const char* wlc_output_get_connector_name(wlc_handle output); + +/** Get connector id. */ +uint32_t wlc_output_get_connector_id(wlc_handle output); + /** Get sleep state. */ bool wlc_output_get_sleep(wlc_handle output); diff --git a/lib/chck/src b/lib/chck/src index 67a422f..42ee88d 160000 --- a/lib/chck/src +++ b/lib/chck/src @@ -1 +1 @@ -Subproject commit 67a422ff262bd6e7dda4df7ae5703d34550f4a9f +Subproject commit 42ee88d206c4c3cbcfa4f031b30ec4bb9e893a22 diff --git a/src/compositor/output.c b/src/compositor/output.c index 218178b..cb0f6a0 100644 --- a/src/compositor/output.c +++ b/src/compositor/output.c @@ -14,6 +14,30 @@ // FIXME: this is a hack static EGLNativeDisplayType INVALID_DISPLAY = (EGLNativeDisplayType)~0; +static const char* +name_for_connector(enum wlc_output_connector connector) +{ + static const char *names[] = { + "None", + "VGA", + "DVI", + "DVI", + "DVI", + "Composite", + "TV", + "LVDS", + "CTV", + "DIN", + "DP", + "HDMI", + "HDMI", + "TV", + "eDP", + }; + + return (connector < LENGTH(names) ? names[connector] : "UNKNOWN"); +} + bool wlc_output_information_add_mode(struct wlc_output_information *info, struct wlc_output_mode *mode) { @@ -527,7 +551,8 @@ wlc_output_set_information(struct wlc_output *output, struct wlc_output_informat { struct wlc_output_mode *mode; except(mode = chck_iter_pool_get(&output->information.modes, output->active.mode)); - wlc_log(WLC_LOG_INFO, "Chose mode (%u) %dx%d", output->active.mode, mode->width, mode->height); + const char *name = name_for_connector(output->information.connector); + wlc_log(WLC_LOG_INFO, "%s-%d Chose mode (%u) %dx%d", name, output->information.connector_id, output->active.mode, mode->width, mode->height); wlc_output_set_resolution_ptr(output, &(struct wlc_size){ mode->width, mode->height }); } } @@ -802,6 +827,20 @@ wlc_output_focus(wlc_handle output) wlc_output_focus_ptr(convert_from_wlc_handle(output, "output")); } +WLC_API const char* +wlc_output_get_connector_name(wlc_handle output) +{ + struct wlc_output *o = convert_from_wlc_handle(output, "output"); + return (o ? name_for_connector(o->information.connector) : NULL); +} + +WLC_API uint32_t +wlc_output_get_connector_id(wlc_handle output) +{ + struct wlc_output *o = convert_from_wlc_handle(output, "output"); + return (o ? o->information.connector_id : 0); +} + void wlc_output_terminate(struct wlc_output *output) { diff --git a/src/compositor/output.h b/src/compositor/output.h index 72dc9ba..e33c4dc 100644 --- a/src/compositor/output.h +++ b/src/compositor/output.h @@ -20,6 +20,24 @@ enum output_link { LINK_ABOVE, }; +enum wlc_output_connector { + CONNECTOR_NONE, + CONNECTOR_VGA, + CONNECTOR_DVI1, + CONNECTOR_DVI2, + CONNECTOR_DVI3, + CONNECTOR_COMPOSITE, + CONNECTOR_TV1, + CONNECTOR_LVDS, + CONNECTOR_CTV, + CONNECTOR_DIN, + CONNECTOR_DP, + CONNECTOR_HDMI1, + CONNECTOR_HDMI2, + CONNECTOR_TV2, + CONNECTOR_eDP, +}; + struct wlc_output_mode { int32_t refresh; int32_t width, height; @@ -33,7 +51,9 @@ struct wlc_output_information { int32_t physical_width, physical_height; int32_t subpixel; int32_t scale; + uint32_t connector_id; enum wl_output_transform transform; + enum wlc_output_connector connector; }; struct wlc_output { diff --git a/src/platform/backend/drm.c b/src/platform/backend/drm.c index 6e5d158..19c970e 100644 --- a/src/platform/backend/drm.c +++ b/src/platform/backend/drm.c @@ -449,6 +449,8 @@ query_drm(int fd, struct chck_iter_pool *out_infos) info->info.physical_height = connector->mmHeight; info->info.subpixel = connector->subpixel; info->info.scale = 1; // weston gets this from config? + info->info.connector_id = connector->connector_type_id; + info->info.connector = (enum wlc_output_connector)connector->connector_type; for (int i = 0; i < connector->count_modes; ++i) { struct wlc_output_mode mode = {0}; diff --git a/src/platform/backend/x11.c b/src/platform/backend/x11.c index 23f7018..a7dd8b2 100644 --- a/src/platform/backend/x11.c +++ b/src/platform/backend/x11.c @@ -498,13 +498,15 @@ x11_event(int fd, uint32_t mask, void *data) } static void -fake_information(struct wlc_output_information *info) +fake_information(struct wlc_output_information *info, uint32_t id) { assert(info); wlc_output_information(info); chck_string_set_cstr(&info->make, "Xorg", false); chck_string_set_cstr(&info->model, "X11 Window", false); info->scale = 1; + info->connector = CONNECTOR_DP; + info->connector_id = id; struct wlc_output_mode mode = {0}; mode.refresh = 60 * 1000; // mHz @@ -576,12 +578,12 @@ update_outputs(struct chck_pool *outputs) } struct wlc_output_information info; - fake_information(&info); + fake_information(&info, i); count += (add_output(window, &info) ? 1 : 0); } } else { struct wlc_output_information info; - fake_information(&info); + fake_information(&info, 0); count += (add_output(x11.screen->root, &info) ? 1 : 0); }