Skip to content

Commit

Permalink
The hw protected buffer should be enable for widevine.
Browse files Browse the repository at this point in the history
This PR rever the commit 30ec052 as it removed allocating
protected buffer feature.

Android U need to supported widevine feature,So add it back.

Tracked-On:
Signed-off-by: manxiaoliang <[email protected]>
  • Loading branch information
manxiaoliang authored and nanazhan committed Dec 17, 2024
1 parent 29d219b commit 9d82402
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cros_gralloc/cros_gralloc_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ uint64_t cros_gralloc_convert_usage(uint64_t usage)
*/
handle_usage(&usage, GRALLOC_USAGE_EXTERNAL_DISP, &use_flags, BO_USE_NONE);
/* Map PROTECTED to linear until real HW protection is available on Android. */
handle_usage(&usage, GRALLOC_USAGE_PROTECTED, &use_flags, BO_USE_LINEAR);
handle_usage(&usage, GRALLOC_USAGE_PROTECTED, &use_flags, BO_USE_PROTECTED);
handle_usage(&usage, GRALLOC_USAGE_CURSOR, &use_flags, BO_USE_NONE);
/* HACK: See b/30054495 for BO_USE_SW_READ_OFTEN. */
handle_usage(&usage, GRALLOC_USAGE_HW_VIDEO_ENCODER, &use_flags,
Expand Down
22 changes: 20 additions & 2 deletions i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static int i915_add_combinations(struct driver *drv)
ARRAY_SIZE(scanout_render_formats), &metadata_4_tiled,
render_not_linear);
drv_add_combinations(drv, source_formats, ARRAY_SIZE(source_formats), &metadata_4_tiled,
texture_flags | BO_USE_NON_GPU_HW);
texture_flags | BO_USE_NON_GPU_HW | hw_protected);

} else {
struct format_metadata metadata_y_tiled = { .tiling = I915_TILING_Y,
Expand Down Expand Up @@ -364,7 +364,7 @@ static int i915_add_combinations(struct driver *drv)
ARRAY_SIZE(scanout_render_formats), &metadata_y_tiled,
scanout_and_render_not_linear);
drv_add_combinations(drv, source_formats, ARRAY_SIZE(source_formats), &metadata_y_tiled,
texture_flags | BO_USE_NON_GPU_HW);
texture_flags | BO_USE_NON_GPU_HW | hw_protected);

}
return 0;
Expand Down Expand Up @@ -1039,6 +1039,24 @@ static int i915_bo_create_from_metadata(struct bo *bo)
}
gem_handle = gem_create_ext.handle;
}
} else if (i915->has_hw_protection && (bo->meta.use_flags & BO_USE_PROTECTED)) {
struct drm_i915_gem_create_ext_protected_content protected_content = {
.base = { .name = I915_GEM_CREATE_EXT_PROTECTED_CONTENT },
.flags = 0,
};
struct drm_i915_gem_create_ext gem_create_ext = {
.size = bo->meta.total_size,
.extensions = (uintptr_t)&protected_content,
};

ret = drmIoctl(bo->drv->fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &gem_create_ext);
if (ret) {
drv_loge("DRM_IOCTL_I915_GEM_CREATE_EXT failed (size=%llu) (ret=%d) \n",
gem_create_ext.size, ret);
return -errno;
}

gem_handle = gem_create_ext.handle;
} else {
struct drm_i915_gem_create gem_create;
memset(&gem_create, 0, sizeof(gem_create));
Expand Down

0 comments on commit 9d82402

Please sign in to comment.