From 0456d945bb99fc4b53a00efee2c84cc0285081a1 Mon Sep 17 00:00:00 2001 From: Carl Zhang Date: Fri, 1 Aug 2025 16:11:04 +0800 Subject: [PATCH] accept cacheable setting from libva set the default coherency to 1-way by setting the usage GMM_RESOURCE_USAGE_STAGING set the usage to GMM_RESOURCE_USAGE_UNKNOWN if it is WC or UC Signed-off-by: Carl Zhang --- .../linux/common/ddi/media_libva_interface_next.cpp | 3 ++- media_softlet/linux/common/ddi/media_libva_util_next.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/media_softlet/linux/common/ddi/media_libva_interface_next.cpp b/media_softlet/linux/common/ddi/media_libva_interface_next.cpp index 45e8e79b2b..8ebf0071ee 100644 --- a/media_softlet/linux/common/ddi/media_libva_interface_next.cpp +++ b/media_softlet/linux/common/ddi/media_libva_interface_next.cpp @@ -3299,7 +3299,8 @@ VAStatus MediaLibvaInterfaceNext::CreateSurfaces2 ( expectedFourcc = externalBufDescripor.pixel_format; width = externalBufDescripor.width; height = externalBufDescripor.height; - // the following code is for backward compatible and it will be removed in the future + descFlag = externalBufDescripor.flags; + // the following code is for backward compatible problem caused by incorrect use of VA_SURFACE_ATTRIB_MEM_TYPE_XXX in application layer. and it will be removed in the future // new implemention should use VASurfaceAttribMemoryType attrib and set its value to VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM if ((externalBufDescripor.flags & VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM )|| (externalBufDescripor.flags & VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME)|| diff --git a/media_softlet/linux/common/ddi/media_libva_util_next.cpp b/media_softlet/linux/common/ddi/media_libva_util_next.cpp index fe05b7e5c4..b06cf09ddf 100644 --- a/media_softlet/linux/common/ddi/media_libva_util_next.cpp +++ b/media_softlet/linux/common/ddi/media_libva_util_next.cpp @@ -651,9 +651,13 @@ VAStatus MediaLibvaUtilNext::CreateExternalSurface( GMM_RESCREATE_CUSTOM_PARAMS_2 gmmCustomParams; MOS_ZeroMemory(&gmmCustomParams, sizeof(gmmCustomParams)); + gmmCustomParams.Usage = GMM_RESOURCE_USAGE_STAGING; + if ((VA_SURFACE_EXTBUF_DESC_UNCACHED & mediaSurface->pSurfDesc->uiFlags) || (VA_SURFACE_EXTBUF_DESC_WC & mediaSurface->pSurfDesc->uiFlags)) + { + gmmCustomParams.Usage = GMM_RESOURCE_USAGE_UNKNOWN; + } if (VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR == mediaSurface->pSurfDesc->uiVaMemType) { - gmmCustomParams.Usage = GMM_RESOURCE_USAGE_STAGING; gmmCustomParams.Type = RESOURCE_1D; }