[PATCH weston 2/9] compositor-drm: factor out drm_output_init_gamma_size()

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 9 13:07:20 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move this bit of code into its own function. The caller of this already
cluttered and origcrtc is not used for anything else.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-drm.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 9efb61ae..e1004e0f 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -4575,6 +4575,25 @@ drm_output_set_seat(struct weston_output *base,
 }
 
 static int
+drm_output_init_gamma_size(struct drm_output *output)
+{
+	struct drm_backend *backend = to_drm_backend(output->base.compositor);
+	drmModeCrtc *crtc;
+
+	assert(output->base.compositor);
+	assert(output->crtc_id != 0);
+	crtc = drmModeGetCrtc(backend->drm.fd, output->crtc_id);
+	if (!crtc)
+		return -1;
+
+	output->base.gamma_size = crtc->gamma_size;
+
+	drmModeFreeCrtc(crtc);
+
+	return 0;
+}
+
+static int
 drm_output_enable(struct weston_output *base)
 {
 	struct drm_output *output = to_drm_output(base);
@@ -4830,7 +4849,6 @@ create_output_for_connector(struct drm_backend *b,
 	const char *make = "unknown";
 	const char *model = "unknown";
 	const char *serial_number = "unknown";
-	drmModeCrtcPtr origcrtc;
 	int i;
 
 	i = find_crtc_for_connector(b, resources, connector);
@@ -4859,13 +4877,6 @@ create_output_for_connector(struct drm_backend *b,
 	output->base.destroy = drm_output_destroy;
 	output->base.disable = drm_output_disable;
 
-	origcrtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
-	if (origcrtc == NULL)
-		goto err_output;
-
-	output->base.gamma_size = origcrtc->gamma_size;
-	drmModeFreeCrtc(origcrtc);
-
 	output->destroy_pending = 0;
 	output->disable_pending = 0;
 
@@ -4900,6 +4911,9 @@ create_output_for_connector(struct drm_backend *b,
 	    output->connector->connector_type == DRM_MODE_CONNECTOR_eDP)
 		output->base.connection_internal = true;
 
+	if (drm_output_init_gamma_size(output) < 0)
+		goto err_output;
+
 	output->state_cur = drm_output_state_alloc(output, NULL);
 
 	output->base.mm_width = output->connector->mmWidth;
-- 
2.13.6



More information about the wayland-devel mailing list