aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaurabh Bipin Chandra2013-09-13 01:26:54 -0500
committerSaurabh Bipin Chandra2013-09-13 07:21:09 -0500
commita896c077f1079c02acc2b4becf564cb209f46538 (patch)
tree1aaff638fde7cd05d21fa12845f9102f4d0da47e /libdce.c
parente0bba2c15bbce4921132e9774137068232619e40 (diff)
downloadrepo-libdce-a896c077f1079c02acc2b4becf564cb209f46538.tar.gz
repo-libdce-a896c077f1079c02acc2b4becf564cb209f46538.tar.xz
repo-libdce-a896c077f1079c02acc2b4becf564cb209f46538.zip
[LIBDCE] Trace and Comments cleanup3.00.03.00
This patch: 1. replaces printf with trace MACROS. 2. Remove unwanted comments. Change-Id: Id137603cbe947ca371550f594fc249d2f1b1410b Signed-off-by: Saurabh Bipin Chandra <a0131926@ti.com>
Diffstat (limited to 'libdce.c')
-rw-r--r--libdce.c84
1 files changed, 29 insertions, 55 deletions
diff --git a/libdce.c b/libdce.c
index 9dd5bce..85df03f 100644
--- a/libdce.c
+++ b/libdce.c
@@ -30,39 +30,6 @@
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/*
34********************************** Notes ******************************************
35*******
36********************************* Memory *****************************************
37*
38*******
39********************************* IPC 3.x *****************************************
40* Two approaches are followed for IPC MmRpc calls.
41* 1. All the parameters which need to be sent and received to/from IPU are coupled in a struct
42* allocated from Shared Memory. Only the adrress of the struct is passed to MmRpc
43* as a pointer argument. This approach is useful as MmRpc in some cases to avoid multiple
44* translations.
45* This approach is followed for :
46* Engine_open(), Engine_close(), create(), control(), delete()
47* For understanding refer to the Mmrpc_test.c in IPC 3.x
48* 2. All the parameters which need to be sent are given as separate arguments to
49* MmRpc. This appraoch is needed when you need to translate an address which is
50* ofsetted from a pointer which in itself needs to be translated.
51* This apporach is followed for : process()
52* For understanding, take the example of inbufs argument in process call(). Inbufs
53* allocated in Shared memory and needs to be translated, has the address of Input
54* buffer (allocated from Tiler). It is not possible to give the Input buffer as an argument
55* to Mmrpc for translation until inbufs is given as a parameter to Mmrpc. Therefore inbuf
56* can't be populated inside another Shared memory struct.
57* 3. This approach is a workaround to use approach [1] by solving the issue posed by [2].
58* This approach is followed for : get_version()
59* Taking the example of inbufs to explain, the Input buffer address will be one of the
60* parameters of the struct (explained in [1]) along with inbufs address. Therefore the
61* Input buffer address will get translated here. At the IPU, this address needs to be
62* copied back to inbufs.
63*********************************************************************************
64*/
65
66#include <stdlib.h> 33#include <stdlib.h>
67#include <string.h> 34#include <string.h>
68#include <stdio.h> 35#include <stdio.h>
@@ -145,41 +112,45 @@ void dce_free(void *ptr)
145 memplugin_free(ptr); 112 memplugin_free(ptr);
146} 113}
147 114
148static inline int dce_sem_init(sem_t **sem) 115static inline int dce_sem_init(sem_t * *sem)
149{ 116{
150 if (*sem) 117 if( *sem ) {
151 return DCE_EOK;; 118 return (DCE_EOK);
119 }
152 120
153#ifdef BUILDOS_ANDROID 121#ifdef BUILDOS_ANDROID
154 *sem = malloc(sizeof(sem_t)); 122 *sem = malloc(sizeof(sem_t));
155 int ret = sem_init(*sem, 0, 1); 123 int ret = sem_init(*sem, 0, 1);
156 return ret; 124 return (ret);
157#else 125#else
158 *sem = sem_open("/dce_semaphore", O_CREAT, S_IRWXU | S_IRWXO | S_IRWXG, 1); 126 *sem = sem_open("/dce_semaphore", O_CREAT, S_IRWXU | S_IRWXO | S_IRWXG, 1);
159 return (*sem) ? DCE_EOK : SEM_FAILED; 127 return ((*sem) ? DCE_EOK : SEM_FAILED);
160#endif 128#endif
161} 129}
162 130
163static inline int dce_sem_wait(sem_t *sem) 131static inline int dce_sem_wait(sem_t *sem)
164{ 132{
165 if (NULL == sem) 133 if( NULL == sem ) {
166 return DCE_EINVALID_INPUT; 134 return (DCE_EINVALID_INPUT);
135 }
167 136
168 return sem_wait(sem); 137 return (sem_wait(sem));
169} 138}
170 139
171static inline int dce_sem_post(sem_t *sem) 140static inline int dce_sem_post(sem_t *sem)
172{ 141{
173 if (NULL == sem) 142 if( NULL == sem ) {
174 return DCE_EINVALID_INPUT; 143 return (DCE_EINVALID_INPUT);
144 }
175 145
176 return sem_post(sem); 146 return (sem_post(sem));
177} 147}
178 148
179static inline void dce_sem_close(sem_t **sem) 149static inline void dce_sem_close(sem_t * *sem)
180{ 150{
181 if (NULL == *sem) 151 if( NULL == *sem ) {
182 return; 152 return;
153 }
183 154
184#ifdef BUILDOS_ANDROID 155#ifdef BUILDOS_ANDROID
185 sem_destroy(*sem); 156 sem_destroy(*sem);
@@ -200,7 +171,7 @@ static int dce_ipc_init(void)
200 MmRpc_Params args; 171 MmRpc_Params args;
201 dce_error_status eError = DCE_EOK; 172 dce_error_status eError = DCE_EOK;
202 173
203 printf(" >> dce_ipc_init\n"); 174 DEBUG(" >> dce_ipc_init\n");
204 175
205 count++; 176 count++;
206 /* Check if already Initialized */ 177 /* Check if already Initialized */
@@ -213,7 +184,7 @@ static int dce_ipc_init(void)
213 184
214 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CREATE_FAIL, count--); 185 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CREATE_FAIL, count--);
215 186
216 printf("open(/dev/" DCE_DEVICE_NAME ") -> 0x%x\n", (int)MmRpcHandle); 187 DEBUG("open(/dev/" DCE_DEVICE_NAME ") -> 0x%x\n", (int)MmRpcHandle);
217 188
218EXIT: 189EXIT:
219 return (eError); 190 return (eError);
@@ -265,7 +236,7 @@ Engine_Handle Engine_open(String name, Engine_Attrs *attrs, Engine_Error *ec)
265 /* Initialize IPC. In case of Error Deinitialize them */ 236 /* Initialize IPC. In case of Error Deinitialize them */
266 _ASSERT_AND_EXECUTE(dce_ipc_init() == DCE_EOK, DCE_EIPC_CREATE_FAIL, dce_ipc_deinit()); 237 _ASSERT_AND_EXECUTE(dce_ipc_init() == DCE_EOK, DCE_EIPC_CREATE_FAIL, dce_ipc_deinit());
267 238
268 printf(">> Engine_open Params::name = %s size = %d\n", name, strlen(name)); 239 INFO(">> Engine_open Params::name = %s size = %d\n", name, strlen(name));
269 /* Allocate Shared memory for the engine_open rpc msg structure*/ 240 /* Allocate Shared memory for the engine_open rpc msg structure*/
270 /* Tiler Memory preferred in QNX */ 241 /* Tiler Memory preferred in QNX */
271 engine_open_msg = memplugin_alloc(sizeof(dce_engine_open), 1, DEFAULT_REGION, 0, 0); 242 engine_open_msg = memplugin_alloc(sizeof(dce_engine_open), 1, DEFAULT_REGION, 0, 0);
@@ -527,8 +498,9 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
527 int fxnRet, count, total_count, numInBufs = 0, numOutBufs = 0; 498 int fxnRet, count, total_count, numInBufs = 0, numOutBufs = 0;
528 dce_error_status eError = DCE_EOK; 499 dce_error_status eError = DCE_EOK;
529 void * *data_buf = NULL; 500 void * *data_buf = NULL;
501
530#ifdef BUILDOS_ANDROID 502#ifdef BUILDOS_ANDROID
531 int32_t inbuf_offset[MAX_INPUT_BUF]; 503 int32_t inbuf_offset[MAX_INPUT_BUF];
532#endif 504#endif
533 505
534 _ASSERT(codec != NULL, DCE_EINVALID_INPUT); 506 _ASSERT(codec != NULL, DCE_EINVALID_INPUT);
@@ -572,8 +544,8 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
572 /* via memheader offset field. Hence the buf ptr needs to be advanced with the offset */ 544 /* via memheader offset field. Hence the buf ptr needs to be advanced with the offset */
573 inbuf_offset[count] = P2H(*data_buf)->offset; 545 inbuf_offset[count] = P2H(*data_buf)->offset;
574 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf), 546 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),
575 (size_t)P2H(*data_buf), (size_t)memplugin_share((void*)*data_buf)); 547 (size_t)P2H(*data_buf), (size_t)memplugin_share((void *)*data_buf));
576 *(uint8_t*)data_buf += inbuf_offset[count]; 548 *(uint8_t *)data_buf += inbuf_offset[count];
577#else 549#else
578 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf), 550 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),
579 (size_t)*data_buf, (size_t)*data_buf); 551 (size_t)*data_buf, (size_t)*data_buf);
@@ -618,13 +590,15 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
618 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 590 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
619 591
620#ifdef BUILDOS_ANDROID 592#ifdef BUILDOS_ANDROID
621 for( count = 0; count < numInBufs; count++) { 593
594 for( count = 0; count < numInBufs; count++ ) {
622 if( codec_id == OMAP_DCE_VIDDEC3 ) { 595 if( codec_id == OMAP_DCE_VIDDEC3 ) {
623 /* restore the actual buf ptr before returing to the mmf */ 596 /* restore the actual buf ptr before returing to the mmf */
624 data_buf = (void * *)(&(((XDM2_BufDesc *)inBufs)->descs[count].buf)); 597 data_buf = (void * *)(&(((XDM2_BufDesc *)inBufs)->descs[count].buf));
625 *(uint8_t*)data_buf -= inbuf_offset[count]; 598 *(uint8_t *)data_buf -= inbuf_offset[count];
626 } 599 }
627 } 600 }
601
628#endif 602#endif
629 603
630 eError = (dce_error_status)(fxnRet); 604 eError = (dce_error_status)(fxnRet);