* could be read after a flush."
*/
#define __DRI_IMAGE_USE_BACKBUFFER 0x0010
+#define __DRI_IMAGE_USE_PROTECTED 0x0020
#define __DRI_IMAGE_TRANSFER_READ 0x1
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)
+#define __DRI2_RENDERER_HAS_PROTECTED_CONTENT 0x000e
+
typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
struct __DRI2rendererQueryExtensionRec {
__DRIextension base;
if (dri2_dpy->buffer_damage && dri2_dpy->buffer_damage->set_damage_region)
disp->Extensions.KHR_partial_update = EGL_TRUE;
+
+ disp->Extensions.EXT_protected_content =
+ dri2_renderer_query_integer(dri2_dpy,
+ __DRI2_RENDERER_HAS_PROTECTED_CONTENT);
}
void
surf->base.format,
surf->base.modifiers,
surf->base.count);
- else
+ else {
+ unsigned flags = surf->base.flags;
+ if (dri2_surf->base.ProtectedContent)
+ flags |= GBM_BO_USE_PROTECTED;
dri2_surf->back->bo = gbm_bo_create(&dri2_dpy->gbm_dri->base,
surf->base.width,
surf->base.height,
surf->base.format,
- surf->base.flags);
+ flags);
+ }
}
if (dri2_surf->back->bo == NULL)
use_flags = __DRI_IMAGE_USE_SHARE | __DRI_IMAGE_USE_BACKBUFFER;
+ if (dri2_surf->base.ProtectedContent) {
+ /* Protected buffers can't be read from another GPU */
+ if (dri2_dpy->is_different_gpu)
+ return -1;
+ use_flags |= __DRI_IMAGE_USE_PROTECTED;
+ }
+
if (dri2_dpy->is_different_gpu &&
dri2_surf->back->linear_copy == NULL) {
/* The LINEAR modifier should be a perfect alias of the LINEAR use
goto cleanup_pixmap;
}
+ if (dri3_surf->surf.base.ProtectedContent &&
+ dri2_dpy->is_different_gpu) {
+ _eglError(EGL_BAD_ALLOC, "dri3_surface_create");
+ goto cleanup_pixmap;
+ }
+
+ dri3_surf->loader_drawable.is_protected_content =
+ dri3_surf->surf.base.ProtectedContent;
+
return &dri3_surf->surf.base;
cleanup_pixmap:
_EGL_CHECK_EXTENSION(EXT_create_context_robustness);
_EGL_CHECK_EXTENSION(EXT_image_dma_buf_import);
_EGL_CHECK_EXTENSION(EXT_image_dma_buf_import_modifiers);
+ _EGL_CHECK_EXTENSION(EXT_protected_content);
_EGL_CHECK_EXTENSION(EXT_surface_CTA861_3_metadata);
_EGL_CHECK_EXTENSION(EXT_surface_SMPTE2086_metadata);
_EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage);
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
if (read_surf && read_surf->Lost)
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
+ /* EGL_EXT_protected_surface spec says:
+ * If EGL_PROTECTED_CONTENT_EXT attributes of read is EGL_TRUE and
+ * EGL_PROTECTED_CONTENT_EXT attributes of draw is EGL_FALSE, an
+ * EGL_BAD_ACCESS error is generated.
+ */
+ if (read_surf && read_surf->ProtectedContent &&
+ draw_surf && !draw_surf->ProtectedContent)
+ RETURN_EGL_ERROR(disp, EGL_BAD_ACCESS, EGL_FALSE);
ret = disp->Driver->MakeCurrent(disp, draw_surf, read_surf, context);
native_pixmap_ptr = (void*) target;
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ if (surf->ProtectedContent)
+ RETURN_EGL_ERROR(disp, EGL_BAD_ACCESS, EGL_FALSE);
ret = disp->Driver->CopyBuffers(disp, surf, native_pixmap_ptr);
RETURN_EGL_EVAL(disp, ret);
EGLBoolean EXT_image_dma_buf_import;
EGLBoolean EXT_image_dma_buf_import_modifiers;
EGLBoolean EXT_pixel_format_float;
+ EGLBoolean EXT_protected_content;
EGLBoolean EXT_surface_CTA861_3_metadata;
EGLBoolean EXT_surface_SMPTE2086_metadata;
EGLBoolean EXT_swap_buffers_with_damage;
}
surf->MipmapTexture = !!val;
break;
+ case EGL_PROTECTED_CONTENT_EXT:
+ if (!disp->Extensions.EXT_protected_content) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+ surf->ProtectedContent = val;
+ break;
+
/* no pixmap surface specific attributes */
default:
err = EGL_BAD_ATTRIBUTE;
surf->VGAlphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
surf->VGColorspace = EGL_VG_COLORSPACE_sRGB;
surf->GLColorspace = EGL_GL_COLORSPACE_LINEAR_KHR;
+ surf->ProtectedContent = EGL_FALSE;
surf->MipmapLevel = 0;
surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT;
case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT:
*value = surface->HdrMetadata.max_fall;
break;
+ case EGL_PROTECTED_CONTENT_EXT:
+ if (!disp->Extensions.EXT_protected_content)
+ return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
+ *value = surface->ProtectedContent;
+ break;
default:
return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
}
EGLBoolean PostSubBufferSupportedNV;
+ EGLBoolean ProtectedContent;
+
struct _egl_hdr_metadata HdrMetadata;
void *NativeSurface;
return NULL;
tex_usage |= PIPE_BIND_CURSOR;
}
+ if (use & __DRI_IMAGE_USE_PROTECTED)
+ tex_usage |= PIPE_BIND_PROTECTED;
img = CALLOC_STRUCT(__DRIimageRec);
if (!img)
if (!value[0])
return -1;
return 0;
+ case __DRI2_RENDERER_HAS_PROTECTED_CONTENT:
+ value[0] =
+ screen->base.screen->get_param(screen->base.screen,
+ PIPE_CAP_DEVICE_PROTECTED_CONTENT);
+ if (!value[0])
+ return -1;
+ return 0;
default:
return driQueryRendererIntegerCommon(_screen, param, value);
}
dri_use |= __DRI_IMAGE_USE_CURSOR;
if (usage & GBM_BO_USE_LINEAR)
dri_use |= __DRI_IMAGE_USE_LINEAR;
+ if (usage & GBM_BO_USE_PROTECTED)
+ dri_use |= __DRI_IMAGE_USE_PROTECTED;
/* Gallium drivers requires shared in order to get the handle/stride */
dri_use |= __DRI_IMAGE_USE_SHARE;
* Buffer is linear, i.e. not tiled.
*/
GBM_BO_USE_LINEAR = (1 << 4),
+ /**
+ * Buffer is protected, i.e. encrypted and not readable by CPU or any
+ * other non-secure / non-trusted components nor by non-trusted OpenGL,
+ * OpenCL, and Vulkan applications.
+ */
+ GBM_BO_USE_PROTECTED = (1 << 5),
};
int
format,
__DRI_IMAGE_USE_SHARE |
__DRI_IMAGE_USE_SCANOUT |
- __DRI_IMAGE_USE_BACKBUFFER,
+ __DRI_IMAGE_USE_BACKBUFFER |
+ (draw->is_protected_content ?
+ __DRI_IMAGE_USE_PROTECTED : 0),
buffer);
pixmap_buffer = buffer->image;
unsigned int back_format;
xcb_present_complete_mode_t last_present_mode;
+ bool is_protected_content;
+
/* Currently protects the following fields:
* event_cnd, has_event_waiter,
* recv_sbc, ust, msc, recv_msc_serial,