[PATCH weston v6 62/73] compositor-drm: backlight control for all heads

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:57:47 UTC 2018


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

If an output has multiple (cloned) heads, it should be enough for any
head to support backlight control for DRM-backend to expose it.

Inspect all attached heads for backlight control and improve the
logging.

Pick the initial backlight level from whatever happens to be the "first"
head, because it's simple.

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

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 63ce8e58..a6cfffda 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3844,6 +3844,35 @@ drm_set_backlight(struct weston_output *output_base, uint32_t value)
 	}
 }
 
+static void
+drm_output_init_backlight(struct drm_output *output)
+{
+	struct weston_head *base;
+	struct drm_head *head;
+
+	output->base.set_backlight = NULL;
+
+	wl_list_for_each(base, &output->base.head_list, output_link) {
+		head = to_drm_head(base);
+
+		if (head->backlight) {
+			weston_log("Initialized backlight for head '%s', device %s\n",
+				   head->base.name, head->backlight->path);
+
+			if (!output->base.set_backlight) {
+				output->base.set_backlight = drm_set_backlight;
+				output->base.backlight_current =
+							drm_get_backlight(head);
+			}
+		}
+	}
+
+	if (!output->base.set_backlight) {
+		weston_log("No backlight control for output '%s'\n",
+			   output->base.name);
+	}
+}
+
 /**
  * Power output on or off
  *
@@ -4917,14 +4946,7 @@ drm_output_enable(struct weston_output *base)
 		goto err;
 	}
 
-	if (head->backlight) {
-		weston_log("Initialized backlight, device %s\n",
-			   head->backlight->path);
-		output->base.set_backlight = drm_set_backlight;
-		output->base.backlight_current = drm_get_backlight(head);
-	} else {
-		weston_log("Failed to initialize backlight\n");
-	}
+	drm_output_init_backlight(output);
 
 	output->base.start_repaint_loop = drm_output_start_repaint_loop;
 	output->base.repaint = drm_output_repaint;
-- 
2.13.6



More information about the wayland-devel mailing list