From 9ca38464cbbb23c556082e4548a2bf795379c75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 26 Jul 2012 22:44:55 -0400 Subject: [PATCH] compositor-drm: Look through all crtc/encoder combinations We used to only check the first possible encoder, now we go through all possible encoders and look through all possible crtcs for each encoder. --- src/compositor-drm.c | 49 ++++++++++++++++++++++++++++---------------- weston.ini | 8 ++++++++ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 7c5ba6e0..7ed544b5 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -1260,6 +1260,33 @@ static const char *connector_type_names[] = { "eDP", }; +static int +find_crtc_for_connector(struct drm_compositor *ec, + drmModeRes *resources, drmModeConnector *connector) +{ + drmModeEncoder *encoder; + uint32_t possible_crtcs; + int i, j; + + for (j = 0; j < connector->count_encoders; j++) { + encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[j]); + if (encoder == NULL) { + weston_log("Failed to get encoder.\n"); + return -1; + } + possible_crtcs = encoder->possible_crtcs; + drmModeFreeEncoder(encoder); + + for (i = 0; i < resources->count_crtcs; i++) { + if (possible_crtcs & (1 << i) && + !(ec->crtc_allocator & (1 << resources->crtcs[i]))) + return i; + } + } + + return -1; +} + static int create_output_for_connector(struct drm_compositor *ec, drmModeRes *resources, @@ -1276,28 +1303,15 @@ create_output_for_connector(struct drm_compositor *ec, char name[32]; const char *type_name; - encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[0]); - if (encoder == NULL) { - weston_log("No encoder for connector.\n"); - return -1; - } - - for (i = 0; i < resources->count_crtcs; i++) { - if (encoder->possible_crtcs & (1 << i) && - !(ec->crtc_allocator & (1 << resources->crtcs[i]))) - break; - } - if (i == resources->count_crtcs) { - weston_log("No usable crtc for encoder.\n"); - drmModeFreeEncoder(encoder); + i = find_crtc_for_connector(ec, resources, connector); + if (i < 0) { + weston_log("No usable crtc/encoder pair for connector.\n"); return -1; } output = malloc(sizeof *output); - if (output == NULL) { - drmModeFreeEncoder(encoder); + if (output == NULL) return -1; - } memset(output, 0, sizeof *output); output->base.subpixel = drm_subpixel_to_wayland(connector->subpixel); @@ -1318,7 +1332,6 @@ create_output_for_connector(struct drm_compositor *ec, ec->connector_allocator |= (1 << output->connector_id); output->original_crtc = drmModeGetCrtc(ec->drm.fd, output->crtc_id); - drmModeFreeEncoder(encoder); /* Get the current mode on the crtc that's currently driving * this connector. */ diff --git a/weston.ini b/weston.ini index 3c98e48b..f736c8ae 100644 --- a/weston.ini +++ b/weston.ini @@ -12,6 +12,7 @@ animation=zoom #lockscreen=/usr/share/backgrounds/gnome/Garden.jpg #homescreen=/usr/share/backgrounds/gnome/Blinds.jpg #animation=fade + [launcher] icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png path=/usr/bin/gnome-terminal @@ -32,3 +33,10 @@ path=./clients/flower # Uncomment path to disable screensaver path=/usr/libexec/weston-screensaver duration=600 + +[output] +name=LVDS1 +mode=off + +mode=1366x768 +modeline=36.25 912 936 1024 1136 512 515 525 533 -hsync +vsync