[PATCH weston v6 59/73] compositor-drm: drm_set_backlight heads

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


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

Fix this function to support more than one head per output.

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

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 965efafd..b77c1879 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3824,21 +3824,24 @@ drm_get_backlight(struct drm_head *head)
 static void
 drm_set_backlight(struct weston_output *output_base, uint32_t value)
 {
-	struct drm_head *head = to_drm_head(weston_output_get_first_head(output_base));
+	struct drm_output *output = to_drm_output(output_base);
+	struct drm_head *head;
 	long max_brightness, new_brightness;
 
-	if (!head->backlight)
-		return;
-
 	if (value > 255)
 		return;
 
-	max_brightness = backlight_get_max_brightness(head->backlight);
+	wl_list_for_each(head, &output->base.head_list, base.output_link) {
+		if (!head->backlight)
+			return;
 
-	/* get denormalized value */
-	new_brightness = (value * max_brightness) / 255;
+		max_brightness = backlight_get_max_brightness(head->backlight);
 
-	backlight_set_brightness(head->backlight, new_brightness);
+		/* get denormalized value */
+		new_brightness = (value * max_brightness) / 255;
+
+		backlight_set_brightness(head->backlight, new_brightness);
+	}
 }
 
 /**
-- 
2.13.6



More information about the wayland-devel mailing list