From: Pekka Paalanen <pekka.paala...@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.paala...@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

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to