[PATCH 3/4] compositor-drm: Return the newly added mode in drm_output_add_mode()
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Thu Aug 9 06:45:00 PDT 2012
Most of the times the caller will look at the output's mode list to get
the new mode, so just return that instead.
---
src/compositor-drm.c | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 33bffae..2ec6705 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1116,7 +1116,7 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
return 0;
}
-static int
+static struct drm_mode *
drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info)
{
struct drm_mode *mode;
@@ -1124,7 +1124,7 @@ drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info)
mode = malloc(sizeof *mode);
if (mode == NULL)
- return -1;
+ return NULL;
mode->base.flags = 0;
mode->base.width = info->hdisplay;
@@ -1149,7 +1149,7 @@ drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info)
wl_list_insert(output->base.mode_list.prev, &mode->base.link);
- return 0;
+ return mode;
}
static int
@@ -1331,13 +1331,13 @@ create_output_for_connector(struct drm_compositor *ec,
int x, int y, struct udev_device *drm_device)
{
struct drm_output *output;
- struct drm_mode *drm_mode, *next;
- struct weston_mode *m, *preferred, *current, *configured;
+ struct drm_mode *drm_mode, *next, *preferred, *current, *configured;
+ struct weston_mode *m;
struct drm_configured_output *o = NULL, *temp;
drmModeEncoder *encoder;
drmModeModeInfo crtc_mode;
drmModeCrtc *crtc;
- int i, ret;
+ int i;
char name[32];
const char *type_name;
@@ -1386,8 +1386,8 @@ create_output_for_connector(struct drm_compositor *ec,
}
for (i = 0; i < connector->count_modes; i++) {
- ret = drm_output_add_mode(output, &connector->modes[i]);
- if (ret)
+ drm_mode = drm_output_add_mode(output, &connector->modes[i]);
+ if (!drm_mode)
goto err_free;
}
@@ -1416,41 +1416,37 @@ create_output_for_connector(struct drm_compositor *ec,
if (o && o->width == drm_mode->base.width &&
o->height == drm_mode->base.height &&
o->config == OUTPUT_CONFIG_MODE)
- configured = &drm_mode->base;
+ configured = drm_mode;
if (!memcmp(&crtc_mode, &drm_mode->mode_info, sizeof crtc_mode))
- current = &drm_mode->base;
+ current = drm_mode;
if (drm_mode->base.flags & WL_OUTPUT_MODE_PREFERRED)
- preferred = &drm_mode->base;
+ preferred = drm_mode;
}
if (o && o->config == OUTPUT_CONFIG_MODELINE) {
- ret = drm_output_add_mode(output, &o->crtc_mode);
- if (ret)
+ configured = drm_output_add_mode(output, &o->crtc_mode);
+ if (!configured)
goto err_free;
- configured = container_of(output->base.mode_list.prev,
- struct weston_mode, link);
current = configured;
}
if (current == NULL && crtc_mode.clock != 0) {
- ret = drm_output_add_mode(output, &crtc_mode);
- if (ret)
+ current = drm_output_add_mode(output, &crtc_mode);
+ if (!current)
goto err_free;
- current = container_of(output->base.mode_list.prev,
- struct weston_mode, link);
}
if (o && o->config == OUTPUT_CONFIG_CURRENT)
configured = current;
if (option_current_mode && current)
- output->base.current = current;
+ output->base.current = ¤t->base;
else if (configured)
- output->base.current = configured;
+ output->base.current = &configured->base;
else if (preferred)
- output->base.current = preferred;
+ output->base.current = &preferred->base;
else if (current)
- output->base.current = current;
+ output->base.current = ¤t->base;
if (output->base.current == NULL) {
weston_log("no available modes for %s\n", output->name);
--
1.7.9.5
More information about the wayland-devel
mailing list