From 8f392d03f1db80dca0b77eedb2795d3d4d789910 Mon Sep 17 00:00:00 2001 From: "Xu, Zhengguo" Date: Wed, 22 May 2024 13:42:07 +0800 Subject: [PATCH] [Decode] Add mos bufmgr api to set and get fences Signed-off-by: Xu, Zhengguo --- .../linux/common/ddi/media_libva_common.cpp | 23 +++++++--- .../common/os/i915/include/mos_bufmgr_api.h | 9 ++++ .../linux/common/os/i915/mos_bufmgr_api.c | 44 +++++++++++++++++++ 3 files changed, 71 insertions(+), 5 deletions(-) diff --git a/media_driver/linux/common/ddi/media_libva_common.cpp b/media_driver/linux/common/ddi/media_libva_common.cpp index f41aa3b9185..f207cb1af79 100644 --- a/media_driver/linux/common/ddi/media_libva_common.cpp +++ b/media_driver/linux/common/ddi/media_libva_common.cpp @@ -478,9 +478,16 @@ void MovePriorityBufferIdToEnd (VABufferID *buffers, int32_t priorityIndexInBuf, VAStatus DdiMedia_SetSyncFences(VADriverContextP ctx, VAContextID context, int32_t *fences, int32_t count) { VAStatus vaStatus = VA_STATUS_SUCCESS; - //todo: get bufmgr - //todo: struct mos_exec_fences exec_fences = {.fences = fences, .count = count}; - //todo: int ret = mos_bufmgr_set_fences(bufmgr, &exec_fences); + PDDI_MEDIA_CONTEXT mediaCtx = DdiMedia_GetMediaContext(ctx); + struct mos_exec_fences exec_fences; + exec_fences.fences = fences; + exec_fences.count = count; + int ret = mos_bufmgr_set_fences(mediaCtx->pDrmBufMgr, &exec_fences); + + if (ret) + { + vaStatus = VA_STATUS_ERROR_OPERATION_FAILED; + } return vaStatus; } @@ -488,8 +495,14 @@ VAStatus DdiMedia_SetSyncFences(VADriverContextP ctx, VAContextID context, int32 VAStatus DdiMedia_GetSyncFenceOut(VADriverContextP ctx, VAContextID context, int32_t *fence_out) { VAStatus vaStatus = VA_STATUS_SUCCESS; - //todo: get bufmgr - //todo: int ret = mos_bufmgr_get_fence(bufmgr, fence_out); + PDDI_MEDIA_CONTEXT mediaCtx = DdiMedia_GetMediaContext(ctx); + int ret = mos_bufmgr_get_fence(mediaCtx->pDrmBufMgr, fence_out); + + if (ret) + { + vaStatus = VA_STATUS_ERROR_OPERATION_FAILED; + *fence_out = 0; + } return vaStatus; } diff --git a/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h b/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h index 9e86adc293f..f88e0cbde51 100644 --- a/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h +++ b/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h @@ -252,6 +252,12 @@ struct mos_drm_uc_version { uint32_t minor_version; }; +struct mos_exec_fences +{ + int32_t *fences; + int32_t count; +}; + struct mos_linux_bo *mos_bo_alloc(struct mos_bufmgr *bufmgr, struct mos_drm_bo_alloc *alloc); struct mos_linux_bo *mos_bo_alloc_userptr(struct mos_bufmgr *bufmgr, @@ -312,6 +318,9 @@ int mos_bufmgr_get_memory_info(struct mos_bufmgr *bufmgr, char *info, uint32_t l int mos_bufmgr_get_devid(struct mos_bufmgr *bufmgr); void mos_bufmgr_realloc_cache(struct mos_bufmgr *bufmgr, uint8_t alloc_mode); +int mos_bufmgr_set_fences(struct mos_bufmgr *bufmgr, struct mos_exec_fences *exec_fences); +int mos_bufmgr_get_fence(struct mos_bufmgr *bufmgr, int32_t *fence_out); + int mos_bo_map_unsynchronized(struct mos_linux_bo *bo); int mos_bo_map_gtt(struct mos_linux_bo *bo); int mos_bo_unmap_gtt(struct mos_linux_bo *bo); diff --git a/media_softlet/linux/common/os/i915/mos_bufmgr_api.c b/media_softlet/linux/common/os/i915/mos_bufmgr_api.c index 6a9f5f6642a..0f6bba3c3ed 100644 --- a/media_softlet/linux/common/os/i915/mos_bufmgr_api.c +++ b/media_softlet/linux/common/os/i915/mos_bufmgr_api.c @@ -1223,6 +1223,50 @@ mos_bufmgr_realloc_cache(struct mos_bufmgr *bufmgr, uint8_t alloc_mode) } } +int +mos_bufmgr_set_fences(struct mos_bufmgr *bufmgr, struct mos_exec_fences *exec_fences) +{ + if(!bufmgr) + { + MOS_OS_CRITICALMESSAGE("Input null ptr\n"); + return -EINVAL; + } + + return 0; + //todo: add func pointer to bufmgr + //if (bufmgr->set_fences) + //{ + // return bufmgr->set_fences(bufmgr, exec_fences); + //} + //else + //{ + // MOS_OS_CRITICALMESSAGE("Unsupported\n"); + //} + +} + +int +mos_bufmgr_get_fence(struct mos_bufmgr *bufmgr, int32_t *fence_out) +{ + if(!bufmgr) + { + MOS_OS_CRITICALMESSAGE("Input null ptr\n"); + return -EINVAL; + } + + return 0; + //todo: add func pointer to bufmgr + //if (bufmgr->get_fence) + //{ + // return bufmgr->get_fence(bufmgr, fence_out); + //} + //else + //{ + // MOS_OS_CRITICALMESSAGE("Unsupported\n"); + //} + +} + int mos_query_engines_count(struct mos_bufmgr *bufmgr, unsigned int *nengine)