aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunita Nadampalli <sunitan@ti.com>2013-09-13 06:05:29 -0500
committerSunita Nadampalli <sunitan@ti.com>2013-09-13 06:05:29 -0500
commite6859266dde6d2c5a85b43fd1ca27ce093b93eb8 (patch)
tree76e5e158b6016e57a26f00421c49fa8b39f301fd
parent71a368d4d01d0dd7bd80f1189fe205f4645fd320 (diff)
downloaddce-e6859266dde6d2c5a85b43fd1ca27ce093b93eb8.tar.gz
[LIBDCE] update memplugin headers and apis
memheader and memplugin apis are extended to meet the requirements for mem allocations/free/share for all OSes. Change-Id: Ide911d1654ccd0807ace37de9576299cbb860d07 Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rw-r--r--libdce.c16
-rw-r--r--libdce_linux.c4
-rw-r--r--memplugin.h36
-rw-r--r--memplugin_linux.c7
-rw-r--r--memplugin_qnx.c30
5 files changed, 50 insertions, 43 deletions
diff --git a/libdce.c b/libdce.c
index b781972..61d1d9d 100644
--- a/libdce.c
+++ b/libdce.c
@@ -137,12 +137,12 @@ static inline void Fill_MmRpc_fxnCtx_Xlt_Array(MmRpc_Xlt *mmrpc_xlt, int index,
/* These interfaces are implemented to maintain Backward Compatability */
void *dce_alloc(int sz)
{
- return (memplugin_alloc(sz, 0, TILER_1D_BUFFER));
+ return (memplugin_alloc(sz, 1, MEM_TILER_1D, 0, 0));
}
void dce_free(void *ptr)
{
- memplugin_free(ptr, TILER_1D_BUFFER);
+ memplugin_free(ptr);
}
/*=====================================================================================*/
@@ -225,11 +225,11 @@ Engine_Handle Engine_open(String name, Engine_Attrs *attrs, Engine_Error *ec)
printf(">> Engine_open Params::name = %s size = %d\n", name, strlen(name));
/* Allocate Shared memory for the engine_open rpc msg structure*/
/* Tiler Memory preferred in QNX */
- engine_open_msg = memplugin_alloc(sizeof(dce_engine_open), 0, TILER_1D_BUFFER);
+ engine_open_msg = memplugin_alloc(sizeof(dce_engine_open), 1, DEFAULT_REGION, 0, 0);
_ASSERT_AND_EXECUTE(engine_open_msg != NULL, DCE_EOUT_OF_MEMORY, engine_handle = NULL);
if( attrs ) {
- engine_attrs = memplugin_alloc(sizeof(Engine_Attrs), 0, TILER_1D_BUFFER);
+ engine_attrs = memplugin_alloc(sizeof(Engine_Attrs), 1, DEFAULT_REGION, 0, 0);
_ASSERT_AND_EXECUTE(engine_attrs != NULL, DCE_EOUT_OF_MEMORY, engine_handle = NULL);
*engine_attrs = *attrs;
}
@@ -257,9 +257,9 @@ EXIT:
/* Unlock dce_ipc_init() and Engine_open() IPU call */
_ASSERT(sem_post(dce_semaphore) == DCE_EOK, DCE_ESEMAPHORE_FAIL);
- memplugin_free(engine_open_msg, TILER_1D_BUFFER);
+ memplugin_free(engine_open_msg);
if( engine_attrs ) {
- memplugin_free(engine_attrs, TILER_1D_BUFFER);
+ memplugin_free(engine_attrs);
}
return ((Engine_Handle)engine_handle);
}
@@ -325,7 +325,7 @@ static void *create(Engine_Handle engine, String name, void *params, dce_codec_t
_ASSERT(params != NULL, DCE_EINVALID_INPUT);
/* Allocate shared memory for translating codec name to IPU */
- codec_name = memplugin_alloc(MAX_NAME_LENGTH * sizeof(char), 0, TILER_1D_BUFFER);
+ codec_name = memplugin_alloc(MAX_NAME_LENGTH * sizeof(char), 1, DEFAULT_REGION, 0, 0);
_ASSERT_AND_EXECUTE(codec_name != NULL, DCE_EOUT_OF_MEMORY, codec_handle = NULL);
strncpy(codec_name, name, strlen(name));
@@ -345,7 +345,7 @@ static void *create(Engine_Handle engine, String name, void *params, dce_codec_t
_ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CALL_FAIL, codec_handle = NULL);
EXIT:
- memplugin_free(codec_name, TILER_1D_BUFFER);
+ memplugin_free(codec_name);
return ((void *)codec_handle);
}
diff --git a/libdce_linux.c b/libdce_linux.c
index a723e7d..3de9b15 100644
--- a/libdce_linux.c
+++ b/libdce_linux.c
@@ -86,7 +86,7 @@ int dce_buf_lock(int num, size_t *handle)
_ASSERT(num > 0, DCE_EINVALID_INPUT);
- desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER);
+ desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 1, MEM_TILER_1D, 0, 0);
_ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY);
for( i = 0; i < num; i++ ) {
@@ -108,7 +108,7 @@ int dce_buf_unlock(int num, size_t *handle)
_ASSERT(num > 0, DCE_EINVALID_INPUT);
- desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER);
+ desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 1, MEM_TILER_1D, 0, 0);
_ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY);
for( i = 0; i < num; i++ ) {
diff --git a/memplugin.h b/memplugin.h
index bd09a8b..1a4a8aa 100644
--- a/memplugin.h
+++ b/memplugin.h
@@ -42,6 +42,7 @@
#include <xf86drm.h>
#include <omap_drm.h>
#include <omap_drmif.h>
+#define DEFAULT_REGION MEM_TILER_1D
#endif /* BUILDOS_LINUX */
@@ -50,6 +51,7 @@
#include <tilermem.h>
#include <SharedMemoryAllocatorUsr.h>
#include <memmgr.h>
+#define DEFAULT_REGION MEM_TILER_1D
#endif /* BUILDOS_QNX */
@@ -65,21 +67,23 @@
/* or IH264DEC_Params */
typedef struct MemHeader {
uint32_t size;
- void *ptr;
-#if defined(BUILDOS_LINUX)
- int32_t dma_buf_fd;
-#endif
+ void *ptr; /* vptr/handle for mpu access */
+ int32_t dma_buf_fd; /* shared dma buf fd */
+ uint32_t region; /* mem region the buffer allocated from */
+ /* internal meta data for the buffer */
+ uint32_t offset; /* offset for the actual data with in the buffer */
+ int32_t map_fd; /* mmapped fd */
+ void * handle; /*custom handle for the HLOS memallocator*/
} MemHeader;
-
-typedef enum mem_type {
- TILER_1D_BUFFER,
- TILER8_2D_BUFFER,
- TILER16_2D_BUFFER,
- SHARED_MEMORY_BUFFER,
+typedef enum MemoryRegion {
+ MEM_TILER_1D,
+ MEM_TILER8_2D,
+ MEM_TILER16_2D,
+ MEM_CARVEOUT,
+ MEM_SHARED,
MEM_MAX
-} mem_type;
-
+} MemRegion;
/* DCE Error Types */
typedef enum mem_error_status {
@@ -90,11 +94,9 @@ typedef enum mem_error_status {
MEM_EOUT_OF_SYSTEM_MEMORY = -4
} mem_error_status;
-void *memplugin_alloc(int sz, int height, mem_type memory_type);
-
-void memplugin_free(void *ptr, mem_type memory_type);
-
-int memplugin_share(void *ptr);
+void *memplugin_alloc(int sz, int height, MemRegion region, int align, int flags);
+void memplugin_free(void *ptr);
+int32_t memplugin_share(void *ptr);
#endif /* __MEMPLUGIN_H__ */
diff --git a/memplugin_linux.c b/memplugin_linux.c
index db04f4c..ed14f17 100644
--- a/memplugin_linux.c
+++ b/memplugin_linux.c
@@ -42,7 +42,7 @@ extern struct omap_device *OmapDev;
* @memory_type : Currently dce_alloc is used on for parameter buffer
* Returns a virtual address pointer to omap_bo buffer or the param buffer
*/
-void *memplugin_alloc(int sz, int height, mem_type memory_type)
+void *memplugin_alloc(int sz, int height, MemRegion region, int align, int flags)
{
MemHeader *h;
struct omap_bo *bo = omap_bo_new(OmapDev, sz + sizeof(MemHeader), OMAP_BO_CACHED);
@@ -56,6 +56,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
h->size = sz;
h->ptr = (void *)bo;
h->dma_buf_fd = 0;
+ h->region = region;
return (H2P(h));
@@ -65,7 +66,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
* @ptr: pointer to omap_bo buffer, to be freed
* @memory_type: Currently dce_free is called on parameter buffers only
*/
-void memplugin_free(void *ptr, mem_type memory_type)
+void memplugin_free(void *ptr)
{
if( ptr ) {
MemHeader *h = P2H(ptr);
@@ -77,7 +78,7 @@ void memplugin_free(void *ptr, mem_type memory_type)
* @ptr : pointer of omap_bo buffer, to be converted to fd
* Returns a file discriptor for the omap_bo buffer
*/
-int memplugin_share(void *ptr)
+int32_t memplugin_share(void *ptr)
{
if( ptr ) {
MemHeader *h = P2H(ptr);
diff --git a/memplugin_qnx.c b/memplugin_qnx.c
index b6e8af2..c91193e 100644
--- a/memplugin_qnx.c
+++ b/memplugin_qnx.c
@@ -37,7 +37,7 @@
/* For TILER 2D Buffers : sz = width */
/* : height = nonzero */
/* For other memory_types : height = 0 */
-void *memplugin_alloc(int sz, int height, mem_type memory_type)
+void *memplugin_alloc(int sz, int height, MemRegion region, int align, int flags)
{
MemHeader *h;
shm_buf *handle;
@@ -46,26 +46,26 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
mem_error_status eError = MEM_EOK;
_ASSERT(sz != 0, MEM_EINVALID_INPUT);
- _ASSERT((memory_type < MEM_MAX) && (memory_type >= TILER_1D_BUFFER), MEM_EINVALID_INPUT);
+ _ASSERT((region < MEM_MAX) && (region >= MEM_TILER_1D), MEM_EINVALID_INPUT);
/* Tiler buffer Allocations : Only Tiler 1D used for Parameter Buffers and RPC Message buffers */
- if( memory_type == TILER_1D_BUFFER || memory_type == TILER8_2D_BUFFER || memory_type == TILER16_2D_BUFFER ) {
+ if( region == MEM_TILER_1D || region == MEM_TILER8_2D || region == MEM_TILER16_2D ) {
num_block = 1;
- if( memory_type == TILER_1D_BUFFER ) {
+ if( region == MEM_TILER_1D ) {
/* Allocate in tiler paged mode (1d) container */
block.pixelFormat = PIXEL_FMT_PAGE;
block.dim.len = sz + sizeof(MemHeader);
#if 0 /* Data Tiler Buffers not to be allocated by DCE */
- } else if( memory_type == TILER8_2D_BUFFER ) {
+ } else if( region == MEM_TILER8_2D ) {
/* Allocate in tiler 8 bit mode (2d) container */
- _ASSERT(height != 0, MEM_EINVALID_INPUT);
+ _ASSERT(height != 1, MEM_EINVALID_INPUT);
block.pixelFormat = PIXEL_FMT_8BIT;
block.dim.area.width = sz;
block.dim.area.height = height;
} else {
/* Allocate in tiler 16 bit mode (2d) container */
- _ASSERT(height != 0, MEM_EINVALID_INPUT);
+ _ASSERT(height != 1, MEM_EINVALID_INPUT);
block.pixelFormat = PIXEL_FMT_16BIT;
block.dim.area.width = sz;
block.dim.area.height = height;
@@ -78,6 +78,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
_ASSERT(h != NULL, MEM_EOUT_OF_TILER_MEMORY);
h->size = sz;
+ h->region = region;
memset(H2P(h), 0, sz);
return (H2P(h));
} else {
@@ -92,6 +93,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
_ASSERT_AND_EXECUTE(h != NULL, MEM_EOUT_OF_SHMEMORY, free(handle));
h->size = sz;
+ h->region = region;
h->ptr = handle;
memset(H2P(h), 0, sz);
return (H2P(h));
@@ -101,17 +103,19 @@ EXIT:
}
/* memory_type is not added if MemHeader is used for Tiler Buffers */
-void memplugin_free(void *ptr, mem_type memory_type)
+void memplugin_free(void *ptr)
{
shm_buf *handle;
mem_error_status eError = MEM_EOK;
+ MemRegion region;
_ASSERT(ptr != NULL, MEM_EINVALID_INPUT);
- _ASSERT((memory_type < MEM_MAX) && (memory_type >= TILER_1D_BUFFER), MEM_EINVALID_INPUT);
+ region = (P2H(ptr))->region;
+ _ASSERT((region < MEM_MAX) && (region >= MEM_TILER_1D), MEM_EINVALID_INPUT);
- if( memory_type == TILER_1D_BUFFER ) {
+ if( region == MEM_TILER_1D ) {
MemMgr_Free(P2H(ptr));
- } else if( memory_type == SHARED_MEMORY_BUFFER ) {
+ } else if( region == MEM_SHARED ) {
handle = (P2H(ptr))->ptr;
SHM_release(handle);
free(handle);
@@ -121,10 +125,10 @@ void memplugin_free(void *ptr, mem_type memory_type)
EXIT:;
}
-inline int memplugin_share(void *ptr)
+inline int32_t memplugin_share(void *ptr)
{
/* No Userspace Virtual pointers to DMA BUF Handles conversion required*/
/* Do nothing */
- return ((int)ptr);
+ return ((int32_t)ptr);
}