Commit 5cfe03c8 authored by Ankit Nautiyal's avatar Ankit Nautiyal

libweston: Add content-protection protocol implementation

This patch adds the content-protection protocol implementation, to
enable a weston client application to request for content-protection
for its content via HDCP.
Signed-off-by: Ankit Nautiyal's avatarAnkit Nautiyal <ankit.k.nautiyal@intel.com>
parent 4b6e73d6
......@@ -111,7 +111,10 @@ enum weston_mode_aspect_ratio {
WESTON_MODE_PIC_AR_256_135 = 4, /* DRM_MODE_PICTURE_ASPECT_256_135*/
};
enum weston_surface_protection_mode {
WESTON_SURFACE_PROTECTION_MODE_RELAXED,
WESTON_SURFACE_PROTECTION_MODE_ENFORCED
};
struct weston_mode {
uint32_t flags;
......@@ -1218,6 +1221,8 @@ struct weston_compositor {
struct weston_log_context *weston_log_ctx;
struct weston_log_scope *debug_scene;
struct content_protection *content_protection;
};
struct weston_buffer {
......@@ -1442,6 +1447,9 @@ struct weston_surface_state {
/* weston_protected_surface.set_type */
enum weston_hdcp_protection desired_protection;
/* weston_protected_surface.enforced/relaxed */
enum weston_surface_protection_mode protection_mode;
};
struct weston_surface_activation_data {
......@@ -1573,6 +1581,8 @@ struct weston_surface {
struct weston_buffer_release_reference buffer_release_ref;
enum weston_hdcp_protection desired_protection;
enum weston_hdcp_protection current_protection;
enum weston_surface_protection_mode protection_mode;
};
struct weston_subsurface {
......@@ -1607,6 +1617,22 @@ struct weston_subsurface {
struct wl_list unused_views;
};
struct protected_surface {
struct weston_surface *surface;
struct wl_listener surface_destroy_listener;
struct wl_list link;
struct wl_resource *protection_resource;
struct content_protection *cp_backptr;
};
struct content_protection {
struct weston_compositor *compositor;
struct wl_listener destroy_listener;
struct weston_log_scope *debug;
struct wl_list protected_list;
};
enum weston_key_state_update {
STATE_UPDATE_AUTOMATIC,
STATE_UPDATE_NONE,
......@@ -2449,6 +2475,13 @@ void
weston_buffer_send_server_error(struct weston_buffer *buffer,
const char *msg);
int
weston_compositor_enable_content_protection(struct weston_compositor *compositor);
void
weston_protected_surface_send_event(struct protected_surface *psurface,
enum weston_hdcp_protection protection);
#ifdef __cplusplus
}
#endif
......
......@@ -481,6 +481,7 @@ weston_surface_state_init(struct weston_surface_state *state)
state->acquire_fence_fd = -1;
state->desired_protection = WESTON_HDCP_DISABLE;
state->protection_mode = WESTON_SURFACE_PROTECTION_MODE_RELAXED;
}
static void
......@@ -564,6 +565,8 @@ weston_surface_create(struct weston_compositor *compositor)
surface->acquire_fence_fd = -1;
surface->desired_protection = WESTON_HDCP_DISABLE;
surface->current_protection = WESTON_HDCP_DISABLE;
surface->protection_mode = WESTON_SURFACE_PROTECTION_MODE_RELAXED;
return surface;
}
......@@ -3360,6 +3363,22 @@ weston_surface_set_desired_protection(struct weston_surface *surface,
weston_surface_damage(surface);
}
static void
weston_surface_set_protection_mode(struct weston_surface *surface,
enum weston_surface_protection_mode p_mode)
{
struct content_protection *cp = surface->compositor->content_protection;
struct protected_surface *psurface;
surface->protection_mode = p_mode;
wl_list_for_each(psurface, &cp->protected_list, link) {
if (!psurface || psurface->surface != surface)
continue;
weston_protected_surface_send_event(psurface,
surface->current_protection);
}
}
static void
weston_surface_commit_state(struct weston_surface *surface,
struct weston_surface_state *state)
......@@ -3450,6 +3469,11 @@ weston_surface_commit_state(struct weston_surface *surface,
&state->feedback_list);
wl_list_init(&state->feedback_list);
/* weston_protected_surface.enforced/relaxed */
if (surface->protection_mode != state->protection_mode)
weston_surface_set_protection_mode(surface,
state->protection_mode);
/* weston_protected_surface.set_type */
weston_surface_set_desired_protection(surface, state->desired_protection);
......@@ -3753,6 +3777,7 @@ weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
&surface->pending.buffer_release_ref);
}
sub->cached.desired_protection = surface->pending.desired_protection;
sub->cached.protection_mode = surface->pending.protection_mode;
assert(surface->pending.acquire_fence_fd == -1);
assert(surface->pending.buffer_release_ref.buffer_release == NULL);
sub->cached.sx += surface->pending.sx;
......@@ -7087,6 +7112,8 @@ weston_compositor_create(struct wl_display *display,
ec->touch_mode = WESTON_TOUCH_MODE_NORMAL;
ec->content_protection = NULL;
if (!wl_global_create(ec->wl_display, &wl_compositor_interface, 4,
ec, compositor_bind))
goto fail;
......
This diff is collapsed.
......@@ -12,6 +12,7 @@ srcs_libweston = [
'bindings.c',
'clipboard.c',
'compositor.c',
'content-protection.c',
'data-device.c',
'input.c',
'linux-dmabuf.c',
......@@ -50,6 +51,8 @@ srcs_libweston = [
text_input_unstable_v1_server_protocol_h,
weston_touch_calibration_protocol_c,
weston_touch_calibration_server_protocol_h,
weston_content_protection_protocol_c,
weston_content_protection_server_protocol_h,
viewporter_protocol_c,
viewporter_server_protocol_h,
xdg_output_unstable_v1_protocol_c,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment