jacinto6: sgx-bin: update sgx binaries and source for drm/gem support
authorHemant Hariyani <hemanthariyani@ti.com>
Tue, 25 Nov 2014 20:55:21 +0000 (14:55 -0600)
committerHemant Hariyani <hemanthariyani@ti.com>
Tue, 25 Nov 2014 20:55:21 +0000 (14:55 -0600)
Adds sgx km source and ddk binaries with gem support.

Change-Id: I22f6dbec3e5ed3202a803d4cdb48e12fc2877220
Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
19 files changed:
jacinto6/README.SGX
jacinto6/sgx.tgz
jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/common/android/features.mk
jacinto6/sgx_src/eurasia_km/eurasiacon/build/linux2/config/core.mk
jacinto6/sgx_src/eurasia_km/include4/services.h
jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge.h
jacinto6/sgx_src/eurasia_km/services4/include/pvr_bridge_km.h
jacinto6/sgx_src/eurasia_km/services4/include/servicesint.h
jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/common/devicemem.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/common/pvrsrv.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/common/refcount.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/common/resman.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/Kbuild.mk
jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osfunc.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/osperproc.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/env/linux/pvr_debug.c
jacinto6/sgx_src/eurasia_km/services4/srvkm/include/refcount.h
jacinto6/sgx_src/eurasia_km/services4/srvkm/include/resman.h

index 6f01818d4d7e408710fcff2bdd867f64b70d8185..1479e47f2182395e8f609923007b264c9d2d2eb4 100644 (file)
@@ -16,9 +16,9 @@ sgx.tgz a set of binaries built for SGX544.
 [DDK Version]
     1.12/2917986
 [DDK commit ID]
-    a0d3db4 tmp: Changes for Android L
+    0c60181 android: update hal_public.h for TI formats
 [Branch]
-    android/1.12/2917986_k3.14_L
+    android/1.12/2917986_k3.14_L_gem
 [Kernel modules built against]
     Kernel Version: 3.14.y with CONFIG_MODVERSIONS=y
 
@@ -33,7 +33,7 @@ Make sure kernel is built before building modules
 # export KERNELDIR=path_to_kernel
 
 To build for OMAP5 (SGX 544 multi core):
-# make ARCH=arm KERNEL_CROSS_COMPILE=arm-eabi- CROSS_COMPILE=arm-eabi- TARGET_PRODUCT="jacinto6evm" PLATFORM_VERSION=4.4 BUILD=release
+# make ARCH=arm KERNEL_CROSS_COMPILE=arm-eabi- CROSS_COMPILE=arm-eabi- TARGET_PRODUCT="jacinto6evm" PLATFORM_VERSION=5.0 BUILD=debug
 
 Once the .ko is built, install it onto device (/system/lib/modules)
 
index da131fa8fb045ddf12a8d5480c928ea9e482d86b..087bdc9984129fdbdc50b2d6016c58a8c1db52dc 100644 (file)
Binary files a/jacinto6/sgx.tgz and b/jacinto6/sgx.tgz differ
index 0b40526ddc231e00978a08cfc1fc59e636c83c3f..7697f1320dc4c77685fd1daa9ed60c1ab29516f1 100644 (file)
@@ -51,7 +51,8 @@ SUPPORT_MEMINFO_IDS := 1
 
 # Enable services ion support by default
 #
-SUPPORT_ION ?= 1
+SUPPORT_ION := 0
+SUPPORT_DRM_GEM := 1
 
 # Need multi-process support in PDUMP
 #
index 052c35eec057d7bfea67084fdb8ade09d5a6e000..1bfce0197f5a532841417548c68788fae9f5472c 100644 (file)
@@ -578,6 +578,7 @@ $(eval $(call TunableBothConfigC,PVRSRV_NEED_PVR_ASSERT,))
 $(eval $(call TunableBothConfigC,PVRSRV_NEED_PVR_TRACE,))
 $(eval $(call TunableBothConfigC,SUPPORT_SECURE_33657_FIX,))
 $(eval $(call TunableBothConfigC,SUPPORT_ION,))
+$(eval $(call TunableBothConfigC,SUPPORT_DRM_GEM,))
 $(eval $(call TunableBothConfigC,SUPPORT_HWRECOVERY_TRACE_LIMIT,))
 $(eval $(call TunableBothConfigC,SUPPORT_PVRSRV_DEVICE_CLASS,))
 $(eval $(call TunableBothConfigC,SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER,1))
@@ -619,6 +620,7 @@ $(eval $(call TunableKernelConfigC,SUPPORT_FORCE_SYNC_DUMP,))
 
 $(eval $(call TunableBothConfigMake,OPTIM,))
 $(eval $(call TunableBothConfigMake,SUPPORT_ION,))
+$(eval $(call TunableBothConfigMake,SUPPORT_DRM_GEM,))
 $(eval $(call TunableBothConfigMake,SUPPORT_PVRSRV_DEVICE_CLASS,))
 
 
index 8828fa98cf32b7eef8ab6498d20c21530fb008de..cca0f7dccb495f215f09eeb8191d4bda6da3a9a4 100644 (file)
@@ -169,6 +169,8 @@ extern "C" {
 #define PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT                 (1U<<7)
 #define PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT                 (1U<<8)
 #define PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT  (1U<<9)
+#define PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT                            (1U<<10)
+#define PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT                            (1U<<11)
 
 #define PVRSRV_MISC_INFO_RESET_PRESENT                                 (1U<<31)
 
@@ -444,6 +446,9 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_
        IMG_UINT32                                                      dummy2;
        #endif /* !defined(USE_CODE) */
 #endif /* defined(SUPPORT_MEMINFO_IDS) */
+#if defined(SUPPORT_DRM_GEM)
+       IMG_SIZE_T                                                      uiDmabufBufferSize;
+#endif /* defined(SUPPORT_DRM_GEM) */
 #if defined(SUPPORT_ION)
        IMG_SIZE_T                                                      uiIonBufferSize;
 #endif /* defined(SUPPORT_ION) */
@@ -577,6 +582,7 @@ typedef struct _PVRSRV_MISC_INFO_
        } sGetRefCountCtl;
 
        IMG_UINT32 ui32PageSize;
+       IMG_INT32 iDrmFd;
 } PVRSRV_MISC_INFO;
 
 /*!
@@ -778,6 +784,21 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory2(IMG_CONST PVRSRV_DEV_DATA *psDe
                                                                                                 PVRSRV_CLIENT_MEM_INFO         **ppsDstMemInfo);
 #endif /* defined(LINUX) */
 
+#if defined(SUPPORT_DRM_GEM)
+PVRSRV_ERROR PVRSRVMapDmabuf(const PVRSRV_DEV_DATA *psDevData,
+                                                               IMG_HANDLE hDevMemHeap,
+                                                               IMG_UINT32 ui32NumFDs,
+                                                               IMG_INT    *paiBufferFDs,
+                                                               IMG_UINT32 ui32ChunkCount,
+                                                               IMG_SIZE_T *pauiOffset,
+                                                               IMG_SIZE_T *pauiSize,
+                                                               IMG_UINT32 ui32Attribs,
+                                                               PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
+
+PVRSRV_ERROR PVRSRVUnmapDmabuf(const PVRSRV_DEV_DATA *psDevData,
+                                                                 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
+#endif /* defined (SUPPORT_DRM_GEM) */
+
 #if defined(SUPPORT_ION)
 PVRSRV_ERROR PVRSRVMapIonHandle(const PVRSRV_DEV_DATA *psDevData,
                                                                IMG_HANDLE hDevMemHeap,
index cf84f76082f76dba532a7af6040255a023a80ce8..f8e1439e60b66cac178e728a0fa4c9281dd6a31d 100644 (file)
@@ -121,13 +121,11 @@ extern "C" {
 #define PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS              PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+26)
 #define PVRSRV_BRIDGE_MAP_DEV_MEMORY_2                 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+27)
 #define PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2               PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+28)
-#if defined (SUPPORT_ION)
-#define PVRSRV_BRIDGE_MAP_ION_HANDLE                   PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29)
-#define PVRSRV_BRIDGE_UNMAP_ION_HANDLE                 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30)
-#define PVRSRV_BRIDGE_CORE_CMD_LAST                            (PVRSRV_BRIDGE_CORE_CMD_FIRST+30)
-#else
-#define PVRSRV_BRIDGE_CORE_CMD_LAST                            (PVRSRV_BRIDGE_CORE_CMD_FIRST+28)
-#endif
+#define PVRSRV_BRIDGE_MAP_DMABUF                       PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29)
+#define PVRSRV_BRIDGE_UNMAP_DMABUF                     PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30)
+#define PVRSRV_BRIDGE_MAP_ION_HANDLE                   PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+31)
+#define PVRSRV_BRIDGE_UNMAP_ION_HANDLE                 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+32)
+#define PVRSRV_BRIDGE_CORE_CMD_LAST                            (PVRSRV_BRIDGE_CORE_CMD_FIRST+32)
 /* SIM */
 #define PVRSRV_BRIDGE_SIM_CMD_FIRST                            (PVRSRV_BRIDGE_CORE_CMD_LAST+1)
 #define PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT             PVRSRV_IOWR(PVRSRV_BRIDGE_SIM_CMD_FIRST+0)      /*!< RTSIM pseudo ISR */
@@ -532,6 +530,33 @@ typedef struct PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM_TAG
 
 }PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM;
 
+/******************************************************************************
+ *     'bridge in' map dmabuf
+ *****************************************************************************/
+#define DMABUF_IMPORT_MAX_FDS 3
+#define DMABUF_IMPORT_MAX_CHUNK_COUNT 3
+typedef struct _PVRSRV_BRIDGE_IN_MAP_DMABUF_
+{
+       IMG_UINT32                      ui32BridgeFlags; /* Must be first member of structure */
+       IMG_UINT32                      ui32NumFDs;
+       IMG_INT32                       ai32BufferFDs[DMABUF_IMPORT_MAX_FDS];
+       IMG_UINT32                      ui32Attribs;
+       IMG_UINT32                      ui32ChunkCount;
+       IMG_SIZE_T                      auiOffset[DMABUF_IMPORT_MAX_CHUNK_COUNT];
+       IMG_SIZE_T                      auiSize[DMABUF_IMPORT_MAX_CHUNK_COUNT];
+       IMG_HANDLE                      hDevCookie;
+       IMG_HANDLE                      hDevMemHeap;
+} PVRSRV_BRIDGE_IN_MAP_DMABUF;
+
+/******************************************************************************
+ *     'bridge in' unmap dmabuf
+ *****************************************************************************/
+typedef struct PVRSRV_BRIDGE_IN_UNMAP_DMABUF_TAG
+{
+       IMG_UINT32              ui32BridgeFlags; /* Must be first member of structure */
+       PVRSRV_KERNEL_MEM_INFO  *psKernelMemInfo;
+}PVRSRV_BRIDGE_IN_UNMAP_DMABUF;
+
 /******************************************************************************
  *     'bridge in' map ion handle
  *****************************************************************************/
@@ -1406,6 +1431,19 @@ typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG
 } PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM;
 
 
+/******************************************************************************
+ *     'bridge out' map dmabuf
+ *****************************************************************************/
+typedef struct _PVRSRV_BRIDGE_OUT_MAP_DMABUF_
+{
+       PVRSRV_ERROR            eError;
+       PVRSRV_KERNEL_MEM_INFO  *psKernelMemInfo;
+       PVRSRV_CLIENT_MEM_INFO  sClientMemInfo;
+       PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo;
+       IMG_SIZE_T                              uiDmabufBufferSize;
+
+} PVRSRV_BRIDGE_OUT_MAP_DMABUF;
+
 /******************************************************************************
  *     'bridge out' map ion handle
  *****************************************************************************/
index d6f7a726155db1e050280286d5450996cc8ba00a..28c12689e571516ce8ed79987f13ed3acd3cda3c 100644 (file)
@@ -145,6 +145,25 @@ IMG_IMPORT
 PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE                     hDevCookie,
                                                                                                PVRSRV_KERNEL_MEM_INFO  *psMemInfo);
 
+#if defined(SUPPORT_DRM_GEM)
+IMG_IMPORT
+PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
+                                                                 IMG_HANDLE hDevCookie,
+                                                                 IMG_HANDLE hDevMemHeap,
+                                                                 IMG_UINT32 ui32NumFDs,
+                                                                 IMG_INT32  *pai32BufferFDs,
+                                                                 IMG_UINT32 ui32Flags,
+                                                                 IMG_UINT32 ui32ChunkCount,
+                                                                 IMG_SIZE_T *pauiOffset,
+                                                                 IMG_SIZE_T *pauiSize,
+                                                                 IMG_SIZE_T *puiIonBufferSize,
+                                                                 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo,
+                                                                 IMG_UINT64 *pui64Stamp);
+
+IMG_IMPORT
+PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmabufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
+#endif /* SUPPORT_DRM_GEM */
+
 #if defined(SUPPORT_ION)
 IMG_IMPORT
 PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
index 2ae1a3bc033dbc603611cd7f940728a072c8cfde..4e164757faf1f52598ab42be0e53cef171232efa 100644 (file)
@@ -85,9 +85,10 @@ typedef enum _PVRSRV_MEMTYPE_
        PVRSRV_MEMTYPE_DEVICECLASS      = 2,
        PVRSRV_MEMTYPE_WRAPPED          = 3,
        PVRSRV_MEMTYPE_MAPPED           = 4,
-       PVRSRV_MEMTYPE_ION                      = 5,
-       PVRSRV_MEMTYPE_ALLOC            = 6,
-       PVRSRV_MEMTYPE_FREE             = 7
+       PVRSRV_MEMTYPE_ION              = 5,
+       PVRSRV_MEMTYPE_DMABUF           = 6,
+       PVRSRV_MEMTYPE_ALLOC            = 7,
+       PVRSRV_MEMTYPE_FREE             = 8
 } PVRSRV_MEMTYPE;
 
 #if defined (MEM_TRACK_INFO_DEBUG)
@@ -151,7 +152,7 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_
        /* ptr to associated kernel sync info - NULL if no sync */
        struct _PVRSRV_KERNEL_SYNC_INFO_        *psKernelSyncInfo;
 
-       IMG_HANDLE                              hIonSyncInfo;
+       IMG_HANDLE                              hExternalSyncInfo;
 
        PVRSRV_MEMTYPE                          memType;
 
index 2321a69b66e1ebe3bb5376c182c128bebf894fb2..29ef9f15a36aa23dc5d611c5c551b8c772ed9d37 100644 (file)
@@ -1392,6 +1392,154 @@ PVRSRVUnwrapExtMemoryBW(IMG_UINT32 ui32BridgeID,
        return 0;
 }
 
+#if defined(SUPPORT_DRM_GEM)
+static IMG_INT
+PVRSRVMapDmabufBW(IMG_UINT32 ui32BridgeID,
+                                          PVRSRV_BRIDGE_IN_MAP_DMABUF *psMapDmabufIN,
+                                          PVRSRV_BRIDGE_OUT_MAP_DMABUF *psMapDmabufOUT,
+                                          PVRSRV_PER_PROCESS_DATA *psPerProc)
+{
+       PVRSRV_KERNEL_MEM_INFO  *psKernelMemInfo;
+       IMG_UINT64 ui64Stamp;
+
+       psMapDmabufOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
+                                                                                        &psMapDmabufIN->hDevCookie,
+                                                                                        psMapDmabufIN->hDevCookie,
+                                                                                        PVRSRV_HANDLE_TYPE_DEV_NODE);
+       if (psMapDmabufOUT->eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup device node handle", __FUNCTION__));
+               return 0;
+       }
+
+       psMapDmabufOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
+                                                                                        &psMapDmabufIN->hDevMemHeap,
+                                                                                        psMapDmabufIN->hDevMemHeap,
+                                                                                        PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP);
+       if (psMapDmabufOUT->eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Failed to lookup memory context handle", __FUNCTION__));
+               return 0;
+       }
+
+       psMapDmabufOUT->eError = PVRSRVMapDmabufKM(psPerProc,
+                                                                                          psMapDmabufIN->hDevCookie,
+                                                                                          psMapDmabufIN->hDevMemHeap,
+                                                                                          psMapDmabufIN->ui32NumFDs,
+                                                                                          psMapDmabufIN->ai32BufferFDs,
+                                                                                          psMapDmabufIN->ui32Attribs,
+                                                                                          psMapDmabufIN->ui32ChunkCount,
+                                                                                          psMapDmabufIN->auiOffset,
+                                                                                          psMapDmabufIN->auiSize,
+                                                                                          &psMapDmabufOUT->uiDmabufBufferSize,
+                                                                                          &psKernelMemInfo,
+                                                                                          &ui64Stamp);
+       if (psMapDmabufOUT->eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Failed to map ion handle", __FUNCTION__));
+               return 0;
+       }
+
+       OSMemSet(&psMapDmabufOUT->sClientMemInfo,
+                        0,
+                        sizeof(psMapDmabufOUT->sClientMemInfo));
+
+       psMapDmabufOUT->sClientMemInfo.pvLinAddrKM =
+                       psKernelMemInfo->pvLinAddrKM;
+
+       psMapDmabufOUT->sClientMemInfo.pvLinAddr = 0;
+       psMapDmabufOUT->sClientMemInfo.sDevVAddr = psKernelMemInfo->sDevVAddr;
+       psMapDmabufOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags;
+       psMapDmabufOUT->sClientMemInfo.uAllocSize = psKernelMemInfo->uAllocSize;
+
+       /* No mapping info, we map through ion */
+       psMapDmabufOUT->sClientMemInfo.hMappingInfo = IMG_NULL;
+
+#if defined(SUPPORT_MEMINFO_IDS)
+       psMapDmabufOUT->sClientMemInfo.ui64Stamp = ui64Stamp;
+#endif
+
+       PVRSRVAllocHandleNR(psPerProc->psHandleBase,
+                                               &psMapDmabufOUT->sClientMemInfo.hKernelMemInfo,
+                                               psKernelMemInfo,
+                                               PVRSRV_HANDLE_TYPE_MEM_INFO,
+                                               PVRSRV_HANDLE_ALLOC_FLAG_NONE);
+
+       if(psMapDmabufIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ)
+       {
+               /* signal no syncinfo */
+               OSMemSet(&psMapDmabufOUT->sClientSyncInfo,
+                                0,
+                                sizeof (PVRSRV_CLIENT_SYNC_INFO));
+               psMapDmabufOUT->sClientMemInfo.psClientSyncInfo = IMG_NULL;
+       }
+       else
+       {
+               /* and setup the sync info */
+#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS)
+               psMapDmabufOUT->sClientSyncInfo.psSyncData =
+                       psKernelMemInfo->psKernelSyncInfo->psSyncData;
+               psMapDmabufOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr =
+                       psKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr;
+               psMapDmabufOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr =
+                       psKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr;
+               psMapDmabufOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr =
+                       psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr;
+
+               psMapDmabufOUT->sClientSyncInfo.hMappingInfo =
+                       psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle;
+#endif
+
+               PVRSRVAllocSubHandleNR(psPerProc->psHandleBase,
+                                                          &psMapDmabufOUT->sClientSyncInfo.hKernelSyncInfo,
+                                                          psKernelMemInfo->psKernelSyncInfo,
+                                                          PVRSRV_HANDLE_TYPE_SYNC_INFO,
+                                                          PVRSRV_HANDLE_ALLOC_FLAG_NONE,
+                                                          psMapDmabufOUT->sClientMemInfo.hKernelMemInfo);
+
+               psMapDmabufOUT->sClientMemInfo.psClientSyncInfo =
+                       &psMapDmabufOUT->sClientSyncInfo;
+       }
+       return 0;
+}
+
+static IMG_INT
+PVRSRVUnmapDmabufBW(IMG_UINT32 ui32BridgeID,
+                                          PVRSRV_BRIDGE_IN_UNMAP_DMABUF *psUnmapDmabufIN,
+                                          PVRSRV_BRIDGE_RETURN *psUnmapDmabufOUT,
+                                          PVRSRV_PER_PROCESS_DATA *psPerProc)
+{
+       IMG_VOID *pvKernelMemInfo;
+
+       PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_UNMAP_DMABUF);
+
+       psUnmapDmabufOUT->eError =
+        PVRSRVLookupHandle(psPerProc->psHandleBase,
+                           &pvKernelMemInfo,
+                                                  psUnmapDmabufIN->psKernelMemInfo,
+                                                  PVRSRV_HANDLE_TYPE_MEM_INFO);
+
+       if(psUnmapDmabufOUT->eError != PVRSRV_OK)
+       {
+               return 0;
+       }
+
+       psUnmapDmabufOUT->eError = PVRSRVUnmapDmabufKM(pvKernelMemInfo);
+
+       if(psUnmapDmabufOUT->eError != PVRSRV_OK)
+       {
+               return 0;
+       }
+
+       psUnmapDmabufOUT->eError =
+               PVRSRVReleaseHandle(psPerProc->psHandleBase,
+                                                       psUnmapDmabufIN->psKernelMemInfo,
+                                                       PVRSRV_HANDLE_TYPE_MEM_INFO);
+
+       return 0;
+}
+#endif /* SUPPORT_ION */
+
 #if defined(SUPPORT_ION)
 static IMG_INT
 PVRSRVMapIonHandleBW(IMG_UINT32 ui32BridgeID,
@@ -2124,6 +2272,15 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID,
                return 0;
        }
 
+       if((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT) != 0)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "Get DRM FD BW"));
+       }
+       if((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT) != 0)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "Set DRM FD BW"));
+       }
+
        if (((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_MEMSTATS_PRESENT) != 0) ||
            ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_DDKVERSION_PRESENT) != 0) ||
            ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) != 0))
@@ -4489,6 +4646,10 @@ CommonBridgeInit(IMG_VOID)
     SetDispatchTableEntry(PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS, PVRSRVChangeDeviceMemoryAttributesBW);
     SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY_2, PVRSRVMapDeviceMemoryBW);
     SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2, PVRSRVExportDeviceMemBW);
+#if defined(SUPPORT_DRM_GEM)
+       SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DMABUF, PVRSRVMapDmabufBW);
+       SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DMABUF, PVRSRVUnmapDmabufBW);
+#endif
 #if defined(SUPPORT_ION)
        SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_ION_HANDLE, PVRSRVMapIonHandleBW);
        SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_ION_HANDLE, PVRSRVUnmapIonHandleBW);
index ac68bcf80bb0dc45f7d4d494d14e238695615306..d28136fe392dcfb36df900b76f8efb0bdcd4dbe6 100644 (file)
@@ -49,14 +49,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "osfunc.h"
 #include "devicemem.h"
 
+#if defined(SUPPORT_DRM_GEM)
+#include "dmabuf.h"
+#endif
+
 #if defined(SUPPORT_ION)
 #include "ion.h"
 #include "env_perproc.h"
-#include "ion_sync.h"
+#endif
 
-/* Start size of the g_IonSyncHash hash table */
-#define ION_SYNC_HASH_SIZE 20
-HASH_TABLE *g_psIonSyncHash = IMG_NULL;
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+#include "external_sync.h"
+
+/* Start size of the g_ExternalSyncHash hash table */
+#define EXTERNAL_SYNC_HASH_SIZE 20
+HASH_TABLE *g_psExternalSyncHash = IMG_NULL;
 #endif
 
 #include "lists.h"
@@ -956,6 +963,15 @@ static IMG_VOID freeExternal(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
                        OSReleasePhysPageAddr(hOSWrapMem);
                }
        }
+#if defined(SUPPORT_DRM_GEM)
+       else if (psMemInfo->memType == PVRSRV_MEMTYPE_DMABUF)
+       {
+               if (hOSWrapMem)
+               {
+                       DmabufUnimportBufferAndReleasePhysAddr(hOSWrapMem);
+               }
+       }
+#endif
 #if defined(SUPPORT_ION)
        else if (psMemInfo->memType == PVRSRV_MEMTYPE_ION)
        {
@@ -1051,17 +1067,18 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
                        /* Fall through: Free only what we should for each memory type */
                        case PVRSRV_MEMTYPE_WRAPPED:
                        case PVRSRV_MEMTYPE_ION:
+                       case PVRSRV_MEMTYPE_DMABUF:
                                freeExternal(psMemInfo);
                        case PVRSRV_MEMTYPE_DEVICE:
                        case PVRSRV_MEMTYPE_DEVICECLASS:
-#if defined(SUPPORT_ION)
-                               if (psMemInfo->hIonSyncInfo)
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+                               if (psMemInfo->hExternalSyncInfo)
                                {
                                        /*
                                                For syncs attached to Ion imported buffers we handle
                                                things a little differently
                                        */
-                                       PVRSRVIonBufferSyncInfoDecRef(psMemInfo->hIonSyncInfo, psMemInfo);
+                                       PVRSRVExternalBufferSyncInfoDecRef(psMemInfo->hExternalSyncInfo, psMemInfo);
                                }
                                else
 #endif
@@ -1073,7 +1090,7 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
                                }
                                break;
                        default:
-                               PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: Unknown memType"));
+                               PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: Unknown memType: %d", psMemInfo->memType));
                                eError = PVRSRV_ERROR_INVALID_MEMINFO;
                }
        }
@@ -1376,35 +1393,24 @@ free_mainalloc:
        return eError;
 }
 
-#if defined(SUPPORT_ION)
-static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID  pvParam,
-                                                                        IMG_UINT32 ui32Param,
-                                                                        IMG_BOOL   bDummy)
-{
-       PVRSRV_KERNEL_MEM_INFO  *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam;
-       
-       PVR_UNREFERENCED_PARAMETER(bDummy);
-
-       return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR);
-}
-
-PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique,
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+PVRSRV_ERROR PVRSRVExternalBufferSyncAcquire(IMG_HANDLE hUnique,
                                                                                IMG_HANDLE hDevCookie,
                                                                                IMG_HANDLE hDevMemContext,
-                                                                               PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo)
+                                                                               PVRSRV_EXTERNAL_SYNC_INFO **ppsExternalSyncInfo)
 {
-       PVRSRV_ION_SYNC_INFO *psIonSyncInfo;
+       PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo;
        PVRSRV_ERROR eError;
        IMG_BOOL bRet;
 
        /* Check the hash to see if we already have a sync for this buffer */
-       psIonSyncInfo = (PVRSRV_ION_SYNC_INFO *) HASH_Retrieve(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique);
-       if (psIonSyncInfo == 0)
+       psExternalSyncInfo = (PVRSRV_EXTERNAL_SYNC_INFO *) HASH_Retrieve(g_psExternalSyncHash, (IMG_UINTPTR_T) hUnique);
+       if (psExternalSyncInfo == 0)
        {
                /* This buffer is new to us, create the syncinfo for it */
                eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT,
-                                                       sizeof(PVRSRV_ION_SYNC_INFO),
-                                                       (IMG_VOID **)&psIonSyncInfo, IMG_NULL,
+                                                       sizeof(PVRSRV_EXTERNAL_SYNC_INFO),
+                                                       (IMG_VOID **)&psExternalSyncInfo, IMG_NULL,
                                                        "Ion Synchronization Info");
                if (eError != PVRSRV_OK)
                {
@@ -1413,64 +1419,362 @@ PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique,
 
                eError = PVRSRVAllocSyncInfoKM(hDevCookie,
                                                                           hDevMemContext,
-                                                                          &psIonSyncInfo->psSyncInfo);
+                                                                          &psExternalSyncInfo->psSyncInfo);
                if (eError != PVRSRV_OK)
                {
                        OSFreeMem(PVRSRV_PAGEABLE_SELECT,
-                                         sizeof(PVRSRV_ION_SYNC_INFO),
-                                         psIonSyncInfo,
+                                         sizeof(PVRSRV_EXTERNAL_SYNC_INFO),
+                                         psExternalSyncInfo,
                                          IMG_NULL);
 
                        return eError;
                }
 #if defined(SUPPORT_MEMINFO_IDS)
-               psIonSyncInfo->ui64Stamp = ++g_ui64MemInfoID;
+               psExternalSyncInfo->ui64Stamp = ++g_ui64MemInfoID;
 #else
-               psIonSyncInfo->ui64Stamp = 0;
+               psExternalSyncInfo->ui64Stamp = 0;
 #endif
-               bRet = HASH_Insert(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique, (IMG_UINTPTR_T) psIonSyncInfo);
+               bRet = HASH_Insert(g_psExternalSyncHash, (IMG_UINTPTR_T) hUnique, (IMG_UINTPTR_T) psExternalSyncInfo);
                if (!bRet)
                {
                        eError = PVRSRV_ERROR_OUT_OF_MEMORY;
 
-                       PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL);
+                       PVRSRVKernelSyncInfoDecRef(psExternalSyncInfo->psSyncInfo, IMG_NULL);
                        OSFreeMem(PVRSRV_PAGEABLE_SELECT,
-                                         sizeof(PVRSRV_ION_SYNC_INFO),
-                                         psIonSyncInfo,
+                                         sizeof(PVRSRV_EXTERNAL_SYNC_INFO),
+                                         psExternalSyncInfo,
                                          IMG_NULL);
 
                        return eError;
                }
 
-               psIonSyncInfo->ui32RefCount = 0;
-               psIonSyncInfo->hUnique = hUnique;
+               psExternalSyncInfo->ui32RefCount = 0;
+               psExternalSyncInfo->hUnique = hUnique;
        }
 
-       psIonSyncInfo->ui32RefCount++;
-       *ppsIonSyncInfo = psIonSyncInfo;
+       psExternalSyncInfo->ui32RefCount++;
+       *ppsExternalSyncInfo = psExternalSyncInfo;
        return PVRSRV_OK;
 }
 
-IMG_VOID PVRSRVIonBufferSyncRelease(PVRSRV_ION_SYNC_INFO *psIonSyncInfo)
+IMG_VOID PVRSRVExternalBufferSyncRelease(PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo)
 {
-       psIonSyncInfo->ui32RefCount--;
+       psExternalSyncInfo->ui32RefCount--;
 
-       if (psIonSyncInfo->ui32RefCount == 0)
+       if (psExternalSyncInfo->ui32RefCount == 0)
        {
-               PVRSRV_ION_SYNC_INFO *psLookup;
+               PVRSRV_EXTERNAL_SYNC_INFO *psLookup;
                /*
                        If we're holding the last reference to the syncinfo
                        then free it
                */
-               psLookup = (PVRSRV_ION_SYNC_INFO *) HASH_Remove(g_psIonSyncHash, (IMG_UINTPTR_T) psIonSyncInfo->hUnique);
-               PVR_ASSERT(psLookup == psIonSyncInfo);
-               PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL);
+               psLookup = (PVRSRV_EXTERNAL_SYNC_INFO *) HASH_Remove(g_psExternalSyncHash, (IMG_UINTPTR_T) psExternalSyncInfo->hUnique);
+               PVR_ASSERT(psLookup == psExternalSyncInfo);
+               PVRSRVKernelSyncInfoDecRef(psExternalSyncInfo->psSyncInfo, IMG_NULL);
                OSFreeMem(PVRSRV_PAGEABLE_SELECT,
-                                 sizeof(PVRSRV_ION_SYNC_INFO),
-                                 psIonSyncInfo,
+                                 sizeof(PVRSRV_EXTERNAL_SYNC_INFO),
+                                 psExternalSyncInfo,
                                  IMG_NULL);
        }
 }
+#endif //defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+
+#if defined(SUPPORT_DRM_GEM)
+static PVRSRV_ERROR DmabufUnmapCallback(IMG_PVOID  pvParam,
+                                                                        IMG_UINT32 ui32Param,
+                                                                        IMG_BOOL   bDummy)
+{
+       PVRSRV_KERNEL_MEM_INFO  *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam;
+       
+       PVR_UNREFERENCED_PARAMETER(bDummy);
+
+       return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR);
+}
+
+/*!
+******************************************************************************
+
+ @Function     PVRSRVMapDmabufKM
+
+ @Description
+
+ Map a DMABUF buffer into the specified device memory context
+
+ @Input           psPerProc : PerProcess data
+ @Input    hDevCookie : Device node cookie
+ @Input    hDevMemHeap : Heap dmabuf handles are mapped into
+ @Input    ui32NumBuffers : Number of dmabuf handles to map. (If one handle is being
+                            mapped, this should be 1, not 0.)
+ @Input    phDmabuf : Array of ui32NumBuffers dmabuf handles (fds)
+ @Input    ui32Flags : Mapping flags
+ @Input    ui32ChunkCount : If ui32NumBuffers is 1, this is the number of
+                            "chunks" specified to be mapped into device-virtual
+                            address space. If ui32NumBuffers > 1, it is ignored.
+ @Input    pauiOffset : Array of offsets in device-virtual address space to map
+                        "chunks" of physical from the dmabuf allocation.
+ @Input    pauiSize : Array of sizes in bytes of device-virtual address space to
+                      map "chunks" of physical from the dmabuf allocation.
+ @Input    puiDmabufBufferSize : Size in bytes of resulting device-virtual mapping.
+ @Output   ppsKernelMemInfo: Output kernel meminfo if successful
+
+ @Return   PVRSRV_ERROR  :
+
+******************************************************************************/
+IMG_EXPORT
+PVRSRV_ERROR PVRSRVMapDmabufKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
+                                                                 IMG_HANDLE hDevCookie,
+                                                                 IMG_HANDLE hDevMemHeap,
+                                                                 IMG_UINT32 ui32NumFDs,
+                                                                 IMG_INT32  *pi32BufferFDs,
+                                                                 IMG_UINT32 ui32Flags,
+                                                                 IMG_UINT32 ui32ChunkCount,
+                                                                 IMG_SIZE_T *pauiOffset,
+                                                                 IMG_SIZE_T *pauiSize,
+                                                                 IMG_SIZE_T *puiDmabufBufferSize,
+                                                                 PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo,
+                                                                 IMG_UINT64 *pui64Stamp)
+{
+       PVRSRV_DEVICE_NODE *psDeviceNode; 
+       PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo;
+       IMG_SYS_PHYADDR *pasSysPhysAddr;
+       IMG_SYS_PHYADDR *pasAdjustedSysPhysAddr;
+       PVRSRV_MEMBLK *psMemBlock;
+       PVRSRV_ERROR eError;
+       IMG_HANDLE hPriv;
+       IMG_HANDLE hUnique;
+       BM_HANDLE hBuffer;
+       IMG_SIZE_T uiMapSize = 0;
+       IMG_SIZE_T uiAdjustOffset = 0;
+       IMG_UINT32 ui32PageCount;
+       IMG_UINT32 i;
+       IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ)?IMG_FALSE:IMG_TRUE;
+
+       if ((hDevCookie == IMG_NULL) || (ui32ChunkCount == 0)
+                || (hDevMemHeap == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL))
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__));
+               return PVRSRV_ERROR_INVALID_PARAMS;
+       }
+
+       for (i=0;i<ui32ChunkCount;i++)
+       {
+               if ((pauiOffset[i] & HOST_PAGEMASK) != 0)
+               {
+                       PVR_DPF((PVR_DBG_ERROR,"%s: Chunk offset is not page aligned", __FUNCTION__));
+                       return PVRSRV_ERROR_INVALID_PARAMS;
+               }
+
+               if ((pauiSize[i] & HOST_PAGEMASK) != 0)
+               {
+                       PVR_DPF((PVR_DBG_ERROR,"%s: Chunk size is not page aligned", __FUNCTION__));
+                       return PVRSRV_ERROR_INVALID_PARAMS;
+               }
+               uiMapSize += pauiSize[i];
+       }
+
+       psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie;
+
+       if(OSAllocMem(PVRSRV_PAGEABLE_SELECT,
+                                       sizeof(PVRSRV_KERNEL_MEM_INFO),
+                                       (IMG_VOID **)&psNewKernelMemInfo, IMG_NULL,
+                                       "Kernel Memory Info") != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for block", __FUNCTION__));
+               return PVRSRV_ERROR_OUT_OF_MEMORY;
+       }
+       OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO));
+
+       /* Import the DMABUF buffer into our dmabuf_client and DMA map it */
+       eError = DmabufImportBufferAndAcquirePhysAddr(ui32NumFDs,
+                                                                                          pi32BufferFDs,
+                                                                                          &ui32PageCount,
+                                                                                          &pasSysPhysAddr,
+                                                                                          &psNewKernelMemInfo->pvLinAddrKM,
+                                                                                          &hPriv,
+                                                                                          &hUnique);
+       if (eError != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get dmabuf buffer/buffer phys addr", __FUNCTION__));
+               goto exitFailedImport;
+       }
+
+       /*
+               Make sure the number of pages detected by the dmabuf import are at least
+               the size of the total chunked region
+       */
+       if(ui32PageCount * PAGE_SIZE < uiMapSize)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: dmabuf allocator returned fewer page addresses "
+                                                               "than specified chunk size(s)", __FUNCTION__));
+               eError = PVRSRV_ERROR_INVALID_PARAMS;
+               goto exitFailedAdjustedAlloc; 
+       }
+
+       /*
+               An Dmabuf buffer might have a number of "chunks" in it which need to be
+               mapped virtually continuous so we need to create a new array of
+               addresses based on this chunk data for the actual wrap
+       */
+       if(OSAllocMem(PVRSRV_PAGEABLE_SELECT,
+                                       sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()),
+                                       (IMG_VOID **)&pasAdjustedSysPhysAddr, IMG_NULL,
+                                       "Dmabuf adjusted system address array") != PVRSRV_OK)
+       {
+               PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for adjusted array", __FUNCTION__));
+               goto exitFailedAdjustedAlloc;
+       }
+       OSMemSet(pasAdjustedSysPhysAddr, 0, sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()));
+
+       for (i=0;i<ui32ChunkCount;i++)
+       {
+               OSMemCopy(&pasAdjustedSysPhysAddr[uiAdjustOffset],
+                                 &pasSysPhysAddr[pauiOffset[i]/HOST_PAGESIZE()],
+                                 (pauiSize[i]/HOST_PAGESIZE()) * sizeof(IMG_SYS_PHYADDR));
+
+               uiAdjustOffset += pauiSize[i]/HOST_PAGESIZE();
+       }
+
+       /* Wrap the returned addresses into our memory context */
+       if (!BM_Wrap(hDevMemHeap,
+                                uiMapSize,
+                                0,
+                                IMG_FALSE,
+                                pasAdjustedSysPhysAddr,
+                                IMG_NULL,
+                                &ui32Flags,    /* This function clobbers our bits in ui32Flags */
+                                &hBuffer))
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Failed to wrap dmabuf buffer", __FUNCTION__));
+               eError = PVRSRV_ERROR_OUT_OF_MEMORY;
+               goto exitFailedWrap;
+       }
+
+       /* Fill in "Implementation dependant" section of mem info */
+       psMemBlock = &psNewKernelMemInfo->sMemBlk;
+       psMemBlock->sDevVirtAddr = BM_HandleToDevVaddr(hBuffer);
+       psMemBlock->hOSMemHandle = BM_HandleToOSMemHandle(hBuffer);
+       psMemBlock->hBuffer = (IMG_HANDLE) hBuffer;
+       psMemBlock->hOSWrapMem = hPriv;                 /* Saves creating a new element as we know hOSWrapMem will not be used */
+       psMemBlock->psIntSysPAddr = pasAdjustedSysPhysAddr;
+
+       psNewKernelMemInfo->ui32Flags = ui32Flags;
+       psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr;
+       psNewKernelMemInfo->uAllocSize = uiMapSize;
+       psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_DMABUF;
+       PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo);
+
+       /* Clear the Backup buffer pointer as we do not have one at this point. We only allocate this as we are going up/down */
+       psNewKernelMemInfo->pvSysBackupBuffer = IMG_NULL;
+
+       if (!bAllocSync)
+       {
+               psNewKernelMemInfo->psKernelSyncInfo = IMG_NULL;
+       }
+       else
+       {
+               PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo;
+               BM_HEAP *psBMHeap;
+               IMG_HANDLE hDevMemContext;
+
+               psBMHeap = (BM_HEAP*)hDevMemHeap;
+               hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext;
+
+               eError = PVRSRVExternalBufferSyncInfoIncRef(hUnique,
+                                                                                          hDevCookie,
+                                                                                          hDevMemContext,
+                                                                                          &psExternalSyncInfo,
+                                                                                          psNewKernelMemInfo);
+               if(eError != PVRSRV_OK)
+               {
+                       goto exitFailedSync;
+               }
+               psNewKernelMemInfo->hExternalSyncInfo = psExternalSyncInfo;
+               psNewKernelMemInfo->psKernelSyncInfo = ExternalBufferSyncGetKernelSyncInfo(psExternalSyncInfo);
+               *pui64Stamp = ExternalBufferSyncGetStamp(psExternalSyncInfo);
+       }
+
+       /* register with the resman */
+       psNewKernelMemInfo->sMemBlk.hResItem = ResManRegisterRes(psPerProc->hResManContext,
+                                                                                                                        RESMAN_TYPE_DEVICEMEM_DMABUF,
+                                                                                                                        psNewKernelMemInfo,
+                                                                                                                        0,
+                                                                                                                        &DmabufUnmapCallback);
+       if (psNewKernelMemInfo->sMemBlk.hResItem == IMG_NULL)
+       {
+               eError = PVRSRV_ERROR_OUT_OF_MEMORY;
+               goto exitFailedResman;
+       }
+
+       psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_DMABUF;
+
+       /*
+               As the user doesn't tell us the size, just the "chunk" information
+               return actual size of the Dmabuf buffer so we can mmap it.
+       */
+       *puiDmabufBufferSize = ui32PageCount * HOST_PAGESIZE();
+       *ppsKernelMemInfo = psNewKernelMemInfo;
+       return PVRSRV_OK;
+
+exitFailedResman:
+       if (psNewKernelMemInfo->psKernelSyncInfo)
+       {
+               PVRSRVExternalBufferSyncInfoDecRef(psNewKernelMemInfo->hExternalSyncInfo, psNewKernelMemInfo);
+       }
+exitFailedSync:
+       BM_Free(hBuffer, ui32Flags);
+exitFailedWrap:
+       OSFreeMem(PVRSRV_PAGEABLE_SELECT,
+                         sizeof(IMG_SYS_PHYADDR) * uiAdjustOffset,
+                         pasAdjustedSysPhysAddr,
+                         IMG_NULL);
+exitFailedAdjustedAlloc:
+       DmabufUnimportBufferAndReleasePhysAddr(hPriv);
+exitFailedImport:
+       OSFreeMem(PVRSRV_PAGEABLE_SELECT,
+                         sizeof(PVRSRV_KERNEL_MEM_INFO),
+                         psNewKernelMemInfo,
+                         IMG_NULL);
+
+       return eError;
+}
+
+/*!
+******************************************************************************
+
+ @Function     PVRSRVUnmapDmabufKM
+
+ @Description
+
+ Frees a dmabuf buffer mapped with PVRSRVMapDmabufKM, including the mem_info structure
+
+ @Input           psMemInfo :
+
+ @Return   PVRSRV_ERROR  :
+
+******************************************************************************/
+IMG_EXPORT
+PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDmabufKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo)
+{
+       if (!psMemInfo)
+       {
+               return PVRSRV_ERROR_INVALID_PARAMS;
+       }
+
+       return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL);
+}
+#endif /* SUPPORT_DRM_GEM */
+
+#if defined(SUPPORT_ION)
+static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID  pvParam,
+                                                                        IMG_UINT32 ui32Param,
+                                                                        IMG_BOOL   bDummy)
+{
+       PVRSRV_KERNEL_MEM_INFO  *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam;
+       
+       PVR_UNREFERENCED_PARAMETER(bDummy);
+
+       return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR);
+}
 
 /*!
 ******************************************************************************
@@ -1655,25 +1959,25 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
        }
        else
        {
-               PVRSRV_ION_SYNC_INFO *psIonSyncInfo;
+               PVRSRV_EXTERNAL_SYNC_INFO *psExternalSyncInfo;
                BM_HEAP *psBMHeap;
                IMG_HANDLE hDevMemContext;
 
                psBMHeap = (BM_HEAP*)hDevMemHeap;
                hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext;
 
-               eError = PVRSRVIonBufferSyncInfoIncRef(hUnique,
+               eError = PVRSRVExternalBufferSyncInfoIncRef(hUnique,
                                                                                           hDevCookie,
                                                                                           hDevMemContext,
-                                                                                          &psIonSyncInfo,
+                                                                                          &psExternalSyncInfo,
                                                                                           psNewKernelMemInfo);
                if(eError != PVRSRV_OK)
                {
                        goto exitFailedSync;
                }
-               psNewKernelMemInfo->hIonSyncInfo = psIonSyncInfo;
-               psNewKernelMemInfo->psKernelSyncInfo = IonBufferSyncGetKernelSyncInfo(psIonSyncInfo);
-               *pui64Stamp = IonBufferSyncGetStamp(psIonSyncInfo);
+               psNewKernelMemInfo->hExternalSyncInfo = psExternalSyncInfo;
+               psNewKernelMemInfo->psKernelSyncInfo = ExternalBufferSyncGetKernelSyncInfo(psExternalSyncInfo);
+               *pui64Stamp = ExternalBufferSyncGetStamp(psExternalSyncInfo);
        }
 
        /* register with the resman */
@@ -1701,7 +2005,7 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc,
 exitFailedResman:
        if (psNewKernelMemInfo->psKernelSyncInfo)
        {
-               PVRSRVIonBufferSyncInfoDecRef(psNewKernelMemInfo->hIonSyncInfo, psNewKernelMemInfo);
+               PVRSRVExternalBufferSyncInfoDecRef(psNewKernelMemInfo->hExternalSyncInfo, psNewKernelMemInfo);
        }
 exitFailedSync:
        BM_Free(hBuffer, ui32Flags);
@@ -2937,14 +3241,16 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInitDeviceMem(IMG_VOID)
 {
        PVRSRV_ERROR eError = PVRSRV_OK;
 
-#if defined(SUPPORT_ION)
+#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM)
        /*
-               For Ion buffers we need to store which ones we know about so
+               For Ion and GEM buffers we need to store which ones we know about so
                we don't give the same buffer a different sync
        */
-       g_psIonSyncHash = HASH_Create(ION_SYNC_HASH_SIZE);
-       if (g_psIonSyncHash == IMG_NULL)
+       PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitDeviceMem: Creating external hash"));
+       g_psExternalSyncHash = HASH_Create(EXTERNAL_SYNC_HASH_SIZE);
+       if (g_psExternalSyncHash == IMG_NULL)
        {
+       PVR_DPF((PVR_DBG_ERROR,"PVRSRVInitDeviceMem: Creating external hash failed"));
                eError = PVRSRV_ERROR_OUT_OF_MEMORY;
        }
 #endif
@@ -2954,8 +3260,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInitDeviceMem(IMG_VOID)
 
 IMG_VOID IMG_CALLCONV PVRSRVDeInitDeviceMem(IMG_VOID)
 {
-#if defined(SUPPORT_ION)
-       HASH_Delete(g_psIonSyncHash);
+#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM)
+       HASH_Delete(g_psExternalSyncHash);
 #endif
 }
 
index ac8e1e3f81a1c175e443ff98f7df81402a3bda3d..1ebb95e2f07eb41dd0c7382dff7eee999a78c7d8 100644 (file)
@@ -59,6 +59,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "lists.h"
 
 IMG_UINT32     g_ui32InitFlags;
+IMG_UINT32  g_iDrmFd = -1;
 
 /* mark which parts of Services were initialised */
 #define                INIT_DATA_ENABLE_PDUMPINIT      0x1U
@@ -458,7 +459,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData)
        g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT;
 #endif
 
-#if defined(SUPPORT_ION)
+#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM)
        eError = PVRSRVInitDeviceMem();
        if (eError != PVRSRV_OK)
                goto Error;
@@ -502,7 +503,7 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData)
        PERFDEINIT();
 
 
-#if defined(SUPPORT_ION)
+#if defined(SUPPORT_ION) || defined(SUPPORT_DRM_GEM)
        if ((g_ui32InitFlags & INIT_DATA_ENABLE_DEVMEM) > 0)
        {
                PVRSRVDeInitDeviceMem();
@@ -1216,7 +1217,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo)
                                                                                |PVRSRV_MISC_INFO_FREEMEM_PRESENT
                                                                                |PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT
                                                                                |PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT
-                                                                               |PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT))
+                                                                               |PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT
+                                                                               |PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT
+                                                                               |PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT))
        {
                PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: invalid state request flags"));
                return PVRSRV_ERROR_INVALID_PARAMS;
@@ -1477,6 +1480,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo)
                psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT;
        }
 #endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */
+       if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT) != 0UL)
+       {
+               PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: GetDrmFD: %d", g_iDrmFd));
+               psMiscInfo->iDrmFd = g_iDrmFd;
+               psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_GET_DRM_FD_PRESENT;
+       }
+       if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT) != 0UL)
+       {
+               g_iDrmFd = psMiscInfo->iDrmFd;
+               PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: SetDrmFD: %d", g_iDrmFd));
+               psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_SET_DRM_FD_PRESENT;
+       }
 
        return PVRSRV_OK;
 }
index a6dcb197566383428ff1fa97efe6a23c2cbfa41f..28f671a5879040cd3f80d92e89eccb9416d6b1a6 100644 (file)
@@ -83,7 +83,7 @@ static DEFINE_SPINLOCK(gsCCBLock);
 /*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/
 static const IMG_UINT guiDebugMask =
        PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO |
-#if defined(SUPPORT_ION)
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
        PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC |
 #endif
        PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2;
@@ -588,8 +588,8 @@ skip:
        psOffsetStruct->ui32Mapped--;
 }
 
-#if defined(SUPPORT_ION)
-PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
                                                                                        IMG_HANDLE hUnique,
                                                                                        IMG_HANDLE hDevCookie,
                                                                                        IMG_HANDLE hDevMemContext,
@@ -601,7 +601,7 @@ PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLi
        /*
                We have to do the call 1st as we need to Ion syninfo which it returns
        */
-       eError = PVRSRVIonBufferSyncAcquire(hUnique,
+       eError = PVRSRVExternalBufferSyncAcquire(hUnique,
                                                                                hDevCookie,
                                                                                hDevMemContext,
                                                                                ppsIonSyncInfo);
@@ -637,7 +637,7 @@ skip:
        return eError;
 }
 
-void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
+void PVRSRVExternalBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
                                                                        PVRSRV_ION_SYNC_INFO *psIonSyncInfo,
                                                                        PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
 {
@@ -665,7 +665,7 @@ void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
 
        PVRSRV_UNLOCK_CCB();
 skip:
-       PVRSRVIonBufferSyncRelease(psIonSyncInfo);
+       PVRSRVExternalBufferSyncRelease(psIonSyncInfo);
 }
 
 #endif /* defined (SUPPORT_ION) */
index 1bb3ebf449c1c935fe6fc582c5d5ad17737b26d7..302efb2bc8b6615ef5ba506b4a58364c128c24b5 100644 (file)
@@ -359,6 +359,9 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext,
                FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_MAPPING, 0, 0, IMG_TRUE);
                FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_KERNEL_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE);
                FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE);
+#if defined(SUPPORT_DRM_GEM)
+               FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_DMABUF, 0, 0, IMG_TRUE);
+#endif
 #if defined(SUPPORT_ION)
                FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ION, 0, 0, IMG_TRUE);
 #endif
index 10064d69c06c9c35e9482bfe407a71d3618a57be..857206e73365d5f9a4a92a542efa44969d005c62 100644 (file)
@@ -78,6 +78,11 @@ pvrsrvkm-y += \
        services4/srvkm/common/queue.o
 endif
 
+ifeq ($(SUPPORT_DRM_GEM),1)
+pvrsrvkm-y += \
+       services4/srvkm/env/linux/dmabuf.o
+endif
+
 ifeq ($(SUPPORT_ION),1)
 pvrsrvkm-y += \
        services4/srvkm/env/linux/ion.o
index 7ffb30c03fda07fb89f101736ffc109ec47e606d..369c0e19160ed982c6dd292ff3f8a64477c3d9fc 100644 (file)
@@ -4634,7 +4634,7 @@ PVRSRV_ERROR PVROSFuncInit(IMG_VOID)
     }
 #endif
 
-#if defined (SUPPORT_ION)
+#if 0//defined (SUPPORT_ION)
        {
                PVRSRV_ERROR eError;
 
@@ -4654,7 +4654,7 @@ PVRSRV_ERROR PVROSFuncInit(IMG_VOID)
  */
 IMG_VOID PVROSFuncDeInit(IMG_VOID)
 {
-#if defined (SUPPORT_ION)
+#if 0//defined (SUPPORT_ION)
        IonDeinit();
 #endif
 #if defined(PVR_LINUX_TIMERS_USING_WORKQUEUES)
index 9b014dccd09a0d94471d13d1d8c1d63050f8eb6a..5a79f7524e697c04f1e7a70753a0f52f1eac3307 100644 (file)
@@ -47,7 +47,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #if defined (SUPPORT_ION)
 #include <linux/err.h>
 #include "ion.h"
-extern struct ion_device *gpsIonDev;
+//extern struct ion_device *gpsIonDev;
 #endif
 
 extern IMG_UINT32 gui32ReleasePID;
@@ -85,7 +85,7 @@ PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData)
        INIT_LIST_HEAD(&psEnvPerProc->sDRMAuthListHead);
 #endif
 
-#if defined(SUPPORT_ION)
+#if 0//defined(SUPPORT_ION)
        OSSNPrintf(psEnvPerProc->azIonClientName, ION_CLIENT_NAME_SIZE, "pvr_ion_client-%d", OSGetCurrentProcessIDKM());
        psEnvPerProc->psIONClient =
                ion_client_create(gpsIonDev,
@@ -114,7 +114,7 @@ PVRSRV_ERROR OSPerProcessPrivateDataDeInit(IMG_HANDLE hOsPrivateData)
 
        psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)hOsPrivateData;
 
-#if defined(SUPPORT_ION)
+#if 0//defined(SUPPORT_ION)
        if (psEnvPerProc->psIONClient)
        {
                ion_client_destroy(psEnvPerProc->psIONClient);
index df3a9b5ef22660a94c5843dea59190708139e444..aece908d6613f533cc24fb130bca8e641b28c1b3 100644 (file)
@@ -462,18 +462,17 @@ IMG_VOID PVRSRVDebugPrintf        (
                }
                else
                {
+                       const IMG_CHAR *pszShortName = strrchr(pszFileName, '/') + 1;
+                       if(pszShortName)
+                               pszFileName = pszShortName;
                        if (ui32DebugLevel & DBGPRIV_BUFFERED)
                        {
                                /* We don't need the full path here */
-                               const IMG_CHAR *pszShortName = strrchr(pszFileName, '/') + 1;
-                               if(pszShortName)
-                                       pszFileName = pszShortName;
-
                                AddToBufferCCB(pszFileName, ui32Line, pszBuf);
                        }
                        else
                        {
-                               printk(KERN_INFO "%s\n", pszBuf);
+                               printk(KERN_INFO "%s (File: %s, Line: %d)\n", pszBuf, pszFileName, ui32Line);
                        }
                }
 
index a2efd6ceb116d3ba3066d25986ea8c191681d36f..0f015b5fe1febb9717211e9f9236361ea248b253 100644 (file)
@@ -43,9 +43,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define __REFCOUNT_H__
 
 #include "pvr_bridge_km.h"
-#if defined(SUPPORT_ION)
-#include "ion_sync.h"
-#endif /* defined(SUPPORT_ION) */
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+#include "external_sync.h"
+#endif /* defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION) */
 
 #if defined(PVRSRV_REFCOUNT_DEBUG)
 
@@ -114,20 +114,20 @@ void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
 void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
                                                                  PKV_OFFSET_STRUCT psOffsetStruct);
 
-#if defined(SUPPORT_ION)
-#define PVRSRVIonBufferSyncInfoIncRef(x...) \
-       PVRSRVIonBufferSyncInfoIncRef2(__FILE__, __LINE__, x)
-#define PVRSRVIonBufferSyncInfoDecRef(x...) \
-       PVRSRVIonBufferSyncInfoDecRef2(__FILE__, __LINE__, x)
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+#define PVRSRVExternalBufferSyncInfoIncRef(x...) \
+       PVRSRVExternalBufferSyncInfoIncRef2(__FILE__, __LINE__, x)
+#define PVRSRVExternalBufferSyncInfoDecRef(x...) \
+       PVRSRVExternalBufferSyncInfoDecRef2(__FILE__, __LINE__, x)
 
-PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
+PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
                                                                                        IMG_HANDLE hUnique,
                                                                                        IMG_HANDLE hDevCookie,
                                                                                        IMG_HANDLE hDevMemContext,
-                                                                                       PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo,
+                                                                                       PVRSRV_EXTERNAL_SYNC_INFO **ppsIonSyncInfo,
                                                                                        PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
-void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
-                                                                       PVRSRV_ION_SYNC_INFO *psIonSyncInfo,
+void PVRSRVExternalBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
+                                                                       PVRSRV_EXTERNAL_SYNC_INFO *psIonSyncInfo,
                                                                        PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
 #endif /* defined (SUPPORT_ION) */
 
@@ -216,26 +216,26 @@ static INLINE void PVRSRVOffsetStructDecMapped(PKV_OFFSET_STRUCT psOffsetStruct)
        psOffsetStruct->ui32Mapped--;
 }
 
-#if defined(SUPPORT_ION)
-static INLINE PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef(IMG_HANDLE hUnique,
+#if defined(SUPPORT_DRM_GEM) || defined(SUPPORT_ION)
+static INLINE PVRSRV_ERROR PVRSRVExternalBufferSyncInfoIncRef(IMG_HANDLE hUnique,
                                                                                                                 IMG_HANDLE hDevCookie,
                                                                                                                 IMG_HANDLE hDevMemContext,
-                                                                                                                PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo,
+                                                                                                                PVRSRV_EXTERNAL_SYNC_INFO **ppsIonSyncInfo,
                                                                                                                 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
 {
        PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
 
-       return PVRSRVIonBufferSyncAcquire(hUnique,
+       return PVRSRVExternalBufferSyncAcquire(hUnique,
                                                                          hDevCookie,
                                                                          hDevMemContext,
                                                                          ppsIonSyncInfo);
 }
 
-static INLINE void PVRSRVIonBufferSyncInfoDecRef(PVRSRV_ION_SYNC_INFO *psIonSyncInfo,
+static INLINE void PVRSRVExternalBufferSyncInfoDecRef(PVRSRV_EXTERNAL_SYNC_INFO *psIonSyncInfo,
                                                                                   PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
 {
        PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
-       PVRSRVIonBufferSyncRelease(psIonSyncInfo);
+       PVRSRVExternalBufferSyncRelease(psIonSyncInfo);
 }
 #endif /* defined (SUPPORT_ION) */
 
index 92659d9843fceb4d1d8353319cfff106fb64a58e..75e09a9c0e525efe63a1ad59d95a23d744d9ad6d 100644 (file)
@@ -80,6 +80,7 @@ enum {
        RESMAN_TYPE_DEVICEMEM_WRAP,                                             /*!< Device Memory Wrap Resource */
        RESMAN_TYPE_DEVICEMEM_ALLOCATION,                               /*!< Device Memory Allocation Resource */
        RESMAN_TYPE_DEVICEMEM_ION,                                              /*!< Device Memory Ion Resource */
+       RESMAN_TYPE_DEVICEMEM_DMABUF,                                   /*!< Device Memory Dmabuf Resource */
        RESMAN_TYPE_EVENT_OBJECT,                                               /*!< Event Object */
     RESMAN_TYPE_SHARED_MEM_INFO,                    /*!< Shared system memory meminfo */
     RESMAN_TYPE_MODIFY_SYNC_OPS,                                       /*!< Syncobject synchronisation Resource*/