summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunita Nadampalli2013-09-13 06:05:29 -0500
committerSunita Nadampalli2013-09-13 06:05:29 -0500
commite6859266dde6d2c5a85b43fd1ca27ce093b93eb8 (patch)
tree76e5e158b6016e57a26f00421c49fa8b39f301fd /memplugin_qnx.c
parent71a368d4d01d0dd7bd80f1189fe205f4645fd320 (diff)
downloadhardware-ti-libdce-e6859266dde6d2c5a85b43fd1ca27ce093b93eb8.tar.gz
hardware-ti-libdce-e6859266dde6d2c5a85b43fd1ca27ce093b93eb8.tar.xz
hardware-ti-libdce-e6859266dde6d2c5a85b43fd1ca27ce093b93eb8.zip
[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>
Diffstat (limited to 'memplugin_qnx.c')
-rw-r--r--memplugin_qnx.c30
1 files changed, 17 insertions, 13 deletions
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 @@
37/* For TILER 2D Buffers : sz = width */ 37/* For TILER 2D Buffers : sz = width */
38/* : height = nonzero */ 38/* : height = nonzero */
39/* For other memory_types : height = 0 */ 39/* For other memory_types : height = 0 */
40void *memplugin_alloc(int sz, int height, mem_type memory_type) 40void *memplugin_alloc(int sz, int height, MemRegion region, int align, int flags)
41{ 41{
42 MemHeader *h; 42 MemHeader *h;
43 shm_buf *handle; 43 shm_buf *handle;
@@ -46,26 +46,26 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
46 mem_error_status eError = MEM_EOK; 46 mem_error_status eError = MEM_EOK;
47 47
48 _ASSERT(sz != 0, MEM_EINVALID_INPUT); 48 _ASSERT(sz != 0, MEM_EINVALID_INPUT);
49 _ASSERT((memory_type < MEM_MAX) && (memory_type >= TILER_1D_BUFFER), MEM_EINVALID_INPUT); 49 _ASSERT((region < MEM_MAX) && (region >= MEM_TILER_1D), MEM_EINVALID_INPUT);
50 50
51 /* Tiler buffer Allocations : Only Tiler 1D used for Parameter Buffers and RPC Message buffers */ 51 /* Tiler buffer Allocations : Only Tiler 1D used for Parameter Buffers and RPC Message buffers */
52 if( memory_type == TILER_1D_BUFFER || memory_type == TILER8_2D_BUFFER || memory_type == TILER16_2D_BUFFER ) { 52 if( region == MEM_TILER_1D || region == MEM_TILER8_2D || region == MEM_TILER16_2D ) {
53 num_block = 1; 53 num_block = 1;
54 54
55 if( memory_type == TILER_1D_BUFFER ) { 55 if( region == MEM_TILER_1D ) {
56 /* Allocate in tiler paged mode (1d) container */ 56 /* Allocate in tiler paged mode (1d) container */
57 block.pixelFormat = PIXEL_FMT_PAGE; 57 block.pixelFormat = PIXEL_FMT_PAGE;
58 block.dim.len = sz + sizeof(MemHeader); 58 block.dim.len = sz + sizeof(MemHeader);
59#if 0 /* Data Tiler Buffers not to be allocated by DCE */ 59#if 0 /* Data Tiler Buffers not to be allocated by DCE */
60 } else if( memory_type == TILER8_2D_BUFFER ) { 60 } else if( region == MEM_TILER8_2D ) {
61 /* Allocate in tiler 8 bit mode (2d) container */ 61 /* Allocate in tiler 8 bit mode (2d) container */
62 _ASSERT(height != 0, MEM_EINVALID_INPUT); 62 _ASSERT(height != 1, MEM_EINVALID_INPUT);
63 block.pixelFormat = PIXEL_FMT_8BIT; 63 block.pixelFormat = PIXEL_FMT_8BIT;
64 block.dim.area.width = sz; 64 block.dim.area.width = sz;
65 block.dim.area.height = height; 65 block.dim.area.height = height;
66 } else { 66 } else {
67 /* Allocate in tiler 16 bit mode (2d) container */ 67 /* Allocate in tiler 16 bit mode (2d) container */
68 _ASSERT(height != 0, MEM_EINVALID_INPUT); 68 _ASSERT(height != 1, MEM_EINVALID_INPUT);
69 block.pixelFormat = PIXEL_FMT_16BIT; 69 block.pixelFormat = PIXEL_FMT_16BIT;
70 block.dim.area.width = sz; 70 block.dim.area.width = sz;
71 block.dim.area.height = height; 71 block.dim.area.height = height;
@@ -78,6 +78,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
78 _ASSERT(h != NULL, MEM_EOUT_OF_TILER_MEMORY); 78 _ASSERT(h != NULL, MEM_EOUT_OF_TILER_MEMORY);
79 79
80 h->size = sz; 80 h->size = sz;
81 h->region = region;
81 memset(H2P(h), 0, sz); 82 memset(H2P(h), 0, sz);
82 return (H2P(h)); 83 return (H2P(h));
83 } else { 84 } else {
@@ -92,6 +93,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type)
92 _ASSERT_AND_EXECUTE(h != NULL, MEM_EOUT_OF_SHMEMORY, free(handle)); 93 _ASSERT_AND_EXECUTE(h != NULL, MEM_EOUT_OF_SHMEMORY, free(handle));
93 94
94 h->size = sz; 95 h->size = sz;
96 h->region = region;
95 h->ptr = handle; 97 h->ptr = handle;
96 memset(H2P(h), 0, sz); 98 memset(H2P(h), 0, sz);
97 return (H2P(h)); 99 return (H2P(h));
@@ -101,17 +103,19 @@ EXIT:
101} 103}
102 104
103/* memory_type is not added if MemHeader is used for Tiler Buffers */ 105/* memory_type is not added if MemHeader is used for Tiler Buffers */
104void memplugin_free(void *ptr, mem_type memory_type) 106void memplugin_free(void *ptr)
105{ 107{
106 shm_buf *handle; 108 shm_buf *handle;
107 mem_error_status eError = MEM_EOK; 109 mem_error_status eError = MEM_EOK;
110 MemRegion region;
108 111
109 _ASSERT(ptr != NULL, MEM_EINVALID_INPUT); 112 _ASSERT(ptr != NULL, MEM_EINVALID_INPUT);
110 _ASSERT((memory_type < MEM_MAX) && (memory_type >= TILER_1D_BUFFER), MEM_EINVALID_INPUT); 113 region = (P2H(ptr))->region;
114 _ASSERT((region < MEM_MAX) && (region >= MEM_TILER_1D), MEM_EINVALID_INPUT);
111 115
112 if( memory_type == TILER_1D_BUFFER ) { 116 if( region == MEM_TILER_1D ) {
113 MemMgr_Free(P2H(ptr)); 117 MemMgr_Free(P2H(ptr));
114 } else if( memory_type == SHARED_MEMORY_BUFFER ) { 118 } else if( region == MEM_SHARED ) {
115 handle = (P2H(ptr))->ptr; 119 handle = (P2H(ptr))->ptr;
116 SHM_release(handle); 120 SHM_release(handle);
117 free(handle); 121 free(handle);
@@ -121,10 +125,10 @@ void memplugin_free(void *ptr, mem_type memory_type)
121EXIT:; 125EXIT:;
122} 126}
123 127
124inline int memplugin_share(void *ptr) 128inline int32_t memplugin_share(void *ptr)
125{ 129{
126 /* No Userspace Virtual pointers to DMA BUF Handles conversion required*/ 130 /* No Userspace Virtual pointers to DMA BUF Handles conversion required*/
127 /* Do nothing */ 131 /* Do nothing */
128 return ((int)ptr); 132 return ((int32_t)ptr);
129} 133}
130 134