From 241a7a5494c9553237a288be2b288f142d93f1aa Mon Sep 17 00:00:00 2001 From: "Yang, Ning" Date: Fri, 10 Aug 2018 10:02:34 +0800 Subject: [PATCH] switch gmm to dynamic Signed-off-by: Yang, Ning --- media_driver/linux/common/cm/cm_hal_os.cpp | 14 ++++-- media_driver/linux/common/cp/shared/cplib.cpp | 9 +--- media_driver/linux/common/ddi/media_libva.cpp | 37 +++++++------- .../linux/common/ddi/media_libva_common.h | 2 + .../ddi/media_libva_putsurface_linux.cpp | 5 +- .../linux/common/ddi/media_libva_util.cpp | 27 +++++++---- .../linux/common/os/mos_context_specific.cpp | 3 +- .../linux/common/os/mos_os_specific.c | 10 +++- .../linux/common/os/mos_os_specific.h | 1 + .../gpu_cmd/gpu_cmd_hcp_ind_obj_base_addr.cpp | 2 +- .../gpu_cmd/gpu_cmd_hcp_pipe_buf_addr.cpp | 48 +++++++++---------- media_driver/media_top_cmake.cmake | 31 ++++++++---- 12 files changed, 112 insertions(+), 77 deletions(-) mode change 100644 => 100755 media_driver/linux/common/cm/cm_hal_os.cpp mode change 100644 => 100755 media_driver/linux/common/cp/shared/cplib.cpp mode change 100644 => 100755 media_driver/linux/common/ddi/media_libva.cpp mode change 100644 => 100755 media_driver/linux/common/ddi/media_libva_common.h mode change 100644 => 100755 media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp mode change 100644 => 100755 media_driver/linux/common/ddi/media_libva_util.cpp mode change 100644 => 100755 media_driver/linux/common/os/mos_context_specific.cpp mode change 100644 => 100755 media_driver/linux/common/os/mos_os_specific.c mode change 100644 => 100755 media_driver/linux/common/os/mos_os_specific.h mode change 100644 => 100755 media_driver/media_top_cmake.cmake diff --git a/media_driver/linux/common/cm/cm_hal_os.cpp b/media_driver/linux/common/cm/cm_hal_os.cpp old mode 100644 new mode 100755 index ce4c56c23a9..2f04e0bc0f2 --- a/media_driver/linux/common/cm/cm_hal_os.cpp +++ b/media_driver/linux/common/cm/cm_hal_os.cpp @@ -335,7 +335,7 @@ MOS_STATUS HalCm_GetSurfaceAndRegister( //| Returns: Result of the operation. //*----------------------------------------------------------------------------- MOS_STATUS HalCm_GetSurfPitchSize( - uint32_t width, uint32_t height, MOS_FORMAT format, uint32_t *pitch, uint32_t *physicalSize) + uint32_t width, uint32_t height, MOS_FORMAT format, uint32_t *pitch, uint32_t *physicalSize, PCM_HAL_STATE state) { MOS_STATUS hr = MOS_STATUS_SUCCESS; @@ -367,12 +367,18 @@ MOS_STATUS HalCm_GetSurfPitchSize( gmmParams.NoGfxMemory = true; // get pitch and size - gmmResInfo = GmmResCreate( &gmmParams ); + if (nullptr == state || + nullptr == state->osInterface) + { + hr = MOS_STATUS_NULL_POINTER; + goto finish; + } + gmmResInfo = state->osInterface->pfnGetGmmClientContext(state->osInterface)->CreateResInfoObject(&gmmParams); if (gmmResInfo != nullptr) { *pitch = static_cast( gmmResInfo->GetRenderPitch() ); *physicalSize = static_cast( gmmResInfo->GetSizeSurface() ); - GmmResFree( gmmResInfo ); + state->osInterface->pfnGetGmmClientContext(state->osInterface)->DestroyResInfoObject(gmmResInfo); } else { @@ -395,7 +401,7 @@ MOS_STATUS HalCm_GetSurface2DPitchAndSize_Linux( { UNUSED(state); return HalCm_GetSurfPitchSize(param->width, param->height, param->format, - ¶m->pitch, ¶m->physicalSize); + ¶m->pitch, ¶m->physicalSize, state); } //*----------------------------------------------------------------------------- diff --git a/media_driver/linux/common/cp/shared/cplib.cpp b/media_driver/linux/common/cp/shared/cplib.cpp old mode 100644 new mode 100755 index 370f69b69c4..41efeef3761 --- a/media_driver/linux/common/cp/shared/cplib.cpp +++ b/media_driver/linux/common/cp/shared/cplib.cpp @@ -36,10 +36,6 @@ class MosCpInterface; typedef struct _MOS_INTERFACE* PMOS_INTERFACE; typedef struct _MOS_OS_CONTEXT MOS_CONTEXT; -typedef GmmLib::Context GMM_GLOBAL_CONTEXT; - -extern GMM_GLOBAL_CONTEXT *pGmmGlobalContext; - extern "C" CPLIB_EXPORT MediaLibvaCapsCpInterface* Create_MediaLibvaCapsCp(); extern "C" CPLIB_EXPORT void Delete_MediaLibvaCapsCp(MediaLibvaCapsCpInterface* pMediaLibvaCapsCpInterface); extern "C" CPLIB_EXPORT DdiCpInterface* Create_DdiCp(MOS_CONTEXT* pMosCtx); @@ -69,7 +65,4 @@ extern "C" CPLIB_EXPORT void Init_CPLib_Symbols() CPLibUtils::m_symbols[CPLibUtils::FUNC_DELETE_MEDIALIBVACAPSCP] = reinterpret_cast(Delete_MediaLibvaCapsCp); } -extern "C" CPLIB_EXPORT void Init_CPLib_Gmm(GMM_GLOBAL_CONTEXT* pCtx) -{ - pGmmGlobalContext = pCtx; -} \ No newline at end of file + diff --git a/media_driver/linux/common/ddi/media_libva.cpp b/media_driver/linux/common/ddi/media_libva.cpp old mode 100644 new mode 100755 index e3870b2007b..d5af4e980f6 --- a/media_driver/linux/common/ddi/media_libva.cpp +++ b/media_driver/linux/common/ddi/media_libva.cpp @@ -1398,12 +1398,15 @@ VAStatus DdiMedia__Initialize ( output_dri_init(ctx); #endif + void *gmm_handle = dlopen(GMM_UMD_DLL, RTLD_NOW); + auto openGmmFunc = reinterpret_cast(dlsym(gmm_handle, GMM_ENTRY_NAME)); + openGmmFunc(&mediaCtx->GmmFuncs); + // init GMM context - GMM_STATUS gmmStatus = GmmInitGlobalContext(mediaCtx->platform, + GMM_STATUS gmmStatus = mediaCtx->GmmFuncs.pfnCreateSingletonContext(mediaCtx->platform, &gmmSkuTable, &gmmWaTable, - &gmmGtInfo, - (GMM_CLIENT)GMM_LIBVA_LINUX); + &gmmGtInfo); if(gmmStatus != GMM_SUCCESS) { @@ -1412,6 +1415,9 @@ VAStatus DdiMedia__Initialize ( return VA_STATUS_ERROR_OPERATION_FAILED; } + // Create GMM Client Context + mediaCtx->pGmmClientContext = mediaCtx->GmmFuncs.pfnCreateClientContext((GMM_CLIENT)GMM_LIBVA_LINUX); + // Create GMM page table manager mediaCtx->m_auxTableMgr = AuxTableMgr::CreateAuxTableMgr(mediaCtx->pDrmBufMgr, &mediaCtx->SkuTable, &mediaCtx->WaTable); @@ -1472,12 +1478,6 @@ VAStatus DdiMedia__Initialize ( } } - if(CPLibUtils::IsCPLibLoaded()) - { - using InitCPLibGmmFuncType = void (*)(GMM_GLOBAL_CONTEXT* pCtx); - CPLibUtils::InvokeCpFunc(CPLibUtils::FUNC_INIT_CPLIB_GMM, pGmmGlobalContext); - } - DdiMediaUtil_UnLockMutex(&GlobalMutex); return VA_STATUS_SUCCESS; @@ -1627,15 +1627,16 @@ static VAStatus DdiMedia_Terminate ( mediaCtx->m_caps = nullptr; } + // Free GMM memory. + mediaCtx->GmmFuncs.pfnDeleteClientContext(mediaCtx->pGmmClientContext); + mediaCtx->GmmFuncs.pfnDestroySingletonContext(); + // release media driver context MOS_FreeMemory(mediaCtx); ctx->pDriverData = nullptr; MOS_utilities_close(); - // Free GMM memory. - GmmDestroyGlobalContext(); - DdiMediaUtil_UnLockMutex(&GlobalMutex); return VA_STATUS_SUCCESS; @@ -3748,6 +3749,7 @@ VAStatus DdiMedia_CreateImage( PDDI_MEDIA_CONTEXT mediaCtx = DdiMedia_GetMediaContext(ctx); DDI_CHK_NULL(mediaCtx, "nullptr mediaCtx.", VA_STATUS_ERROR_INVALID_PARAMETER); + DDI_CHK_NULL(mediaCtx->pGmmClientContext, "nullptr mediaCtx->pGmmClientContext.", VA_STATUS_ERROR_INVALID_PARAMETER); VAImage *vaimg = (VAImage*)MOS_AllocAndZeroMemory(sizeof(VAImage)); DDI_CHK_NULL(vaimg, "Insufficient to allocate an VAImage.", VA_STATUS_ERROR_ALLOCATION_FAILED); @@ -3830,7 +3832,7 @@ VAStatus DdiMedia_CreateImage( return VA_STATUS_ERROR_UNIMPLEMENTED; } - gmmResourceInfo = GmmResCreate(&gmmParams); + gmmResourceInfo = mediaCtx->pGmmClientContext->CreateResInfoObject(&gmmParams); if(nullptr == gmmResourceInfo) { DDI_ASSERTMESSAGE("Gmm Create Resource Failed."); @@ -3895,7 +3897,7 @@ VAStatus DdiMedia_CreateImage( break; } - GmmResFree(gmmResourceInfo); + mediaCtx->pGmmClientContext->DestroyResInfoObject(gmmResourceInfo); DDI_MEDIA_BUFFER *buf = (DDI_MEDIA_BUFFER *)MOS_AllocAndZeroMemory(sizeof(DDI_MEDIA_BUFFER)); if (nullptr == buf) @@ -5720,8 +5722,9 @@ VAStatus DdiMedia_ExportSurfaceHandle( DDI_CHK_LESS((uint32_t)(surface_id), mediaCtx->pSurfaceHeap->uiAllocatedHeapElements, "Invalid surfaces", VA_STATUS_ERROR_INVALID_SURFACE); DDI_MEDIA_SURFACE *mediaSurface = DdiMedia_GetSurfaceFromVASurfaceID(mediaCtx, surface_id); - DDI_CHK_NULL(mediaSurface, "nullptr mediaSurface", VA_STATUS_ERROR_INVALID_SURFACE); - DDI_CHK_NULL(mediaSurface->bo, "nullptr mediaSurface bo", VA_STATUS_ERROR_INVALID_SURFACE); + DDI_CHK_NULL(mediaSurface, "nullptr mediaSurface", VA_STATUS_ERROR_INVALID_SURFACE); + DDI_CHK_NULL(mediaSurface->bo, "nullptr mediaSurface->bo", VA_STATUS_ERROR_INVALID_SURFACE); + DDI_CHK_NULL(mediaSurface->pGmmResourceInfo, "nullptr mediaSurface->pGmmResourceInfo", VA_STATUS_ERROR_INVALID_SURFACE); int32_t ret = mos_bo_gem_export_to_prime(mediaSurface->bo, (int32_t*)&mediaSurface->name); if (ret) @@ -5745,7 +5748,7 @@ VAStatus DdiMedia_ExportSurfaceHandle( desc->num_objects = 1; desc->objects[0].fd = mediaSurface->name; - desc->objects[0].size = GmmResGetSizeSurface(mediaSurface->pGmmResourceInfo); + desc->objects[0].size = mediaSurface->pGmmResourceInfo->GetSizeSurface(); switch (tiling) { case I915_TILING_X: desc->objects[0].drm_format_modifier = I915_FORMAT_MOD_X_TILED; diff --git a/media_driver/linux/common/ddi/media_libva_common.h b/media_driver/linux/common/ddi/media_libva_common.h old mode 100644 new mode 100755 index 2988d5325ee..0e388bc5967 --- a/media_driver/linux/common/ddi/media_libva_common.h +++ b/media_driver/linux/common/ddi/media_libva_common.h @@ -437,6 +437,8 @@ struct DDI_MEDIA_CONTEXT GMM_CLIENT_CONTEXT *pGmmClientContext; + GmmExportEntries GmmFuncs; + // Aux Table Manager AuxTableMgr *m_auxTableMgr; diff --git a/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp b/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp old mode 100644 new mode 100755 index 06abe9ca09a..05555683012 --- a/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp +++ b/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp @@ -374,6 +374,7 @@ VAStatus DdiCodec_PutSurfaceLinuxHW( DDI_CHK_NULL(mediaCtx, "Null mediaCtx", VA_STATUS_ERROR_INVALID_CONTEXT); DDI_CHK_NULL(mediaCtx->dri_output, "Null mediaDrvCtx->dri_output", VA_STATUS_ERROR_INVALID_PARAMETER); DDI_CHK_NULL(mediaCtx->pSurfaceHeap, "Null mediaDrvCtx->pSurfaceHeap", VA_STATUS_ERROR_INVALID_PARAMETER); + DDI_CHK_NULL(mediaCtx->pGmmClientContext, "Null mediaCtx->pGmmClientContext", VA_STATUS_ERROR_INVALID_PARAMETER); DDI_CHK_LESS((uint32_t)surface, mediaCtx->pSurfaceHeap->uiAllocatedHeapElements, "Invalid surfaceId", VA_STATUS_ERROR_INVALID_SURFACE); struct dri_vtable * const dri_vtable = &mediaCtx->dri_output->vtable; @@ -485,7 +486,7 @@ VAStatus DdiCodec_PutSurfaceLinuxHW( gmmParams.Type = RESOURCE_2D; gmmParams.Format = GMM_FORMAT_R8G8B8A8_UNORM_TYPE; //gmmParams.Format = GMM_FORMAT_B8G8R8A8_UNORM_TYPE; - target.OsResource.pGmmResInfo = GmmResCreate(&gmmParams); + target.OsResource.pGmmResInfo = mediaCtx->pGmmClientContext->CreateResInfoObject(&gmmParams); if (nullptr == target.OsResource.pGmmResInfo) { mos_bo_unreference(drawable_bo); @@ -529,7 +530,7 @@ VAStatus DdiCodec_PutSurfaceLinuxHW( dri_vtable->swap_buffer(ctx, dri_drawable); DdiMediaUtil_UnLockMutex(&mediaCtx->PutSurfaceSwapBufferMutex); - GmmResFree(target.OsResource.pGmmResInfo); + mediaCtx->pGmmClientContext->DestroyResInfoObject(target.OsResource.pGmmResInfo); target.OsResource.pGmmResInfo = nullptr; return VA_STATUS_SUCCESS; diff --git a/media_driver/linux/common/ddi/media_libva_util.cpp b/media_driver/linux/common/ddi/media_libva_util.cpp old mode 100644 new mode 100755 index b6cc37c1094..48d48af9776 --- a/media_driver/linux/common/ddi/media_libva_util.cpp +++ b/media_driver/linux/common/ddi/media_libva_util.cpp @@ -297,6 +297,7 @@ VAStatus DdiMediaUtil_AllocateSurface( DDI_CHK_NULL(mediaSurface, "mediaSurface is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); DDI_CHK_NULL(mediaDrvCtx, "mediaDrvCtx is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); + DDI_CHK_NULL(mediaDrvCtx->pGmmClientContext, "mediaDrvCtx->pGmmClientContext is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); int32_t size = 0; uint32_t tileformat = I915_TILING_NONE; @@ -497,7 +498,7 @@ VAStatus DdiMediaUtil_AllocateSurface( gmmParams.Flags.Gpu.Video = true; - mediaSurface->pGmmResourceInfo = gmmResourceInfo = GmmResCreate(&gmmParams); + mediaSurface->pGmmResourceInfo = gmmResourceInfo = mediaDrvCtx->pGmmClientContext->CreateResInfoObject(&gmmParams); if(nullptr == gmmResourceInfo) { @@ -638,6 +639,8 @@ VAStatus DdiMediaUtil_AllocateBuffer( { DDI_CHK_NULL(mediaBuffer, "mediaBuffer is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); + DDI_CHK_NULL(mediaBuffer->pMediaCtx, "mediaBuffer->pMediaCtx is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); + DDI_CHK_NULL(mediaBuffer->pMediaCtx->pGmmClientContext, "mediaBuffer->pMediaCtx->pGmmClientContext is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); if(format >= Media_Format_Count) return VA_STATUS_ERROR_INVALID_PARAMETER; @@ -673,12 +676,12 @@ VAStatus DdiMediaUtil_AllocateBuffer( gmmParams.Flags.Gpu.Video = true; gmmParams.Flags.Info.Linear = true; - mediaBuffer->pGmmResourceInfo = GmmResCreate(&gmmParams); + mediaBuffer->pGmmResourceInfo = mediaBuffer->pMediaCtx->pGmmClientContext->CreateResInfoObject(&gmmParams); DDI_CHK_NULL(mediaBuffer->pGmmResourceInfo, "pGmmResourceInfo is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); - GmmResOverrideAllocationSize(mediaBuffer->pGmmResourceInfo, mediaBuffer->iSize); - GmmResOverrideAllocationBaseWidth(mediaBuffer->pGmmResourceInfo, mediaBuffer->iSize); - GmmResOverrideAllocationPitch(mediaBuffer->pGmmResourceInfo, mediaBuffer->iSize); + mediaBuffer->pGmmResourceInfo->OverrideSize(mediaBuffer->iSize); + mediaBuffer->pGmmResourceInfo->OverrideBaseWidth(mediaBuffer->iSize); + mediaBuffer->pGmmResourceInfo->OverridePitch(mediaBuffer->iSize); finish: return hRes; } @@ -705,6 +708,8 @@ VAStatus DdiMediaUtil_Allocate2DBuffer( MOS_BUFMGR *bufmgr) { DDI_CHK_NULL(mediaBuffer, "mediaBuffer is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); + DDI_CHK_NULL(mediaBuffer->pMediaCtx, "mediaBuffer->pMediaCtx is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); + DDI_CHK_NULL(mediaBuffer->pMediaCtx->pGmmClientContext, "mediaBuffer->pMediaCtx->pGmmClientContext is nullptr", VA_STATUS_ERROR_INVALID_BUFFER); int32_t size = 0; uint32_t tileformat = I915_TILING_NONE; @@ -726,7 +731,7 @@ VAStatus DdiMediaUtil_Allocate2DBuffer( gmmParams.Flags.Info.Linear = true; gmmParams.Flags.Gpu.Video = true; GMM_RESOURCE_INFO *gmmResourceInfo; - mediaBuffer->pGmmResourceInfo = gmmResourceInfo = GmmResCreate(&gmmParams); + mediaBuffer->pGmmResourceInfo = gmmResourceInfo = mediaBuffer->pMediaCtx->pGmmClientContext->CreateResInfoObject(&gmmParams); if(nullptr == gmmResourceInfo) { @@ -1034,6 +1039,8 @@ void DdiMediaUtil_FreeSurface(DDI_MEDIA_SURFACE *surface) { DDI_CHK_NULL(surface, "nullptr surface", ); DDI_CHK_NULL(surface->bo, "nullptr surface->bo", ); + DDI_CHK_NULL(surface->pMediaCtx, "nullptr surface->pMediaCtx", ); + DDI_CHK_NULL(surface->pMediaCtx->pGmmClientContext, "nullptr surface->pMediaCtx->pGmmClientContext", ); // Unmap Aux mapping if the surface was mapped if (surface->pMediaCtx->m_auxTableMgr) @@ -1064,7 +1071,7 @@ void DdiMediaUtil_FreeSurface(DDI_MEDIA_SURFACE *surface) if (nullptr != surface->pGmmResourceInfo) { - GmmResFree(surface->pGmmResourceInfo); + surface->pMediaCtx->pGmmClientContext->DestroyResInfoObject(surface->pGmmResourceInfo); surface->pGmmResourceInfo = nullptr; } } @@ -1074,6 +1081,8 @@ void DdiMediaUtil_FreeSurface(DDI_MEDIA_SURFACE *surface) void DdiMediaUtil_FreeBuffer(DDI_MEDIA_BUFFER *buf) { DDI_CHK_NULL(buf, "nullptr", ); + DDI_CHK_NULL(buf->pMediaCtx, "nullptr", ); + DDI_CHK_NULL(buf->pMediaCtx->pGmmClientContext, "nullptr", ); // calling sequence checking if (buf->bMapped) { @@ -1093,7 +1102,7 @@ void DdiMediaUtil_FreeBuffer(DDI_MEDIA_BUFFER *buf) if (nullptr != buf->pGmmResourceInfo) { - GmmResFree(buf->pGmmResourceInfo); + buf->pMediaCtx->pGmmClientContext->DestroyResInfoObject(buf->pGmmResourceInfo); buf->pGmmResourceInfo = nullptr; } } @@ -1406,7 +1415,7 @@ VAStatus DdiMediaUtil_UnRegisterRTSurfaces( PDDI_MEDIA_CONTEXT mediaCtx = DdiMedia_GetMediaContext(ctx); DDI_CHK_NULL(mediaCtx,"nullptr mediaCtx!", VA_STATUS_ERROR_INVALID_CONTEXT); DDI_CHK_NULL(surface, "nullptr surface!", VA_STATUS_ERROR_INVALID_PARAMETER); - + //Look through all decode contexts to unregister the surface in each decode context's RTtable. if (mediaCtx->pDecoderCtxHeap != nullptr) { diff --git a/media_driver/linux/common/os/mos_context_specific.cpp b/media_driver/linux/common/os/mos_context_specific.cpp old mode 100644 new mode 100755 index ba8b4325947..0956628bd39 --- a/media_driver/linux/common/os/mos_context_specific.cpp +++ b/media_driver/linux/common/os/mos_context_specific.cpp @@ -505,7 +505,7 @@ MOS_STATUS OsContextSpecific::Init(PMOS_CONTEXT pOsDriverContext) MOS_SecureMemcpy(&m_perfData, sizeof(PERF_DATA), pOsDriverContext->pPerfData, sizeof(PERF_DATA)); mos_bufmgr_gem_enable_reuse(pOsDriverContext->bufmgr); m_cpContext = pOsDriverContext->pCpContext; - m_pGmmClientContext = GmmCreateClientContext((GMM_CLIENT)GMM_LIBVA_LINUX); + m_pGmmClientContext = pOsDriverContext->pGmmClientContext; m_auxTableMgr = pOsDriverContext->m_auxTableMgr; // DDI layer can pass over the DeviceID. @@ -656,7 +656,6 @@ void OsContextSpecific::Destroy() { mos_gem_context_destroy(m_intelContext); } - GmmDeleteClientContext(m_pGmmClientContext); SetOsContextValid(false); } diff --git a/media_driver/linux/common/os/mos_os_specific.c b/media_driver/linux/common/os/mos_os_specific.c old mode 100644 new mode 100755 index 29c97eb788d..bcfa638535c --- a/media_driver/linux/common/os/mos_os_specific.c +++ b/media_driver/linux/common/os/mos_os_specific.c @@ -1001,7 +1001,7 @@ void Linux_Destroy( mos_gem_context_destroy(pOsContext->intel_context); } - GmmDeleteClientContext(pOsContext->pGmmClientContext); + pOsContext->GmmFuncs.pfnDeleteClientContext(pOsContext->pGmmClientContext); MOS_FreeMemAndSetNull(pOsContext); } @@ -5701,6 +5701,7 @@ MOS_STATUS Mos_Specific_InitInterface( uint32_t dwResetCount; int32_t ret; bool modularizedGpuCtxEnabled; + void *gmm_handle; MOS_OS_FUNCTION_ENTER; @@ -5708,6 +5709,9 @@ MOS_STATUS Mos_Specific_InitInterface( pOsContext = nullptr; pOsUserFeatureInterface = (PMOS_USER_FEATURE_INTERFACE)&pOsInterface->UserFeatureInterface; + gmm_handle = dlopen(GMM_UMD_DLL, RTLD_NOW); + auto openGmmFunc = reinterpret_cast(dlsym(gmm_handle, GMM_ENTRY_NAME)); + MOS_OS_NORMALMESSAGE("mm:Mos_Specific_InitInterface called."); MOS_OS_CHK_NULL(pOsInterface); @@ -5725,6 +5729,8 @@ MOS_STATUS Mos_Specific_InitInterface( goto finish; } + openGmmFunc(&pOsContext->GmmFuncs); + pOsContext->intel_context = nullptr; if (pOsInterface->modulizedMosEnabled && !Mos_Solo_IsEnabled()) { @@ -5755,7 +5761,7 @@ MOS_STATUS Mos_Specific_InitInterface( } else { - pOsContext->pGmmClientContext = GmmCreateClientContext((GMM_CLIENT)GMM_LIBVA_LINUX); + pOsContext->pGmmClientContext = pOsContext->GmmFuncs.pfnCreateClientContext((GMM_CLIENT)GMM_LIBVA_LINUX); } // Initialize diff --git a/media_driver/linux/common/os/mos_os_specific.h b/media_driver/linux/common/os/mos_os_specific.h old mode 100644 new mode 100755 index af9e6fad4bd..b6f3266a3eb --- a/media_driver/linux/common/os/mos_os_specific.h +++ b/media_driver/linux/common/os/mos_os_specific.h @@ -518,6 +518,7 @@ struct _MOS_OS_CONTEXT void *pLibdrmHandle; GMM_CLIENT_CONTEXT *pGmmClientContext; //UMD specific ClientContext object in GMM + GmmExportEntries GmmFuncs; AuxTableMgr *m_auxTableMgr; // GPU Status Buffer diff --git a/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_ind_obj_base_addr.cpp b/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_ind_obj_base_addr.cpp index ce750136ffb..f62211210dc 100644 --- a/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_ind_obj_base_addr.cpp +++ b/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_ind_obj_base_addr.cpp @@ -23,5 +23,5 @@ void GpuCmdHcpIndObjBaseAddrG10::InitCachePolicy() { - m_pCmd->HcpIndirectBitstreamObjectMemoryAddressAttributes.DW0.Value |= 8; + m_pCmd->HcpIndirectBitstreamObjectMemoryAddressAttributes.DW0.Value |= 0; } diff --git a/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_pipe_buf_addr.cpp b/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_pipe_buf_addr.cpp index d31ced0ea44..55c0a9abf00 100644 --- a/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_pipe_buf_addr.cpp +++ b/media_driver/linux/ult/ult_app/gpu_cmd/gpu_cmd_hcp_pipe_buf_addr.cpp @@ -23,28 +23,28 @@ void GpuCmdHcpPipeBufAddrG10::InitCachePolicy() { - m_pCmd->DecodedPictureMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->DeblockingFilterLineBufferMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->DeblockingFilterTileLineBufferMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->DeblockingFilterTileColumnBufferMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->MetadataLineBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->MetadataTileLineBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->MetadataTileColumnBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->SaoLineBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->SaoTileLineBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->SaoTileColumnBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->CurrentMotionVectorTemporalBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->ReferencePictureBaseAddressMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->OriginalUncompressedPictureSourceMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->StreamoutDataDestinationMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->DecodedPictureStatusErrorBufferBaseAddressMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->LcuIldbStreamoutBufferMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->CollocatedMotionVectorTemporalBuffer07MemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->Vp9ProbabilityBufferReadWriteMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->Vp9SegmentIdBufferReadWriteMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->Vp9HvdLineRowstoreBufferReadWriteMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->Vp9HvdTileRowstoreBufferReadWriteMemoryAddressAttributes.DW0.Value |= 6; - m_pCmd->SaoStreamoutDataDestinationBufferReadWriteMemoryAddressAttributes.DW0.Value |= 8; - m_pCmd->FrameStatisticsStreamoutDataDestinationBufferAttributesReadWrite.DW0.Value |= 8; - m_pCmd->SseSourcePixelRowstoreBufferAttributesReadWrite.DW0.Value |= 6; + m_pCmd->DecodedPictureMemoryAddressAttributes.DW0.Value |= 0; + m_pCmd->DeblockingFilterLineBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->DeblockingFilterTileLineBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->DeblockingFilterTileColumnBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->MetadataLineBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->MetadataTileLineBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->MetadataTileColumnBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->SaoLineBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->SaoTileLineBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->SaoTileColumnBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->CurrentMotionVectorTemporalBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->ReferencePictureBaseAddressMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->OriginalUncompressedPictureSourceMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->StreamoutDataDestinationMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->DecodedPictureStatusErrorBufferBaseAddressMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->LcuIldbStreamoutBufferMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->CollocatedMotionVectorTemporalBuffer07MemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->Vp9ProbabilityBufferReadWriteMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->Vp9SegmentIdBufferReadWriteMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->Vp9HvdLineRowstoreBufferReadWriteMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->Vp9HvdTileRowstoreBufferReadWriteMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->SaoStreamoutDataDestinationBufferReadWriteMemoryAddressAttributes.DW0.Value |= 4; + m_pCmd->FrameStatisticsStreamoutDataDestinationBufferAttributesReadWrite.DW0.Value |= 4; + m_pCmd->SseSourcePixelRowstoreBufferAttributesReadWrite.DW0.Value |= 4; } diff --git a/media_driver/media_top_cmake.cmake b/media_driver/media_top_cmake.cmake old mode 100644 new mode 100755 index b4884331d86..aedc8f23556 --- a/media_driver/media_top_cmake.cmake +++ b/media_driver/media_top_cmake.cmake @@ -81,19 +81,34 @@ bs_ufo_link_libraries_noBsymbolic( "pciaccess m pthread dl rt" ) +find_package(PkgConfig) + if (NOT DEFINED INCLUDED_LIBS OR "${INCLUDED_LIBS}" STREQUAL "") - # dep libs (gmmlib for now) can be passed through INCLUDED_LIBS, but if not, we need try to setup dep through including dep projects - if (NOT TARGET gmm_umd) - add_subdirectory("${BS_DIR_GMMLIB}" "${CMAKE_BINARY_DIR}/gmmlib") + + # checking gmm dependencies + pkg_check_modules(LIBGMM igdgmm) + + if(LIBGMM_FOUND) + include_directories(BEFORE ${LIBGMM_INCLUDE_DIRS}) + link_directories(${LIBGMM_LIBRARY_DIRS}) + target_link_libraries ( ${LIB_NAME} ${LIBGMM_LIBRARIES}) endif() - if (TARGET gmm_umd) - target_link_libraries ( ${LIB_NAME} - gmm_umd - ) + # dep libs (gmmlib for now) can be passed through INCLUDED_LIBS, but if not, we need try to setup dep through including dep projects + if (NOT LIBGMM_FOUND) + if (NOT TARGET igfx_gmmumd_dll) + add_subdirectory("${BS_DIR_GMMLIB}" "${CMAKE_BINARY_DIR}/gmmlib") + endif() + + if (TARGET igfx_gmmumd_dll) + target_link_libraries ( ${LIB_NAME} + igfx_gmmumd_dll + ) + endif() endif() -include(${MEDIA_DRIVER_CMAKE}/ext/media_feature_include_ext.cmake OPTIONAL) + target_compile_definitions(${LIB_NAME} PUBLIC GMM_LIB_DLL) + include(${MEDIA_DRIVER_CMAKE}/ext/media_feature_include_ext.cmake OPTIONAL) endif(NOT DEFINED INCLUDED_LIBS OR "${INCLUDED_LIBS}" STREQUAL "")