diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index d07d56f8..b49e453b 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -215,6 +215,9 @@ struct weston_head { char *name; /**< head name, e.g. connector name */ bool connected; /**< is physically connected */ bool non_desktop; /**< non-desktop display, e.g. HMD */ + + /** Current content protection status */ + enum weston_hdcp_protection current_protection; }; /** Represents an output @@ -292,6 +295,7 @@ struct weston_output { struct wl_list head_list; /**< List of driven weston_heads */ enum weston_hdcp_protection desired_protection; + enum weston_hdcp_protection current_protection; void (*start_repaint_loop)(struct weston_output *output); int (*repaint)(struct weston_output *output, @@ -2355,6 +2359,10 @@ struct wl_listener * weston_head_get_destroy_listener(struct weston_head *head, wl_notify_func_t notify); +void +weston_head_set_content_protection_status(struct weston_head *head, + enum weston_hdcp_protection status); + struct weston_head * weston_compositor_iterate_heads(struct weston_compositor *compositor, struct weston_head *iter); diff --git a/libweston/compositor.c b/libweston/compositor.c index 12b9016b..ddce8f0f 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -4769,6 +4769,7 @@ weston_head_init(struct weston_head *head, const char *name) 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_connection_status(struct weston_head *head, bool connected) 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.