[PATCH 06/12] compositor-drm: Abstract drm_output_set_mode()

Xiong Zhang xiong.y.zhang at intel.com
Fri Mar 7 00:27:24 PST 2014


Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
---
 src/compositor-drm.c | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 78292a6..dd1c251 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -593,6 +593,26 @@ drm_output_set_gamma(struct weston_output *output_base,
 }
 
 static int
+drm_output_set_mode(struct drm_output *output, uint32_t fb_id)
+{
+	struct drm_compositor *compositor =
+		(struct drm_compositor *)output->base.compositor;
+	struct drm_mode *mode;
+	int ret = 0;
+
+	mode = container_of(output->base.current_mode,
+			    struct drm_mode, base);
+	ret = drmModeSetCrtc(compositor->drm.fd, output->crtc_id,
+			     fb_id, 0, 0,
+			     &output->connector_id, 1,
+			     &mode->mode_info);
+	if (ret)
+		weston_log("set mode failed: %m\n");
+
+	return ret;
+}
+
+static int
 drm_output_repaint(struct weston_output *output_base,
 		   pixman_region32_t *damage)
 {
@@ -600,7 +620,6 @@ drm_output_repaint(struct weston_output *output_base,
 	struct drm_compositor *compositor =
 		(struct drm_compositor *) output->base.compositor;
 	struct drm_sprite *s;
-	struct drm_mode *mode;
 	int ret = 0;
 
 	if (output->destroy_pending)
@@ -611,17 +630,11 @@ drm_output_repaint(struct weston_output *output_base,
 	if (!output->next)
 		return -1;
 
-	mode = container_of(output->base.current_mode, struct drm_mode, base);
 	if (!output->current ||
 	    output->current->stride != output->next->stride) {
-		ret = drmModeSetCrtc(compositor->drm.fd, output->crtc_id,
-				     output->next->fb_id, 0, 0,
-				     &output->connector_id, 1,
-				     &mode->mode_info);
-		if (ret) {
-			weston_log("set mode failed: %m\n");
+		if (drm_output_set_mode(output, output->next->fb_id))
 			goto err_pageflip;
-		}
+
 		output_base->set_dpms(output_base, WESTON_DPMS_ON);
 	}
 
@@ -2355,8 +2368,6 @@ static void
 drm_compositor_set_modes(struct drm_compositor *compositor)
 {
 	struct drm_output *output;
-	struct drm_mode *drm_mode;
-	int ret;
 
 	wl_list_for_each(output, &compositor->base.output_list, base.link) {
 		if (!output->current) {
@@ -2369,17 +2380,7 @@ drm_compositor_set_modes(struct drm_compositor *compositor)
 			continue;
 		}
 
-		drm_mode = (struct drm_mode *) output->base.current_mode;
-		ret = drmModeSetCrtc(compositor->drm.fd, output->crtc_id,
-				     output->current->fb_id, 0, 0,
-				     &output->connector_id, 1,
-				     &drm_mode->mode_info);
-		if (ret < 0) {
-			weston_log(
-				"failed to set mode %dx%d for output at %d,%d: %m\n",
-				drm_mode->base.width, drm_mode->base.height, 
-				output->base.x, output->base.y);
-		}
+		drm_output_set_mode(output, output->current->fb_id);
 	}
 }
 
-- 
1.8.3.2



More information about the wayland-devel mailing list