diff options
author | Saurabh Bipin Chandra | 2013-08-04 04:55:14 -0500 |
---|---|---|
committer | Saurabh Bipin Chandra | 2013-08-30 00:58:22 -0500 |
commit | 6163ea9eb894f3d88562e31ea442f848a6e8a568 (patch) | |
tree | a2092941c0ce83d28e9faeb0d112f245d225162d | |
parent | 060b6ab4d13c30af1062df055889f86ccca3c6b7 (diff) | |
download | repo-libdce-3.00.01.05.tar.gz repo-libdce-3.00.01.05.tar.xz repo-libdce-3.00.01.05.zip |
[GLP] Enable DMA Buf Handle3.00.01.05
This patch converts all MmRpc_Pointer_Param call
to MmRpc_OffsetPointer_Param to take care of MemHeader.
This is not needed from a QNX perspective but is needed
from a Linux perspective. There should no added latency is QNX
due to this change as the rpmsg_rpc kernel path is still the same.
This patch invokes memplugin_share() for the buffers allocated
through DCE to get the corresponding DMA Buf Handles for GLP.
For QNX, the return value is expected to be 0.
For linux, the patch adds the logic for Single vs Multiplanar buffers.
For linux, the memplugin_share() logic is modified to store and
retireve the same dma_buf_fd rather than getting a dup() each time.
These changes makes the following assumptions:
1. All the parameter buffers are allocated through
DCE/MemPlugin.
2. The CLient passes Virtual pointers, rather than
DMA Buf Handles to libdce for parameter buffers.
3. For IO Buffers, the client passes DMA Buf Handles
and are not allocated using DCE/MemPlugin.
This patch assumes MmRpc is exposing translation[i].base.
Change-Id: I7d13f4a4d69fbe8b6dd0317e2a860f0df2061ef9
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Signed-off-by: Saurabh Bipin Chandra <a0131926@ti.com>
-rw-r--r-- | libdce.c | 100 | ||||
-rw-r--r-- | memplugin.h | 8 | ||||
-rw-r--r-- | memplugin_linux.c | 8 |
3 files changed, 83 insertions, 33 deletions
@@ -111,12 +111,21 @@ static inline void Fill_MmRpc_fxnCtx(MmRpc_FxnCtx *fxnCtx, int fxn_id, int num_p | |||
111 | fxnCtx->xltAry = xltAry; | 111 | fxnCtx->xltAry = xltAry; |
112 | } | 112 | } |
113 | 113 | ||
114 | static inline void Fill_MmRpc_fxnCtx_Ptr_Params(MmRpc_Param *mmrpc_params, int size, void *addr, void *handle) | 114 | static inline void Fill_MmRpc_fxnCtx_OffPtr_Params(MmRpc_Param *mmrpc_params, int size, void *base, int offset, size_t handle) |
115 | { | ||
116 | mmrpc_params->type = MmRpc_ParamType_OffPtr; | ||
117 | mmrpc_params->param.offPtr.size = (size_t)size; | ||
118 | mmrpc_params->param.offPtr.base = (size_t)base; | ||
119 | mmrpc_params->param.offPtr.offset = (size_t)offset; | ||
120 | mmrpc_params->param.offPtr.handle = handle; | ||
121 | } | ||
122 | |||
123 | static inline void Fill_MmRpc_fxnCtx_Ptr_Params(MmRpc_Param *mmrpc_params, int size, void *addr, size_t handle) | ||
115 | { | 124 | { |
116 | mmrpc_params->type = MmRpc_ParamType_Ptr; | 125 | mmrpc_params->type = MmRpc_ParamType_Ptr; |
117 | mmrpc_params->param.ptr.size = size; | 126 | mmrpc_params->param.ptr.size = size; |
118 | mmrpc_params->param.ptr.addr = (size_t)addr; | 127 | mmrpc_params->param.ptr.addr = (size_t)addr; |
119 | mmrpc_params->param.ptr.handle = (size_t)handle; | 128 | mmrpc_params->param.ptr.handle = handle; |
120 | } | 129 | } |
121 | 130 | ||
122 | static inline void Fill_MmRpc_fxnCtx_Scalar_Params(MmRpc_Param *mmrpc_params, int size, int data) | 131 | static inline void Fill_MmRpc_fxnCtx_Scalar_Params(MmRpc_Param *mmrpc_params, int size, int data) |
@@ -126,13 +135,14 @@ static inline void Fill_MmRpc_fxnCtx_Scalar_Params(MmRpc_Param *mmrpc_params, in | |||
126 | mmrpc_params->param.scalar.data = (size_t)data; | 135 | mmrpc_params->param.scalar.data = (size_t)data; |
127 | } | 136 | } |
128 | 137 | ||
129 | static inline void Fill_MmRpc_fxnCtx_Xlt_Array(MmRpc_Xlt *mmrpc_xlt, int index, int32_t base, int32_t addr, void *handle) | 138 | static inline void Fill_MmRpc_fxnCtx_Xlt_Array(MmRpc_Xlt *mmrpc_xlt, int index, int32_t base, int32_t addr, size_t handle) |
130 | { | 139 | { |
131 | /* index : index of params filled in FxnCtx */ | 140 | /* index : index of params filled in FxnCtx */ |
132 | /* offset : calculated from address of index */ | 141 | /* offset : calculated from address of index */ |
133 | mmrpc_xlt->index = index; | 142 | mmrpc_xlt->index = index; |
134 | mmrpc_xlt->offset = MmRpc_OFFSET(base, addr); | 143 | mmrpc_xlt->offset = MmRpc_OFFSET(base, addr); |
135 | mmrpc_xlt->handle = (size_t)handle; | 144 | mmrpc_xlt->base = handle; |
145 | mmrpc_xlt->handle = handle; | ||
136 | } | 146 | } |
137 | 147 | ||
138 | /************************ FUNCTIONS **************************/ | 148 | /************************ FUNCTIONS **************************/ |
@@ -273,7 +283,8 @@ Engine_Handle Engine_open(String name, Engine_Attrs *attrs, Engine_Error *ec) | |||
273 | 283 | ||
274 | /* Marshall function arguments into the send buffer */ | 284 | /* Marshall function arguments into the send buffer */ |
275 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_ENGINE_OPEN, 1, 0, NULL); | 285 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_ENGINE_OPEN, 1, 0, NULL); |
276 | Fill_MmRpc_fxnCtx_Ptr_Params(fxnCtx.params, sizeof(dce_engine_open), engine_open_msg, NULL); | 286 | Fill_MmRpc_fxnCtx_OffPtr_Params(fxnCtx.params, GetSz(engine_open_msg), (void *)P2H(engine_open_msg), |
287 | sizeof(MemHeader), memplugin_share(engine_open_msg)); | ||
277 | 288 | ||
278 | /* Invoke the Remote function through MmRpc */ | 289 | /* Invoke the Remote function through MmRpc */ |
279 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, (int32_t *)(&engine_handle)); | 290 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, (int32_t *)(&engine_handle)); |
@@ -354,9 +365,10 @@ static void *create(Engine_Handle engine, String name, void *params, dce_codec_t | |||
354 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_CREATE, 4, 0, NULL); | 365 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_CREATE, 4, 0, NULL); |
355 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[0]), sizeof(int32_t), codec_id); | 366 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[0]), sizeof(int32_t), codec_id); |
356 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(Engine_Handle), (int32_t)engine); | 367 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(Engine_Handle), (int32_t)engine); |
357 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[2]), (P2H(codec_name))->size, codec_name, NULL); | 368 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[2]), GetSz(codec_name), P2H(codec_name), |
358 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[3]), (P2H(params))->size, params, NULL); | 369 | sizeof(MemHeader), memplugin_share(codec_name)); |
359 | 370 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[3]), GetSz(params), P2H(params), | |
371 | sizeof(MemHeader), memplugin_share(params)); | ||
360 | /* Invoke the Remote function through MmRpc */ | 372 | /* Invoke the Remote function through MmRpc */ |
361 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, (int32_t *)(&codec_handle)); | 373 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, (int32_t *)(&codec_handle)); |
362 | 374 | ||
@@ -398,8 +410,10 @@ static XDAS_Int32 control(void *codec, int id, void *dynParams, void *status, dc | |||
398 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[0]), sizeof(int32_t), codec_id); | 410 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[0]), sizeof(int32_t), codec_id); |
399 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(int32_t), (int32_t)codec); | 411 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(int32_t), (int32_t)codec); |
400 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[2]), sizeof(int32_t), (int32_t)id); | 412 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[2]), sizeof(int32_t), (int32_t)id); |
401 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[3]), (P2H(dynParams))->size, dynParams, NULL); | 413 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[3]), GetSz(dynParams), P2H(dynParams), |
402 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[4]), (P2H(status))->size, status, NULL); | 414 | sizeof(MemHeader), memplugin_share(dynParams)); |
415 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[4]), GetSz(status), P2H(status), | ||
416 | sizeof(MemHeader), memplugin_share(status)); | ||
403 | 417 | ||
404 | /* Invoke the Remote function through MmRpc */ | 418 | /* Invoke the Remote function through MmRpc */ |
405 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); | 419 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); |
@@ -451,11 +465,13 @@ static XDAS_Int32 get_version(void *codec, void *dynParams, void *status, dce_co | |||
451 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_GET_VERSION, 4, 1, &xltAry); | 465 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_GET_VERSION, 4, 1, &xltAry); |
452 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[0]), sizeof(int32_t), codec_id); | 466 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[0]), sizeof(int32_t), codec_id); |
453 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(int32_t), (int32_t)codec); | 467 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[1]), sizeof(int32_t), (int32_t)codec); |
454 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[2]), (P2H(dynParams))->size, dynParams, NULL); | 468 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[2]), GetSz(dynParams), P2H(dynParams), |
455 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[3]), (P2H(status))->size, status, NULL); | 469 | sizeof(MemHeader), memplugin_share(dynParams)); |
470 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[3]), GetSz(status), P2H(status), | ||
471 | sizeof(MemHeader), memplugin_share(status)); | ||
456 | 472 | ||
457 | /* Address Translation needed for buffer for version Info */ | 473 | /* Address Translation needed for buffer for version Info */ |
458 | Fill_MmRpc_fxnCtx_Xlt_Array(fxnCtx.xltAry, 3, (int32_t)status, (int32_t)version_buf, NULL); | 474 | Fill_MmRpc_fxnCtx_Xlt_Array(fxnCtx.xltAry, 3, (int32_t)P2H(status), (int32_t)version_buf, memplugin_share(*version_buf)); |
459 | 475 | ||
460 | /* Invoke the Remote function through MmRpc */ | 476 | /* Invoke the Remote function through MmRpc */ |
461 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); | 477 | eError = MmRpc_call(MmRpcHandle, &fxnCtx, &fxnRet); |
@@ -475,6 +491,8 @@ typedef enum process_call_params { | |||
475 | OUTARGS_INDEX | 491 | OUTARGS_INDEX |
476 | } process_call_params; | 492 | } process_call_params; |
477 | 493 | ||
494 | #define LUMA_BUF 0 | ||
495 | #define CHROMA_BUF 1 | ||
478 | /*===============================================================*/ | 496 | /*===============================================================*/ |
479 | /** process : Encode/Decode process. | 497 | /** process : Encode/Decode process. |
480 | * | 498 | * |
@@ -495,8 +513,9 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs, | |||
495 | { | 513 | { |
496 | MmRpc_FxnCtx fxnCtx; | 514 | MmRpc_FxnCtx fxnCtx; |
497 | MmRpc_Xlt xltAry[MAX_TOTAl_BUF]; | 515 | MmRpc_Xlt xltAry[MAX_TOTAl_BUF]; |
498 | int fxnRet, count, total_count, numInBufs = 0, numOutBufs = 0, sz[OUTARGS_INDEX + 1] = { 0 }; | 516 | int fxnRet, count, total_count, numInBufs = 0, numOutBufs = 0; |
499 | dce_error_status eError = DCE_EOK; | 517 | dce_error_status eError = DCE_EOK; |
518 | void * *data_buf = NULL; | ||
500 | 519 | ||
501 | _ASSERT(codec != NULL, DCE_EINVALID_INPUT); | 520 | _ASSERT(codec != NULL, DCE_EINVALID_INPUT); |
502 | _ASSERT(inBufs != NULL, DCE_EINVALID_INPUT); | 521 | _ASSERT(inBufs != NULL, DCE_EINVALID_INPUT); |
@@ -507,17 +526,9 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs, | |||
507 | if( codec_id == OMAP_DCE_VIDDEC3 ) { | 526 | if( codec_id == OMAP_DCE_VIDDEC3 ) { |
508 | numInBufs = ((XDM2_BufDesc *)inBufs)->numBufs; | 527 | numInBufs = ((XDM2_BufDesc *)inBufs)->numBufs; |
509 | numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs; | 528 | numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs; |
510 | sz[INBUFS_INDEX] = sizeof(XDM2_BufDesc); | ||
511 | sz[OUTBUFS_INDEX] = sizeof(XDM2_BufDesc); | ||
512 | sz[INARGS_INDEX] = sizeof(VIDDEC3_InArgs); | ||
513 | sz[OUTARGS_INDEX] = sizeof(VIDDEC3_OutArgs); | ||
514 | } else if( codec_id == OMAP_DCE_VIDENC2 ) { | 529 | } else if( codec_id == OMAP_DCE_VIDENC2 ) { |
515 | numInBufs = ((IVIDEO2_BufDesc *)inBufs)->numPlanes; | 530 | numInBufs = ((IVIDEO2_BufDesc *)inBufs)->numPlanes; |
516 | numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs; | 531 | numOutBufs = ((XDM2_BufDesc *)outBufs)->numBufs; |
517 | sz[INBUFS_INDEX] = sizeof(IVIDEO2_BufDesc); | ||
518 | sz[OUTBUFS_INDEX] = sizeof(XDM2_BufDesc); | ||
519 | sz[INARGS_INDEX] = sizeof(VIDENC2_InArgs); | ||
520 | sz[OUTARGS_INDEX] = sizeof(VIDENC2_OutArgs); | ||
521 | } | 532 | } |
522 | 533 | ||
523 | /* marshall function arguments into the send buffer */ | 534 | /* marshall function arguments into the send buffer */ |
@@ -525,24 +536,55 @@ static XDAS_Int32 process(void *codec, void *inBufs, void *outBufs, | |||
525 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_PROCESS, 6, numInBufs + numOutBufs, xltAry); | 536 | Fill_MmRpc_fxnCtx(&fxnCtx, DCE_RPC_CODEC_PROCESS, 6, numInBufs + numOutBufs, xltAry); |
526 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_ID_INDEX]), sizeof(int32_t), codec_id); | 537 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_ID_INDEX]), sizeof(int32_t), codec_id); |
527 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_HANDLE_INDEX]), sizeof(int32_t), (int32_t)codec); | 538 | Fill_MmRpc_fxnCtx_Scalar_Params(&(fxnCtx.params[CODEC_HANDLE_INDEX]), sizeof(int32_t), (int32_t)codec); |
528 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[INBUFS_INDEX]), sz[INBUFS_INDEX], inBufs, NULL); | 539 | |
529 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[OUTBUFS_INDEX]), sz[OUTBUFS_INDEX], outBufs, NULL); | 540 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[INBUFS_INDEX]), GetSz(inBufs), P2H(inBufs), |
530 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[INARGS_INDEX]), sz[INARGS_INDEX], inArgs, NULL); | 541 | sizeof(MemHeader), memplugin_share(inBufs)); |
531 | Fill_MmRpc_fxnCtx_Ptr_Params(&(fxnCtx.params[OUTARGS_INDEX]), sz[OUTARGS_INDEX], outArgs, NULL); | 542 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[OUTBUFS_INDEX]), GetSz(outBufs), P2H(outBufs), |
543 | sizeof(MemHeader), memplugin_share(outBufs)); | ||
544 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[INARGS_INDEX]), GetSz(inArgs), P2H(inArgs), | ||
545 | sizeof(MemHeader), memplugin_share(inArgs)); | ||
546 | Fill_MmRpc_fxnCtx_OffPtr_Params(&(fxnCtx.params[OUTARGS_INDEX]), GetSz(outArgs), P2H(outArgs), | ||
547 | sizeof(MemHeader), memplugin_share(outArgs)); | ||
532 | 548 | ||
533 | /* InBufs, OutBufs, InArgs, OutArgs buffer need translation but since they have been */ | 549 | /* InBufs, OutBufs, InArgs, OutArgs buffer need translation but since they have been */ |
534 | /* individually mentioned as fxnCtx Params, they need not be mentioned below again */ | 550 | /* individually mentioned as fxnCtx Params, they need not be mentioned below again */ |
535 | /* Input and Output Buffers have to be mentioned for translation */ | 551 | /* Input and Output Buffers have to be mentioned for translation */ |
536 | for( count = 0, total_count = 0; count < numInBufs; count++, total_count++ ) { | 552 | for( count = 0, total_count = 0; count < numInBufs; count++, total_count++ ) { |
537 | if( codec_id == OMAP_DCE_VIDDEC3 ) { | 553 | if( codec_id == OMAP_DCE_VIDDEC3 ) { |
538 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, (int32_t)inBufs, (int32_t)&(((XDM2_BufDesc *)inBufs)->descs[count].buf), NULL); | 554 | data_buf = (void * *)(&(((XDM2_BufDesc *)inBufs)->descs[count].buf)); |
555 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, (int32_t)P2H(inBufs), | ||
556 | (int32_t)data_buf, (size_t)*data_buf); | ||
539 | } else if( codec_id == OMAP_DCE_VIDENC2 ) { | 557 | } else if( codec_id == OMAP_DCE_VIDENC2 ) { |
540 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, (int32_t)inBufs, (int32_t)&(((IVIDEO2_BufDesc *)inBufs)->planeDesc[count].buf), NULL); | 558 | data_buf = (void * *)(&(((IVIDEO2_BufDesc *)inBufs)->planeDesc[count].buf)); |
559 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), INBUFS_INDEX, (int32_t)P2H(inBufs), | ||
560 | (int32_t)data_buf, (size_t)*data_buf); | ||
541 | } | 561 | } |
542 | } | 562 | } |
543 | 563 | ||
544 | for( count = 0; count < numOutBufs; count++, total_count++ ) { | 564 | for( count = 0; count < numOutBufs; count++, total_count++ ) { |
545 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX, (int32_t)outBufs, (int32_t)&(((XDM2_BufDesc *)outBufs)->descs[count].buf), NULL); | 565 | if(((XDM2_BufDesc *)outBufs)->descs[LUMA_BUF].buf != ((XDM2_BufDesc *)outBufs)->descs[CHROMA_BUF].buf ) { |
566 | /* MultiPlanar Buffers */ | ||
567 | data_buf = (void * *)(&(((XDM2_BufDesc *)outBufs)->descs[count].buf)); | ||
568 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX, (int32_t)P2H(outBufs), | ||
569 | (int32_t)data_buf, (size_t)*data_buf); | ||
570 | } | ||
571 | #if defined(BUILDOS_LINUX) | ||
572 | else { | ||
573 | /* SinglePlanar Buffers */ | ||
574 | data_buf = (void * *)(&(((XDM2_BufDesc *)outBufs)->descs[count].buf)); | ||
575 | Fill_MmRpc_fxnCtx_Xlt_Array(&(fxnCtx.xltAry[total_count]), OUTBUFS_INDEX, (int32_t)P2H(outBufs), | ||
576 | (int32_t)data_buf, (size_t)*data_buf); | ||
577 | if( count == CHROMA_BUF ) { | ||
578 | if(((XDM2_BufDesc *)outBufs)->descs[count].memType == XDM_MEMTYPE_RAW || | ||
579 | ((XDM2_BufDesc *)outBufs)->descs[count].memType == XDM_MEMTYPE_TILEDPAGE ) { | ||
580 | *data_buf += ((XDM2_BufDesc *)outBufs)->descs[LUMA_BUF].bufSize.bytes; | ||
581 | } else { | ||
582 | *data_buf += ((XDM2_BufDesc *)outBufs)->descs[LUMA_BUF].bufSize.tileMem.width * | ||
583 | ((XDM2_BufDesc *)outBufs)->descs[LUMA_BUF].bufSize.tileMem.height; | ||
584 | } | ||
585 | } | ||
586 | } | ||
587 | #endif | ||
546 | } | 588 | } |
547 | 589 | ||
548 | /* Invoke the Remote function through MmRpc */ | 590 | /* Invoke the Remote function through MmRpc */ |
diff --git a/memplugin.h b/memplugin.h index 49e0500..bd09a8b 100644 --- a/memplugin.h +++ b/memplugin.h | |||
@@ -56,6 +56,7 @@ | |||
56 | #define P2H(p) (&(((MemHeader *)(p))[-1])) | 56 | #define P2H(p) (&(((MemHeader *)(p))[-1])) |
57 | #define H2P(h) ((void *)&(h)[1]) | 57 | #define H2P(h) ((void *)&(h)[1]) |
58 | 58 | ||
59 | #define GetSz(buf) ((P2H(buf))->size + sizeof(MemHeader)) | ||
59 | 60 | ||
60 | /* MemHeader is important because it is necessary to know the */ | 61 | /* MemHeader is important because it is necessary to know the */ |
61 | /* size of the parameter buffers on IPU for Cache operations */ | 62 | /* size of the parameter buffers on IPU for Cache operations */ |
@@ -63,8 +64,11 @@ | |||
63 | /* For ex: static params can be VIDDEC3_Params, IVIDDEC3_Params */ | 64 | /* For ex: static params can be VIDDEC3_Params, IVIDDEC3_Params */ |
64 | /* or IH264DEC_Params */ | 65 | /* or IH264DEC_Params */ |
65 | typedef struct MemHeader { | 66 | typedef struct MemHeader { |
66 | int size; | 67 | uint32_t size; |
67 | void *ptr; | 68 | void *ptr; |
69 | #if defined(BUILDOS_LINUX) | ||
70 | int32_t dma_buf_fd; | ||
71 | #endif | ||
68 | } MemHeader; | 72 | } MemHeader; |
69 | 73 | ||
70 | 74 | ||
diff --git a/memplugin_linux.c b/memplugin_linux.c index bb99d26..47f03fc 100644 --- a/memplugin_linux.c +++ b/memplugin_linux.c | |||
@@ -45,7 +45,7 @@ extern struct omap_device *dev; | |||
45 | void *memplugin_alloc(int sz, int height, mem_type memory_type) | 45 | void *memplugin_alloc(int sz, int height, mem_type memory_type) |
46 | { | 46 | { |
47 | MemHeader *h; | 47 | MemHeader *h; |
48 | struct omap_bo *bo = omap_bo_new(dev, sz + sizeof(MemHeader), OMAP_BO_WC); | 48 | struct omap_bo *bo = omap_bo_new(dev, sz + sizeof(MemHeader), OMAP_BO_CACHED); |
49 | 49 | ||
50 | if( !bo ) { | 50 | if( !bo ) { |
51 | return (NULL); | 51 | return (NULL); |
@@ -55,6 +55,7 @@ void *memplugin_alloc(int sz, int height, mem_type memory_type) | |||
55 | memset(H2P(h), 0, sz); | 55 | memset(H2P(h), 0, sz); |
56 | h->size = sz; | 56 | h->size = sz; |
57 | h->ptr = (void *)bo; | 57 | h->ptr = (void *)bo; |
58 | h->dma_buf_fd = 0; | ||
58 | 59 | ||
59 | return (H2P(h)); | 60 | return (H2P(h)); |
60 | 61 | ||
@@ -80,7 +81,10 @@ int memplugin_share(void *ptr) | |||
80 | { | 81 | { |
81 | if( ptr ) { | 82 | if( ptr ) { |
82 | MemHeader *h = P2H(ptr); | 83 | MemHeader *h = P2H(ptr); |
83 | return (omap_bo_dmabuf((struct omap_bo *)h->ptr)); | 84 | if( !h->dma_buf_fd ) { |
85 | h->dma_buf_fd = omap_bo_dmabuf((struct omap_bo *)h->ptr); | ||
86 | } | ||
87 | return (h->dma_buf_fd); | ||
84 | } | 88 | } |
85 | return (-1); | 89 | return (-1); |
86 | } | 90 | } |