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>
dev
Ankit Nautiyal 6 years ago
parent 2690a77088
commit 4f64ff8b2f
  1. 8
      include/libweston/libweston.h
  2. 33
      libweston/compositor.c

@ -215,6 +215,9 @@ struct weston_head {
char *name; /**< head name, e.g. connector name */ char *name; /**< head name, e.g. connector name */
bool connected; /**< is physically connected */ bool connected; /**< is physically connected */
bool non_desktop; /**< non-desktop display, e.g. HMD */ bool non_desktop; /**< non-desktop display, e.g. HMD */
/** Current content protection status */
enum weston_hdcp_protection current_protection;
}; };
/** Represents an output /** Represents an output
@ -292,6 +295,7 @@ struct weston_output {
struct wl_list head_list; /**< List of driven weston_heads */ struct wl_list head_list; /**< List of driven weston_heads */
enum weston_hdcp_protection desired_protection; enum weston_hdcp_protection desired_protection;
enum weston_hdcp_protection current_protection;
void (*start_repaint_loop)(struct weston_output *output); void (*start_repaint_loop)(struct weston_output *output);
int (*repaint)(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, weston_head_get_destroy_listener(struct weston_head *head,
wl_notify_func_t notify); wl_notify_func_t notify);
void
weston_head_set_content_protection_status(struct weston_head *head,
enum weston_hdcp_protection status);
struct weston_head * struct weston_head *
weston_compositor_iterate_heads(struct weston_compositor *compositor, weston_compositor_iterate_heads(struct weston_compositor *compositor,
struct weston_head *iter); struct weston_head *iter);

@ -4769,6 +4769,7 @@ weston_head_init(struct weston_head *head, const char *name)
wl_list_init(&head->resource_list); wl_list_init(&head->resource_list);
wl_list_init(&head->xdg_output_resource_list); wl_list_init(&head->xdg_output_resource_list);
head->name = strdup(name); head->name = strdup(name);
head->current_protection = WESTON_HDCP_DISABLE;
} }
/** Send output heads changed signal /** 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); 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? /** Is the head currently connected?
* *
* \param head The head to query. * \param head The head to query.

Loading…
Cancel
Save