libweston: Compute current protection for weston_output and weston_head
The actual protection status for a given weston_head depends upon the
corresponding drm_head's connector HDCP properties. On the other hand,
the actual protection for a weston_output is the minimum of the
protection status of its attached heads.
As a head's protection changes, the current protection of the output
to which the head is attached is recomputed.
This patch adds the support to keep track of the current
content-protection for heads and the outputs.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 12b9016..ddce8f0 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4769,6 +4769,7 @@
wl_list_init(&head->resource_list);
wl_list_init(&head->xdg_output_resource_list);
head->name = strdup(name);
+ head->current_protection = WESTON_HDCP_DISABLE;
}
/** Send output heads changed signal
@@ -5271,6 +5272,38 @@
weston_head_set_device_changed(head);
}
+static void
+weston_output_compute_protection(struct weston_output *output)
+{
+ struct weston_head *head;
+ enum weston_hdcp_protection op_protection;
+ bool op_protection_valid = false;
+
+ wl_list_for_each(head, &output->head_list, output_link) {
+ if (!op_protection_valid) {
+ op_protection = head->current_protection;
+ op_protection_valid = true;
+ }
+ if (head->current_protection < op_protection)
+ op_protection = head->current_protection;
+ }
+
+ if (!op_protection_valid)
+ op_protection = WESTON_HDCP_DISABLE;
+
+ if (output->current_protection != op_protection)
+ output->current_protection = op_protection;
+}
+
+WL_EXPORT void
+weston_head_set_content_protection_status(struct weston_head *head,
+ enum weston_hdcp_protection status)
+{
+ head->current_protection = status;
+ if (head->output)
+ weston_output_compute_protection(head->output);
+}
+
/** Is the head currently connected?
*
* \param head The head to query.