From 2f9ed71a8f28854868e5643b621035046c5f41e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 26 Jul 2012 17:57:15 -0400 Subject: [PATCH] compositor-drm: Assign unique output names like xrandr does --- src/compositor-drm.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 8ea4965..7c5ba6e 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -99,6 +99,7 @@ struct drm_fb { struct drm_output { struct weston_output base; + char *name; uint32_t crtc_id; uint32_t connector_id; drmModeCrtcPtr original_crtc; @@ -1241,6 +1242,24 @@ drm_set_dpms(struct weston_output *output_base, enum dpms_enum level) drmModeFreeConnector(connector); } +static const char *connector_type_names[] = { + "None", + "VGA", + "DVI", + "DVI", + "DVI", + "Composite", + "TV", + "LVDS", + "CTV", + "DIN", + "DP", + "HDMI", + "HDMI", + "TV", + "eDP", +}; + static int create_output_for_connector(struct drm_compositor *ec, drmModeRes *resources, @@ -1254,6 +1273,8 @@ create_output_for_connector(struct drm_compositor *ec, drmModeModeInfo crtc_mode; drmModeCrtc *crtc; int i, ret; + char name[32]; + const char *type_name; encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[0]); if (encoder == NULL) { @@ -1284,6 +1305,13 @@ create_output_for_connector(struct drm_compositor *ec, output->base.model = "unknown"; wl_list_init(&output->base.mode_list); + if (connector->connector_type < ARRAY_LENGTH(connector_type_names)) + type_name = connector_type_names[connector->connector_type]; + else + type_name = "UNKNOWN"; + snprintf(name, 32, "%s%d", type_name, connector->connector_type_id); + output->name = strdup(name); + output->crtc_id = resources->crtcs[i]; ec->crtc_allocator |= (1 << output->crtc_id); output->connector_id = connector->connector_id; @@ -1389,8 +1417,8 @@ create_output_for_connector(struct drm_compositor *ec, output->base.set_dpms = drm_set_dpms; output->base.switch_mode = drm_output_switch_mode; - weston_log("kms connector %d, crtc %d\n", - output->connector_id, output->crtc_id); + weston_log("Output %s, (connector %d, crtc %d)\n", + output->name, output->connector_id, output->crtc_id); wl_list_for_each(m, &output->base.mode_list, link) weston_log_continue(" mode %dx%d@%.1f%s%s%s\n", m->width, m->height, m->refresh / 1000.0, -- 2.7.4