return ret;
}
+/** Rewrite the output's mode list
+ *
+ * @param output The output.
+ * @return 0 on success, -1 on failure.
+ *
+ * Destroy all existing modes in the list, and reconstruct a new list from
+ * scratch, based on the currently attached heads.
+ *
+ * On failure the output's mode list may contain some modes.
+ */
+static int
+drm_output_update_modelist_from_heads(struct drm_output *output)
+{
+ struct drm_backend *backend = to_drm_backend(output->base.compositor);
+ struct weston_head *head_base;
+ struct drm_head *head;
+ struct drm_mode *mode;
+ int i;
+
+ assert(!output->base.enabled);
+
+ drm_mode_list_destroy(backend, &output->base.mode_list);
+
+ /* XXX: needs a strategy for combining mode lists from multiple heads */
+ head_base = weston_output_get_first_head(&output->base);
+ assert(head_base);
+ head = to_drm_head(head_base);
+
+ for (i = 0; i < head->connector->count_modes; i++) {
+ mode = drm_output_add_mode(output, &head->connector->modes[i]);
+ if (!mode)
+ return -1;
+ }
+
+ return 0;
+}
+
/**
* Choose suitable mode for an output
*
struct drm_mode *current;
+ if (drm_output_update_modelist_from_heads(output) < 0)
+ return -1;
+
current = drm_output_choose_initial_mode(b, output, mode, modeline,
&head->inherited_mode);
if (!current)
{
struct drm_output *output;
struct drm_head *head;
- struct drm_mode *drm_mode;
- int i;
output = zalloc(sizeof *output);
if (output == NULL)
output->state_cur = drm_output_state_alloc(output, NULL);
- for (i = 0; i < head->connector->count_modes; i++) {
- drm_mode = drm_output_add_mode(output, &head->connector->modes[i]);
- if (!drm_mode) {
- weston_log("failed to add mode\n");
- goto err_output;
- }
- }
-
weston_compositor_add_pending_output(&output->base, b->compositor);
/* drm_head_create() made its own connector */
return 0;
-err_output:
- drm_head_destroy(head);
- drm_output_destroy(&output->base);
-
err_init:
drmModeFreeConnector(connector);
return -1;