Skip to content

Commit

Permalink
[Decode] Enable pat index for prime buffer
Browse files Browse the repository at this point in the history
Getting pat index from gmm for imported prime buffer
  • Loading branch information
Jexu authored and intel-mediadev committed Jul 22, 2024
1 parent 6f2977f commit 619c25a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions media_driver/linux/common/ddi/media_libva_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ VAStatus DdiMediaUtil_AllocateSurface(
alloc_prime.name = "prime";
alloc_prime.prime_fd = mediaSurface->pSurfDesc->ulBuffer;
alloc_prime.size = mediaSurface->pSurfDesc->uiSize;
//alloc_prime->pat_index = xxx; //get pat_index from gmm
alloc_prime.pat_index = PAT_INDEX_INVALID; //Setting with default pat index 0 in legacy ddi
bo = mos_bo_create_from_prime(mediaDrvCtx->pDrmBufMgr, &alloc_prime);
}

Expand Down Expand Up @@ -385,7 +385,7 @@ VAStatus DdiMediaUtil_AllocateSurface(
alloc_prime.name = "prime";
alloc_prime.prime_fd = mediaSurface->pSurfDesc->ulBuffer;
alloc_prime.size = mediaSurface->pSurfDesc->uiSize;
//alloc_prime->pat_index = xxx; //get pat_index from gmm
alloc_prime.pat_index = PAT_INDEX_INVALID; //Setting with default pat index 0 in legacy ddi
bo = mos_bo_create_from_prime(mediaDrvCtx->pDrmBufMgr, &alloc_prime);
if( bo != nullptr )
{
Expand Down
8 changes: 5 additions & 3 deletions media_softlet/linux/common/ddi/media_libva_util_next.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ VAStatus MediaLibvaUtilNext::CreateExternalSurface(
GMM_RESOURCE_INFO *gmmResourceInfo = nullptr;
MOS_LINUX_BO *bo = nullptr;
uint32_t swizzle_mode;
unsigned int patIndex = PAT_INDEX_INVALID;
VAStatus status = VA_STATUS_SUCCESS;

// Default set as compression not supported, surface compression import only support from Memory Type VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 or VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3
Expand Down Expand Up @@ -616,6 +617,8 @@ VAStatus MediaLibvaUtilNext::CreateExternalSurface(

DDI_CHK_NULL(gmmResourceInfo, "Gmm create resource failed", VA_STATUS_ERROR_ALLOCATION_FAILED);

patIndex = MosInterface::GetPATIndexFromGmm(mediaDrvCtx->pGmmClientContext, gmmResourceInfo);

// DRM buffer allocated by Application, No need to re-allocate new DRM buffer
switch (mediaSurface->pSurfDesc->uiVaMemType)
{
Expand All @@ -632,14 +635,13 @@ VAStatus MediaLibvaUtilNext::CreateExternalSurface(
alloc_prime.name = "prime";
alloc_prime.prime_fd = mediaSurface->pSurfDesc->ulBuffer;
alloc_prime.size = mediaSurface->pSurfDesc->uiSize;
//alloc_prime->pat_index = xxx; // get pat_index from gmm
alloc_prime.pat_index = patIndex;

bo = mos_bo_create_from_prime(mediaDrvCtx->pDrmBufMgr, &alloc_prime);
}
break;
case VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR:
{
unsigned int patIndex = MosInterface::GetPATIndexFromGmm(mediaDrvCtx->pGmmClientContext, gmmResourceInfo);

struct mos_drm_bo_alloc_userptr alloc_uptr;
alloc_uptr.name = "SysSurface";
alloc_uptr.addr = (void *)mediaSurface->pSurfDesc->ulBuffer;
Expand Down
6 changes: 3 additions & 3 deletions media_softlet/linux/common/os/xe/mos_bufmgr_xe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,7 @@ mos_bo_create_from_prime_xe(struct mos_bufmgr *bufmgr, struct mos_drm_bo_alloc_p
struct mos_xe_bo_gem *bo_gem;
int prime_fd = alloc_prime->prime_fd;
int size = alloc_prime->size;
uint16_t pat_index = alloc_prime->pat_index;
drmMMListHead *list;

bufmgr_gem->m_lock.lock();
Expand Down Expand Up @@ -1599,10 +1600,9 @@ mos_bo_create_from_prime_xe(struct mos_bufmgr *bufmgr, struct mos_drm_bo_alloc_p

bo_gem->bo.handle = handle;
/*
* Note, currectly there is no cpu_caching and pat_index for external-imported bo, hard code for it.
* Need to get the pat_index by the customer_gmminfo with 1way coherency at least later.
* Note: Need to get the pat_index by the customer_gmminfo with 1way coherency at least.
*/
bo_gem->pat_index = 1; //Note need to hard code a pat_index with 1way coherency at least
bo_gem->pat_index = pat_index == PAT_INDEX_INVALID ? 0 : pat_index;
bo_gem->bo.bufmgr = bufmgr;

bo_gem->gem_handle = handle;
Expand Down

0 comments on commit 619c25a

Please sign in to comment.