aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPradeep Venkatasubbarao2013-11-15 05:05:01 -0600
committerPradeep Venkatasubbarao2013-12-03 01:26:09 -0600
commit9208d0f18664575c0a50420435c19c85ff9740dd (patch)
tree75f177ca0b42328ea1c8b7fd342970b7663e1ec6 /libdce.c
parent31bb1282efc6e9afcfdc90ece237cfe156d4d853 (diff)
downloadrepo-libdce-9208d0f18664575c0a50420435c19c85ff9740dd.tar.gz
repo-libdce-9208d0f18664575c0a50420435c19c85ff9740dd.tar.xz
repo-libdce-9208d0f18664575c0a50420435c19c85ff9740dd.zip
Added VIDDEC2 interfaces for DSP codecs
This patch adds VIDDEC2 interfaces and libdce now supports both VIDDEC2 and VIDDEC3 interfaces. It initializes ipc based on the server name(IVA or DSP). Provisions are made to handle multiple instances of IPU and DSP codecs. Change-Id: Ie1869e626423a6250983711114dc9d0854022309 Signed-off-by: Pradeep Venkatasubbarao <pradeepv@ti.com>
Diffstat (limited to 'libdce.c')
-rw-r--r--libdce.c298
1 files changed, 243 insertions, 55 deletions
diff --git a/libdce.c b/libdce.c
index 8dde367..cdb11bd 100644
--- a/libdce.c
+++ b/libdce.c
@@ -48,11 +48,12 @@
48 48
49/********************* GLOBALS ***********************/ 49/********************* GLOBALS ***********************/
50/* Hande used for Remote Communication */ 50/* Hande used for Remote Communication */
51MmRpc_Handle MmRpcHandle = NULL; 51MmRpc_Handle MmRpcHandle[MAX_REMOTEDEVICES] = { NULL};
52Engine_Handle gEngineHandle[MAX_INSTANCES][MAX_REMOTEDEVICES] = { NULL};
52static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 53static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
53static int __ClientCount = 0; 54static int __ClientCount[MAX_REMOTEDEVICES] = {0};
54int dce_debug = DCE_DEBUG_LEVEL; 55int dce_debug = DCE_DEBUG_LEVEL;
55 56const String DCE_DEVICE_NAME[MAX_REMOTEDEVICES]= {"rpmsg-dce","rpmsg-dce-dsp"};
56/****************** INLINE FUNCTIONS ********************/ 57/****************** INLINE FUNCTIONS ********************/
57 58
58static inline void Fill_MmRpc_fxnCtx(MmRpc_FxnCtx *fxnCtx, int fxn_id, int num_params, int num_xlts, MmRpc_Xlt *xltAry) 59static inline void Fill_MmRpc_fxnCtx(MmRpc_FxnCtx *fxnCtx, int fxn_id, int num_params, int num_xlts, MmRpc_Xlt *xltAry)
@@ -110,32 +111,73 @@ void dce_free(void *ptr)
110 memplugin_free(ptr); 111 memplugin_free(ptr);
111} 112}
112 113
114static int __inline getCoreIndexFromName(String name)
115{
116 if(name == NULL)
117 return INVALID_CORE;
118
119 if(!strcmp(name,"ivahd_vidsvr"))
120 return IPU;
121 else if(!strcmp(name, "dsp_vidsvr"))
122 return DSP;
123 else
124 return INVALID_CORE;
125}
126
127static int __inline getCoreIndexFromCodec(int codec_id)
128{
129 if(codec_id == OMAP_DCE_VIDENC2 || codec_id == OMAP_DCE_VIDDEC3)
130 return IPU;
131 else if(codec_id == OMAP_DCE_VIDDEC2)
132 return DSP;
133 else
134 return INVALID_CORE;
135}
136static int __inline getCoreIndexFromEngine(Engine_Handle engine)
137{
138 int i;
139 int core = INVALID_CORE;
140
141 for(i = 0; i < MAX_INSTANCES ; i++){
142 if(engine == gEngineHandle[i][IPU]){
143 core = IPU;
144 break;
145 }
146 else if(engine == gEngineHandle[i][DSP]){
147 core = DSP;
148 break;
149 }
150 }
151 return core;
152}
113/*=====================================================================================*/ 153/*=====================================================================================*/
114/** dce_ipc_init : Initialize MmRpc. This function is called within Engine_open(). 154/** dce_ipc_init : Initialize MmRpc. This function is called within Engine_open().
115 * 155 *
116 * @ return : Error Status. 156 * @ return : Error Status.
117 */ 157 */
118static int dce_ipc_init(void) 158static int dce_ipc_init(int core)
119{ 159{
120 MmRpc_Params args; 160 MmRpc_Params args;
121 dce_error_status eError = DCE_EOK; 161 dce_error_status eError = DCE_EOK;
122 162
123 DEBUG(" >> dce_ipc_init\n"); 163 DEBUG(" >> dce_ipc_init\n");
124 164
125 __ClientCount++;
126 /* Check if already Initialized */
127 if (__ClientCount > 1) {
128 goto EXIT;
129 }
130
131 /* Create remote server insance */ 165 /* Create remote server insance */
132 MmRpc_Params_init(&args); 166 __ClientCount[core]++;
133 167
134 eError = MmRpc_create(DCE_DEVICE_NAME, &args, &MmRpcHandle); 168 if(__ClientCount[core] > MAX_INSTANCES){
169 eError = DCE_EXDM_UNSUPPORTED;
170 return eError;
171 }
172 if(__ClientCount[core] > 1){
173 goto EXIT;
174 }
135 175
136 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CREATE_FAIL, __ClientCount--); 176 MmRpc_Params_init(&args);
137 177
138 DEBUG("open(/dev/" DCE_DEVICE_NAME ") -> 0x%x\n", (int)MmRpcHandle); 178 eError = MmRpc_create(DCE_DEVICE_NAME[core], &args, &MmRpcHandle[core]);
179 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CREATE_FAIL, __ClientCount[core]--);
180 DEBUG("open(/dev/%s]) -> 0x%x\n",DCE_DEVICE_NAME[core], (int)MmRpcHandle[core]);
139 181
140EXIT: 182EXIT:
141 return (eError); 183 return (eError);
@@ -145,18 +187,17 @@ EXIT:
145/** dce_ipc_deinit : DeInitialize MmRpc. This function is called within 187/** dce_ipc_deinit : DeInitialize MmRpc. This function is called within
146 * Engine_close(). 188 * Engine_close().
147 */ 189 */
148static void dce_ipc_deinit() 190static void dce_ipc_deinit(int core)
149{ 191{
150 __ClientCount--; 192 __ClientCount[core]--;
151 if( __ClientCount > 0 ) { 193 if( __ClientCount[core] > 0 ) {
152 goto EXIT; 194 goto EXIT;
153 } 195 }
154
155 if( MmRpcHandle != NULL ) {
156 MmRpc_delete(&MmRpcHandle);
157 }
158 MmRpcHandle = NULL;
159 196
197 if( MmRpcHandle[core] != NULL ) {
198 MmRpc_delete(&MmRpcHandle[core]);
199 MmRpcHandle[core] = NULL;
200 }
160EXIT: 201EXIT:
161 return; 202 return;
162} 203}
@@ -177,13 +218,15 @@ Engine_Handle Engine_open(String name, Engine_Attrs *attrs, Engine_Error *ec)
177 dce_engine_open *engine_open_msg = NULL; 218 dce_engine_open *engine_open_msg = NULL;
178 Engine_Attrs *engine_attrs = NULL; 219 Engine_Attrs *engine_attrs = NULL;
179 Engine_Handle engine_handle = NULL; 220 Engine_Handle engine_handle = NULL;
221 int coreIdx = INVALID_CORE;
180 222
181 _ASSERT(name != '\0', DCE_EINVALID_INPUT); 223 _ASSERT(name != '\0', DCE_EINVALID_INPUT);
182 224
183 pthread_mutex_lock(&mutex); 225 pthread_mutex_lock(&mutex);
184 226 coreIdx = getCoreIndexFromName(name);
227 _ASSERT(coreIdx != INVALID_CORE, DCE_EINVALID_INPUT);
185 /* Initialize IPC. In case of Error Deinitialize them */ 228 /* Initialize IPC. In case of Error Deinitialize them */
186 _ASSERT(dce_ipc_init() == DCE_EOK, DCE_EIPC_CREATE_FAIL); 229 _ASSERT(dce_ipc_init(coreIdx) == DCE_EOK, DCE_EIPC_CREATE_FAIL);
187 230
188 INFO(">> Engine_open Params::name = %s size = %d\n", name, strlen(name)); 231 INFO(">> Engine_open Params::name = %s size = %d\n", name, strlen(name));
189 /* Allocate Shared memory for the engine_open rpc msg structure*/ 232 /* Allocate Shared memory for the engine_open rpc msg structure*/
@@ -207,9 +250,10 @@ Engine_Handle Engine_open(String name, Engine_Attrs *attrs, Engine_Error *ec)
207 sizeof(MemHeader), memplugin_share(engine_open_msg)); 250 sizeof(MemHeader), memplugin_share(engine_open_msg));
208 251
209 /* Invoke the Remote function through MmRpc */ 252 /* Invoke the Remote function through MmRpc */
210 eError = MmRpc_call(MmRpcHandle, &fxnCtx, (int32_t *)(&engine_handle)); 253 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, (int32_t *)(&engine_handle));
254 gEngineHandle[__ClientCount[coreIdx] - 1][coreIdx] = engine_handle;
211 255
212 /* In case of Error, the Application will get a NULL Engine Handle */ 256 /* In case of Error, the Application will get a NULL Engine Handle */
213 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CALL_FAIL, engine_handle = NULL); 257 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CALL_FAIL, engine_handle = NULL);
214 258
215 if( ec ) { 259 if( ec ) {
@@ -237,8 +281,9 @@ Void Engine_close(Engine_Handle engine)
237 MmRpc_FxnCtx fxnCtx; 281 MmRpc_FxnCtx fxnCtx;
238 int32_t fxnRet; 282 int32_t fxnRet;
239 dce_error_status eError = DCE_EOK; 283 dce_error_status eError = DCE_EOK;
284 int32_t coreIdx = INVALID_CORE;
240 285
241 pthread_mutex_lock(&mutex); 286 pthread_mutex_lock(&mutex);
242 287
243 _ASSERT(engine != NULL, DCE_EINVALID_INPUT); 288 _ASSERT(engine != NULL, DCE_EINVALID_INPUT);
244 289
@@ -246,13 +291,15 @@ Void Engine_close(Engine_Handle engine)
246 Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_ENGINE_CLOSE, 1, 0, NULL); 291 Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_ENGINE_CLOSE, 1, 0, NULL);
247 Fill_MmRpc_fxnCtx_Scalar_Params(fxnCtx.params, sizeof(Engine_Handle), (int32_t)engine); 292 Fill_MmRpc_fxnCtx_Scalar_Params(fxnCtx.params, sizeof(Engine_Handle), (int32_t)engine);
248 293
249 /* Invoke the Remote function through MmRpc */ 294 coreIdx = getCoreIndexFromEngine(engine);
250 eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); 295 _ASSERT(coreIdx != INVALID_CORE,DCE_EINVALID_INPUT);
251 296
297 /* Invoke the Remote function through MmRpc */
298 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, &fxnRet);
252 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 299 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
253 300
254EXIT: 301EXIT:
255 dce_ipc_deinit(); 302 dce_ipc_deinit(coreIdx);
256 303
257 pthread_mutex_unlock(&mutex); 304 pthread_mutex_unlock(&mutex);
258 305
@@ -279,6 +326,7 @@ static void *create(Engine_Handle engine, String name, void *params, dce_codec_t
279 dce_error_status eError = DCE_EOK; 326 dce_error_status eError = DCE_EOK;
280 void *codec_handle = NULL; 327 void *codec_handle = NULL;
281 char *codec_name = NULL; 328 char *codec_name = NULL;
329 int coreIdx = INVALID_CORE;
282 330
283 _ASSERT(name != '\0', DCE_EINVALID_INPUT); 331 _ASSERT(name != '\0', DCE_EINVALID_INPUT);
284 _ASSERT(engine != NULL, DCE_EINVALID_INPUT); 332 _ASSERT(engine != NULL, DCE_EINVALID_INPUT);
@@ -299,8 +347,9 @@ static void *create(Engine_Handle engine, String name, void *params, dce_codec_t
299 Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[3]), GetSz(params), P2H(params), 347 Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[3]), GetSz(params), P2H(params),
300 sizeof(MemHeader), memplugin_share(params)); 348 sizeof(MemHeader), memplugin_share(params));
301 /* Invoke the Remote function through MmRpc */ 349 /* Invoke the Remote function through MmRpc */
302 eError = MmRpc_call(MmRpcHandle, &fxnCtx, (int32_t *)(&codec_handle)); 350 coreIdx = getCoreIndexFromCodec(codec_id);
303 351 _ASSERT(coreIdx != INVALID_CORE, DCE_EINVALID_INPUT);
352 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, (int32_t *)(&codec_handle));
304 /* In case of Error, the Application will get a NULL Codec Handle */ 353 /* In case of Error, the Application will get a NULL Codec Handle */
305 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CALL_FAIL, codec_handle = NULL); 354 _ASSERT_AND_EXECUTE(eError == DCE_EOK, DCE_EIPC_CALL_FAIL, codec_handle = NULL);
306 355
@@ -329,6 +378,7 @@ static XDAS_Int32 control(void *codec, int id, void *dynParams, void *status, dc
329 MmRpc_FxnCtx fxnCtx; 378 MmRpc_FxnCtx fxnCtx;
330 int32_t fxnRet; 379 int32_t fxnRet;
331 dce_error_status eError = DCE_EOK; 380 dce_error_status eError = DCE_EOK;
381 int coreIdx = INVALID_CORE;
332 382
333 _ASSERT(codec != NULL, DCE_EINVALID_INPUT); 383 _ASSERT(codec != NULL, DCE_EINVALID_INPUT);
334 _ASSERT(dynParams != NULL, DCE_EINVALID_INPUT); 384 _ASSERT(dynParams != NULL, DCE_EINVALID_INPUT);
@@ -345,7 +395,9 @@ static XDAS_Int32 control(void *codec, int id, void *dynParams, void *status, dc
345 sizeof(MemHeader), memplugin_share(status)); 395 sizeof(MemHeader), memplugin_share(status));
346 396
347 /* Invoke the Remote function through MmRpc */ 397 /* Invoke the Remote function through MmRpc */
348 eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); 398 coreIdx = getCoreIndexFromCodec(codec_id);
399 _ASSERT(coreIdx != INVALID_CORE, DCE_EINVALID_INPUT);
400 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, &fxnRet);
349 401
350 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 402 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
351 403
@@ -378,6 +430,7 @@ static XDAS_Int32 get_version(void *codec, void *dynParams, void *status, dce_co
378 void * *version_buf = NULL; 430 void * *version_buf = NULL;
379 int32_t fxnRet; 431 int32_t fxnRet;
380 dce_error_status eError = DCE_EOK; 432 dce_error_status eError = DCE_EOK;
433 int coreIdx = INVALID_CORE;
381 434
382 _ASSERT(codec != NULL, DCE_EINVALID_INPUT); 435 _ASSERT(codec != NULL, DCE_EINVALID_INPUT);
383 _ASSERT(dynParams != NULL, DCE_EINVALID_INPUT); 436 _ASSERT(dynParams != NULL, DCE_EINVALID_INPUT);
@@ -387,6 +440,8 @@ static XDAS_Int32 get_version(void *codec, void *dynParams, void *status, dce_co
387 version_buf = (void * *)(&(((IVIDDEC3_Status *)status)->data.buf)); 440 version_buf = (void * *)(&(((IVIDDEC3_Status *)status)->data.buf));
388 } else if( codec_id == OMAP_DCE_VIDENC2 ) { 441 } else if( codec_id == OMAP_DCE_VIDENC2 ) {
389 version_buf = (void * *)(&(((IVIDENC2_Status *)status)->data.buf)); 442 version_buf = (void * *)(&(((IVIDENC2_Status *)status)->data.buf));
443 }else if( codec_id == OMAP_DCE_VIDDEC2 ) {
444 version_buf = (void * *)(&(((IVIDDEC2_Status *)status)->data.buf));
390 } 445 }
391 _ASSERT(*version_buf != NULL, DCE_EINVALID_INPUT); 446 _ASSERT(*version_buf != NULL, DCE_EINVALID_INPUT);
392 447
@@ -400,10 +455,14 @@ static XDAS_Int32 get_version(void *codec, void *dynParams, void *status, dce_co
400 sizeof(MemHeader), memplugin_share(status)); 455 sizeof(MemHeader), memplugin_share(status));
401 456
402 /* Address Translation needed for buffer for version Info */ 457 /* Address Translation needed for buffer for version Info */
403 Fill_MmRpc_fxnCtx_Xlt_Array(fxnCtx.xltAry, 3, MmRpc_OFFSET((int32_t)status, (int32_t)version_buf), (size_t)P2H(*version_buf), memplugin_share(*version_buf)); 458 Fill_MmRpc_fxnCtx_Xlt_Array(fxnCtx.xltAry, 3,
459 MmRpc_OFFSET((int32_t)status, (int32_t)version_buf),
460 (size_t)P2H(*version_buf), memplugin_share(*version_buf));
404 461
405 /* Invoke the Remote function through MmRpc */ 462 /* Invoke the Remote function through MmRpc */
406 eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); 463 coreIdx = getCoreIndexFromCodec(codec_id);
464 _ASSERT(coreIdx != INVALID_CORE, DCE_EINVALID_INPUT);
465 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, &fxnRet);
407 466
408 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 467 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
409 468
@@ -417,7 +476,8 @@ typedef enum process_call_params {
417 INBUFS_INDEX, 476 INBUFS_INDEX,
418 OUTBUFS_INDEX, 477 OUTBUFS_INDEX,
419 INARGS_INDEX, 478 INARGS_INDEX,
420 OUTARGS_INDEX 479 OUTARGS_INDEX,
480 OUTBUFS_PTR_INDEX
421} process_call_params; 481} process_call_params;
422 482
423#define LUMA_BUF 0 483#define LUMA_BUF 0
@@ -441,10 +501,14 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
441 void *inArgs, void *outArgs, dce_codec_type codec_id) 501 void *inArgs, void *outArgs, dce_codec_type codec_id)
442{ 502{
443 MmRpc_FxnCtx fxnCtx; 503 MmRpc_FxnCtx fxnCtx;
444 MmRpc_Xlt xltAry[MAX_TOTAl_BUF]; 504 MmRpc_Xlt xltAry[MAX_TOTAL_BUF];
445 int fxnRet, count, total_count, numInBufs = 0, numOutBufs = 0; 505 int fxnRet, count, total_count, numInBufs = 0, numOutBufs = 0;
446 dce_error_status eError = DCE_EOK; 506 dce_error_status eError = DCE_EOK;
447 void * *data_buf = NULL; 507 void **data_buf = NULL;
508 void **buf_arry = NULL;
509 void **bufSize_arry = NULL;
510 int numXltAry, numParams;
511 int coreIdx = INVALID_CORE;
448 512
449#ifdef BUILDOS_ANDROID 513#ifdef BUILDOS_ANDROID
450 int32_t inbuf_offset[MAX_INPUT_BUF]; 514 int32_t inbuf_offset[MAX_INPUT_BUF];
@@ -459,14 +523,28 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
459 if( codec_id == OMAP_DCE_VIDDEC3 ) { 523 if( codec_id == OMAP_DCE_VIDDEC3 ) {
460 numInBufs = ((XDM2_BufDesc *)inBufs)->numBufs; 524 numInBufs = ((XDM2_BufDesc *)inBufs)->numBufs;
461 numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs; 525 numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs;
526 numXltAry = numInBufs + numOutBufs;
527 numParams = 6;
462 } else if( codec_id == OMAP_DCE_VIDENC2 ) { 528 } else if( codec_id == OMAP_DCE_VIDENC2 ) {
463 numInBufs = ((IVIDEO2_BufDesc *)inBufs)->numPlanes; 529 numInBufs = ((IVIDEO2_BufDesc *)inBufs)->numPlanes;
464 numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs; 530 numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs;
531 numXltAry = numInBufs + numOutBufs;
532 numParams = 6;
533 }else if( codec_id == OMAP_DCE_VIDDEC2 ) {
534 numInBufs = ((XDM1_BufDesc *)inBufs)->numBufs;
535 numOutBufs = ((XDM_BufDesc *)outBufs)->numBufs;
536 numXltAry = numInBufs + numOutBufs + MAX_OUTPUT_BUFPTRS;/* 2 extra needed for bufs and bufSizes */
537 numParams = 7;
538 }
539 else{
540 eError = DCE_EXDM_UNSUPPORTED;
541 return eError;
465 } 542 }
466 543
544
467 /* marshall function arguments into the send buffer */ 545 /* marshall function arguments into the send buffer */
468 /* Approach [2] as explained in "Notes" used for process */ 546 /* Approach [2] as explained in "Notes" used for process */
469 Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_PROCESS, 6, numInBufs + numOutBufs, xltAry); 547 Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_PROCESS, numParams, numXltAry, xltAry);
470 Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_ID_INDEX]), sizeof(int32_t), codec_id); 548 Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_ID_INDEX]), sizeof(int32_t), codec_id);
471 Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_HANDLE_INDEX]), sizeof(int32_t), (int32_t)codec); 549 Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_HANDLE_INDEX]), sizeof(int32_t), (int32_t)codec);
472 550
@@ -490,34 +568,60 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
490 /* for the actual data. the offset within the input buffer is provided */ 568 /* for the actual data. the offset within the input buffer is provided */
491 /* via memheader offset field. Hence the buf ptr needs to be advanced with the offset */ 569 /* via memheader offset field. Hence the buf ptr needs to be advanced with the offset */
492 inbuf_offset[count] = P2H(*data_buf)->offset; 570 inbuf_offset[count] = P2H(*data_buf)->offset;
493 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf), 571 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX,
494 (size_t)P2H(*data_buf), (size_t)memplugin_share((void *)*data_buf)); 572 MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),(size_t)P2H(*data_buf),
573 (size_t)memplugin_share((void *)*data_buf));
574
495 *data_buf += inbuf_offset[count]; 575 *data_buf += inbuf_offset[count];
496#else 576#else
497 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf), 577 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX,
498 (size_t)*data_buf, (size_t)*data_buf); 578 MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),
579 (size_t)*data_buf, (size_t)*data_buf);
499#endif 580#endif
500 } else if( codec_id == OMAP_DCE_VIDENC2 ) { 581 } else if( codec_id == OMAP_DCE_VIDENC2 ) {
501 data_buf = (void * *)(&(((IVIDEO2_BufDesc *)inBufs)->planeDesc[count].buf)); 582 data_buf = (void * *)(&(((IVIDEO2_BufDesc *)inBufs)->planeDesc[count].buf));
502 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf), 583 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX,
503 (size_t)*data_buf, (size_t)*data_buf); 584 MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),
585 (size_t)*data_buf, (size_t)*data_buf);
586
587 } else if( codec_id == OMAP_DCE_VIDDEC2 ) {
588 data_buf = (void * *)(&(((XDM1_BufDesc *)inBufs)->descs[count].buf));
589#ifdef BUILDOS_ANDROID
590 /* the decoder input buffer filled by the parsers, have an offset */
591 /* for the actual data. the offset within the input buffer is provided */
592 /* via memheader offset field. Hence the buf ptr needs to be advanced with the offset */
593 inbuf_offset[count] = P2H(*data_buf)->offset;
594 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX,
595 MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),(size_t)P2H(*data_buf),
596 (size_t)memplugin_share((void *)*data_buf));
597
598 *data_buf += inbuf_offset[count];
599#else
600 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX,
601 MmRpc_OFFSET((int32_t)inBufs, (int32_t)data_buf),
602 (size_t)*data_buf, (size_t)*data_buf);
603#endif
504 } 604 }
505 } 605}
506 606
507 /* Output Buffers */ 607 /* Output Buffers */
508 for( count = 0; count < numOutBufs; count++, total_count++ ) { 608 for( count = 0; count < numOutBufs; count++, total_count++ ) {
609 if(codec_id == OMAP_DCE_VIDENC2 || codec_id == OMAP_DCE_VIDDEC3) {
509 if(((XDM2_BufDesc *)outBufs)->descs[LUMA_BUF].buf != ((XDM2_BufDesc *)outBufs)->descs[CHROMA_BUF].buf ) { 610 if(((XDM2_BufDesc *)outBufs)->descs[LUMA_BUF].buf != ((XDM2_BufDesc *)outBufs)->descs[CHROMA_BUF].buf ) {
510 /* Either Encode usecase or MultiPlanar Buffers for Decode usecase */ 611 /* Either Encode usecase or MultiPlanar Buffers for Decode usecase */
511 data_buf = (void * *)(&(((XDM2_BufDesc *)outBufs)->descs[count].buf)); 612 data_buf = (void * *)(&(((XDM2_BufDesc *)outBufs)->descs[count].buf));
512 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX, MmRpc_OFFSET((int32_t)outBufs, (int32_t)data_buf), 613 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX,
513 (size_t)*data_buf, (size_t)*data_buf); 614 MmRpc_OFFSET((int32_t)outBufs, (int32_t)data_buf),
615 (size_t)*data_buf, (size_t)*data_buf);
514 } 616 }
515#if defined(BUILDOS_LINUX) || defined(BUILDOS_ANDROID) 617#if defined(BUILDOS_LINUX) || defined(BUILDOS_ANDROID)
516 else { 618 else {
517 /* SinglePlanar Buffers for Decode usecase*/ 619 /* SinglePlanar Buffers for Decode usecase*/
518 data_buf = (void * *)(&(((XDM2_BufDesc *)outBufs)->descs[count].buf)); 620 data_buf = (void * *)(&(((XDM2_BufDesc *)outBufs)->descs[count].buf));
519 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX, MmRpc_OFFSET((int32_t)outBufs, (int32_t)data_buf), 621 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX,
520 (size_t)*data_buf, (size_t)*data_buf); 622 MmRpc_OFFSET((int32_t)outBufs, (int32_t)data_buf),
623 (size_t)*data_buf, (size_t)*data_buf);
624
521 if( count == CHROMA_BUF ) { 625 if( count == CHROMA_BUF ) {
522 if(((XDM2_BufDesc *)outBufs)->descs[count].memType == XDM_MEMTYPE_RAW || 626 if(((XDM2_BufDesc *)outBufs)->descs[count].memType == XDM_MEMTYPE_RAW ||
523 ((XDM2_BufDesc *)outBufs)->descs[count].memType == XDM_MEMTYPE_TILEDPAGE ) { 627 ((XDM2_BufDesc *)outBufs)->descs[count].memType == XDM_MEMTYPE_TILEDPAGE ) {
@@ -529,10 +633,40 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
529 } 633 }
530 } 634 }
531#endif 635#endif
532 } 636 }else if(codec_id == OMAP_DCE_VIDDEC2) {
637 if(count == LUMA_BUF) {
638 buf_arry = (void * *)(&(((XDM_BufDesc *)outBufs)->bufs));
639
640 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX,
641 MmRpc_OFFSET((int32_t)outBufs, (int32_t)buf_arry),
642 (size_t)P2H(*buf_arry), (size_t)memplugin_share(*buf_arry));
643
644 total_count++;
645
646 bufSize_arry = (void * *)(&(((XDM_BufDesc *)outBufs)->bufSizes));
533 647
648 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX,
649 MmRpc_OFFSET((int32_t)outBufs, (int32_t)bufSize_arry),
650 (size_t)P2H(*bufSize_arry), (size_t)memplugin_share(*bufSize_arry));
651
652 total_count++;
653 }
654
655 Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[OUTBUFS_PTR_INDEX]), GetSz(*buf_arry), P2H(*buf_arry),
656 sizeof(MemHeader), memplugin_share(*buf_arry));
657
658 data_buf = (void * *)(&(((XDM_BufDesc *)outBufs)->bufs[count]));
659
660 Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_PTR_INDEX,
661 MmRpc_OFFSET((int32_t)*buf_arry, (int32_t)data_buf), (size_t)*data_buf, (size_t)*data_buf);
662
663 }
664
665}
534 /* Invoke the Remote function through MmRpc */ 666 /* Invoke the Remote function through MmRpc */
535 eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); 667 coreIdx = getCoreIndexFromCodec(codec_id);
668 _ASSERT(coreIdx != INVALID_CORE, DCE_EINVALID_INPUT);
669 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, &fxnRet);
536 670
537 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 671 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
538 672
@@ -543,6 +677,10 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs,
543 /* restore the actual buf ptr before returing to the mmf */ 677 /* restore the actual buf ptr before returing to the mmf */
544 data_buf = (void * *)(&(((XDM2_BufDesc *)inBufs)->descs[count].buf)); 678 data_buf = (void * *)(&(((XDM2_BufDesc *)inBufs)->descs[count].buf));
545 *data_buf -= inbuf_offset[count]; 679 *data_buf -= inbuf_offset[count];
680 }else if( codec_id == OMAP_DCE_VIDDEC2 ) {
681 /* restore the actual buf ptr before returing to the mmf */
682 data_buf = (void * *)(&(((XDM1_BufDesc *)inBufs)->descs[count].buf));
683 *data_buf -= inbuf_offset[count];
546 } 684 }
547 } 685 }
548 686
@@ -565,6 +703,7 @@ static void delete(void *codec, dce_codec_type codec_id)
565 MmRpc_FxnCtx fxnCtx; 703 MmRpc_FxnCtx fxnCtx;
566 int32_t fxnRet; 704 int32_t fxnRet;
567 dce_error_status eError = DCE_EOK; 705 dce_error_status eError = DCE_EOK;
706 int coreIdx = INVALID_CORE;
568 707
569 _ASSERT(codec != NULL, DCE_EINVALID_INPUT); 708 _ASSERT(codec != NULL, DCE_EINVALID_INPUT);
570 709
@@ -574,7 +713,9 @@ static void delete(void *codec, dce_codec_type codec_id)
574 Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(int32_t), (int32_t)codec); 713 Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(int32_t), (int32_t)codec);
575 714
576 /* Invoke the Remote function through MmRpc */ 715 /* Invoke the Remote function through MmRpc */
577 eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); 716 coreIdx = getCoreIndexFromCodec(codec_id);
717 _ASSERT(coreIdx != INVALID_CORE, DCE_EINVALID_INPUT);
718 eError = MmRpc_call(MmRpcHandle[coreIdx], &fxnCtx, &fxnRet);
578 719
579 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 720 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
580 721
@@ -582,7 +723,7 @@ EXIT:
582 return; 723 return;
583} 724}
584 725
585/*************** Deocder Codec Engine Functions ***********************/ 726/*************** Decoder Codec Engine Functions ***********************/
586VIDDEC3_Handle VIDDEC3_create(Engine_Handle engine, String name, 727VIDDEC3_Handle VIDDEC3_create(Engine_Handle engine, String name,
587 VIDDEC3_Params *params) 728 VIDDEC3_Params *params)
588{ 729{
@@ -678,4 +819,51 @@ Void VIDENC2_delete(VIDENC2_Handle codec)
678 delete(codec, OMAP_DCE_VIDENC2); 819 delete(codec, OMAP_DCE_VIDENC2);
679 DEBUG("<<"); 820 DEBUG("<<");
680} 821}
822/*************** Decoder Codec Engine Functions ***********************/
823VIDDEC2_Handle VIDDEC2_create(Engine_Handle engine, String name,
824 VIDDEC2_Params *params)
825{
826 VIDDEC2_Handle codec;
827
828 DEBUG(">> engine=%p, name=%s, params=%p", engine, name, params);
829 codec = create(engine, name, params, OMAP_DCE_VIDDEC2);
830 DEBUG("<< codec=%p", codec);
831 return (codec);
832}
681 833
834XDAS_Int32 VIDDEC2_control(VIDDEC2_Handle codec, VIDDEC2_Cmd id,
835 VIDDEC2_DynamicParams *dynParams, VIDDEC2_Status *status)
836{
837 XDAS_Int32 ret;
838
839 DEBUG(">> codec=%p, id=%d, dynParams=%p, status=%p",
840 codec, id, dynParams, status);
841 if( id == XDM_GETVERSION ) {
842 ret = get_version(codec, dynParams, status, OMAP_DCE_VIDDEC2);
843 } else {
844 ret = control(codec, id, dynParams, status, OMAP_DCE_VIDDEC2);
845 }
846 DEBUG("<< ret=%d", ret);
847 return (ret);
848}
849
850XDAS_Int32 VIDDEC2_process(VIDDEC2_Handle codec,
851 XDM1_BufDesc *inBufs, XDM_BufDesc *outBufs,
852 VIDDEC2_InArgs *inArgs, VIDDEC2_OutArgs *outArgs)
853{
854 XDAS_Int32 ret;
855
856 DEBUG(">> codec=%p, inBufs=%p, outBufs=%p, inArgs=%p, outArgs=%p",
857 codec, inBufs, outBufs, inArgs, outArgs);
858 ret = process(codec, inBufs, outBufs, inArgs, outArgs, OMAP_DCE_VIDDEC2);
859 DEBUG("<< ret=%d", ret);
860 return (ret);
861}
862
863
864Void VIDDEC2_delete(VIDDEC2_Handle codec)
865{
866 DEBUG(">> codec=%p", codec);
867 delete(codec, OMAP_DCE_VIDDEC2);
868 DEBUG("<<");
869}