[PATCH weston 6/8] compositor-drm: Make some functions take a weston_output directly

Emmanuel Gil Peyrot emmanuel.peyrot at collabora.com
Mon May 2 21:40:15 UTC 2016


Makes it clearer that they don’t use any field specific to drm_output,
and reduce the amount of churn from the following commits.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
---
 src/compositor-drm.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 5938d53..1edcaab 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -232,7 +232,7 @@ static void
 drm_output_set_cursor(struct drm_output *output);
 
 static void
-drm_output_update_msc(struct drm_output *output, unsigned int seq);
+drm_output_update_msc(struct weston_output *output_base, unsigned int seq);
 
 static int
 drm_sprite_crtc_supported(struct drm_output *output, uint32_t supported)
@@ -775,7 +775,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
 		refresh_nsec =
 			millihz_to_nsec(output_base->current_mode->refresh);
 		if (timespec_to_nsec(&vbl2now) < refresh_nsec) {
-			drm_output_update_msc(output, vbl.reply.sequence);
+			drm_output_update_msc(output_base, vbl.reply.sequence);
 			weston_output_finish_frame(output_base, &ts,
 						WP_PRESENTATION_FEEDBACK_INVALID);
 			return;
@@ -803,14 +803,14 @@ finish_frame:
 }
 
 static void
-drm_output_update_msc(struct drm_output *output, unsigned int seq)
+drm_output_update_msc(struct weston_output *output_base, unsigned int seq)
 {
-	uint64_t msc_hi = output->base.msc >> 32;
+	uint64_t msc_hi = output_base->msc >> 32;
 
-	if (seq < (output->base.msc & 0xffffffff))
+	if (seq < (output_base->msc & 0xffffffff))
 		msc_hi++;
 
-	output->base.msc = (msc_hi << 32) + seq;
+	output_base->msc = (msc_hi << 32) + seq;
 }
 
 static void
@@ -823,7 +823,7 @@ vblank_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec,
 	uint32_t flags = WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
 			 WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
 
-	drm_output_update_msc(output, frame);
+	drm_output_update_msc(&output->base, frame);
 	output->vblank_pending = 0;
 
 	drm_output_release_fb(output, s->current);
@@ -850,7 +850,7 @@ page_flip_handler(int fd, unsigned int frame,
 			 WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
 			 WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
 
-	drm_output_update_msc(output, frame);
+	drm_output_update_msc(&output->base, frame);
 
 	/* We don't set page_flip_pending on start_repaint_loop, in that case
 	 * we just want to page flip to the current buffer to get an accurate
@@ -1367,17 +1367,17 @@ drm_output_destroy(struct weston_output *output_base)
  * @returns Pointer to a mode from the output's mode list
  */
 static struct drm_mode *
-choose_mode (struct drm_output *output, struct weston_mode *target_mode)
+choose_mode (struct weston_output *output_base, struct weston_mode *target_mode)
 {
 	struct drm_mode *tmp_mode = NULL, *mode;
 
-	if (output->base.current_mode->width == target_mode->width &&
-	    output->base.current_mode->height == target_mode->height &&
-	    (output->base.current_mode->refresh == target_mode->refresh ||
+	if (output_base->current_mode->width == target_mode->width &&
+	    output_base->current_mode->height == target_mode->height &&
+	    (output_base->current_mode->refresh == target_mode->refresh ||
 	     target_mode->refresh == 0))
-		return (struct drm_mode *)output->base.current_mode;
+		return (struct drm_mode *)output_base->current_mode;
 
-	wl_list_for_each(mode, &output->base.mode_list, base.link) {
+	wl_list_for_each(mode, &output_base->mode_list, base.link) {
 		if (mode->mode_info.hdisplay == target_mode->width &&
 		    mode->mode_info.vdisplay == target_mode->height) {
 			if (mode->base.refresh == target_mode->refresh ||
@@ -1415,7 +1415,7 @@ drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mo
 
 	b = (struct drm_backend *)output_base->compositor->backend;
 	output = (struct drm_output *)output_base;
-	drm_mode  = choose_mode (output, mode);
+	drm_mode = choose_mode(&output->base, mode);
 
 	if (!drm_mode) {
 		weston_log("%s, invalid resolution:%dx%d\n", __func__, mode->width, mode->height);
@@ -1630,7 +1630,7 @@ init_pixman(struct drm_backend *b)
  * @returns Newly-allocated Weston/DRM mode structure
  */
 static struct drm_mode *
-drm_output_add_mode(struct drm_output *output, const drmModeModeInfo *info)
+drm_output_add_mode(struct weston_output *output_base, const drmModeModeInfo *info)
 {
 	struct drm_mode *mode;
 	uint64_t refresh;
@@ -1660,7 +1660,7 @@ drm_output_add_mode(struct drm_output *output, const drmModeModeInfo *info)
 	if (info->type & DRM_MODE_TYPE_PREFERRED)
 		mode->base.flags |= WL_OUTPUT_MODE_PREFERRED;
 
-	wl_list_insert(output->base.mode_list.prev, &mode->base.link);
+	wl_list_insert(output_base->mode_list.prev, &mode->base.link);
 
 	return mode;
 }
@@ -2196,7 +2196,7 @@ get_gbm_format_from_section(struct weston_config_section *section,
  * @returns A mode from the output's mode list, or NULL if none available
  */
 static struct drm_mode *
-drm_output_choose_initial_mode(struct drm_output *output,
+drm_output_choose_initial_mode(struct weston_output *output_base,
 			       enum output_config kind,
 			       int width, int height,
 			       const drmModeModeInfo *current_mode,
@@ -2208,7 +2208,7 @@ drm_output_choose_initial_mode(struct drm_output *output,
 	struct drm_mode *best = NULL;
 	struct drm_mode *drm_mode;
 
-	wl_list_for_each_reverse(drm_mode, &output->base.mode_list, base.link) {
+	wl_list_for_each_reverse(drm_mode, &output_base->mode_list, base.link) {
 		if (kind == OUTPUT_CONFIG_MODE &&
 		    width == drm_mode->base.width &&
 		    height == drm_mode->base.height)
@@ -2225,13 +2225,13 @@ drm_output_choose_initial_mode(struct drm_output *output,
 	}
 
 	if (kind == OUTPUT_CONFIG_MODELINE) {
-		configured = drm_output_add_mode(output, modeline);
+		configured = drm_output_add_mode(output_base, modeline);
 		if (!configured)
 			return NULL;
 	}
 
 	if (current == NULL && current_mode->clock != 0) {
-		current = drm_output_add_mode(output, current_mode);
+		current = drm_output_add_mode(output_base, current_mode);
 		if (!current)
 			return NULL;
 	}
@@ -2254,7 +2254,7 @@ drm_output_choose_initial_mode(struct drm_output *output,
 	if (best)
 		return best;
 
-	weston_log("no available modes for %s\n", output->base.name);
+	weston_log("no available modes for %s\n", output_base->name);
 	return NULL;
 }
 
@@ -2381,7 +2381,7 @@ create_output_for_connector(struct drm_backend *b,
 		goto err_free;
 
 	for (i = 0; i < connector->count_modes; i++) {
-		drm_mode = drm_output_add_mode(output, &connector->modes[i]);
+		drm_mode = drm_output_add_mode(output_base, &connector->modes[i]);
 		if (!drm_mode)
 			goto err_free;
 	}
@@ -2393,7 +2393,7 @@ create_output_for_connector(struct drm_backend *b,
 		goto err_free;
 	}
 
-	current = drm_output_choose_initial_mode(output, config,
+	current = drm_output_choose_initial_mode(output_base, config,
 						 width, height,
 						 &crtc_mode, &modeline);
 	if (!current)
-- 
2.8.2



More information about the wayland-devel mailing list