compositor-drm: backlight control for all heads

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@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
Pekka Paalanen 2017-11-15 12:51:01 +02:00
parent f005f25d62
commit f8b850d4e1
1 changed files with 30 additions and 8 deletions

View File

@ -3826,6 +3826,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
*
@ -4899,14 +4928,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;