Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (c) 2010, Texas Instruments Incorporated
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *
      9  * *  Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  *
     12  * *  Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * *  Neither the name of Texas Instruments Incorporated nor the names of
     17  *    its contributors may be used to endorse or promote products derived
     18  *    from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 /**
     34  *  @file  omx_rpc_stub.c
     35  *         This file contains methods that provides the functionality for
     36  *         the OpenMAX1.1 DOMX Framework RPC Stub implementations.
     37  *
     38  *  @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\src
     39  *
     40  *  @rev 1.0
     41  */
     42 
     43 /*==============================================================
     44  *! Revision History
     45  *! ============================
     46  *! 30-Apr-2010 Abhishek Ranka : Fixed GetExtension issue
     47  *!
     48  *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation
     49  *!
     50  *! 19-August-2009 B Ravi Kiran ravi.kiran (at) ti.com: Initial Version
     51  *================================================================*/
     52 /******************************************************************
     53  *   INCLUDE FILES
     54  ******************************************************************/
     55 #include <string.h>
     56 #include <stdio.h>
     57 #include <unistd.h>
     58 
     59 #include "omx_rpc.h"
     60 #include "omx_rpc_utils.h"
     61 #include "omx_proxy_common.h"
     62 #include "omx_rpc_stub.h"
     63 #include <OMX_TI_Common.h>
     64 #include <timm_osal_interfaces.h>
     65 
     66 #include <linux/rpmsg_omx.h>
     67 #include "rpmsg_omx_defs.h"
     68 
     69 /******************************************************************
     70  *   EXTERNS
     71  ******************************************************************/
     72 
     73 /******************************************************************
     74  *   MACROS - LOCAL
     75  ******************************************************************/
     76 
     77 //#define RPC_MSGPIPE_SIZE (4)
     78 #define RPC_MSG_SIZE_FOR_PIPE (sizeof(OMX_PTR))
     79 
     80 /* When this is defined ETB/FTB calls are made in sync mode. Undefining will
     81  * result in these calls being sent via async mode. Sync mode leads to correct
     82  * functionality as per OMX spec but has a slight performance penalty. Async
     83  * mode sacrifices strict adherence to spec for some gain in performance. */
     84 #define RPC_SYNC_MODE
     85 
     86 
     87 #define RPC_getPacket(nPacketSize, pPacket) do { \
     88     pPacket = TIMM_OSAL_Malloc(nPacketSize, TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); \
     89     RPC_assert(pPacket != NULL, RPC_OMX_ErrorInsufficientResources, \
     90            "Error Allocating RCM Message Frame"); \
     91     TIMM_OSAL_Memset(pPacket, 0, nPacketSize); \
     92     } while(0)
     93 
     94 #define RPC_freePacket(pPacket) do { \
     95     if(pPacket != NULL) TIMM_OSAL_Free(pPacket); \
     96     } while(0)
     97 
     98 #define RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, nSize) do { \
     99     status = write(hCtx->fd_omx, pPacket, nPacketSize); \
    100     RPC_freePacket(pPacket); \
    101     pPacket = NULL; \
    102     if(status < 0 ) DOMX_ERROR("DOMX Write failed 0x%x %d",status,status); \
    103     RPC_assert(status >= 0, RPC_OMX_ErrorUndefined, "Write failed"); \
    104     eError = TIMM_OSAL_ReadFromPipe(hCtx->pMsgPipe[nFxnIdx], &pRetPacket, \
    105         RPC_MSG_SIZE_FOR_PIPE, (TIMM_OSAL_U32 *)(&nSize), TIMM_OSAL_SUSPEND); \
    106     RPC_assert(eError == TIMM_OSAL_ERR_NONE, eError, \
    107         "Read failed"); \
    108     } while(0)
    109 
    110 /*Set bit 31 on fxn idx as it is static function*/
    111 #define RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize) do { \
    112     pOmxPacket = (struct omx_packet *)pPacket; \
    113     pData = pOmxPacket->data; \
    114     pOmxPacket->desc |= OMX_DESC_MSG << OMX_DESC_TYPE_SHIFT; \
    115     pOmxPacket->msg_id = 0; \
    116     pOmxPacket->flags = OMX_POOLID_JOBID_DEFAULT; \
    117     pOmxPacket->fxn_idx = (nFxnIdx | 0x80000000); \
    118     pOmxPacket->result = 0; \
    119     pOmxPacket->data_size = nPacketSize; \
    120     } while(0)
    121 
    122 //Async to be checked later - most probably same as sync but without the read
    123 #if 0
    124 
    125 #define RPC_sendPacket_async(HRCM, pPacket, nFxnIdx) do { \
    126     pPacket->nFxnIdx = nFxnIdx; \
    127     status = RcmClient_execCmd(HRCM, pPacket); \
    128     if(status < 0) { \
    129     RPC_freePacket(HRCM, pPacket); \
    130     pPacket = NULL; \
    131     RPC_assert(0, RPC_OMX_RCM_ErrorExecFail, \
    132            "RcmClient_exec failed"); \
    133     } \
    134     } while(0)
    135 
    136 #define RPC_checkAsyncErrors(rcmHndl, pPacket) do { \
    137     status = RcmClient_checkForError(rcmHndl, &pPacket); \
    138     if(status < 0) { \
    139         RPC_freePacket(rcmHndl, pPacket); \
    140         pPacket = NULL; \
    141     } \
    142     RPC_assert(status >= 0, RPC_OMX_RCM_ClientFail, \
    143         "Async error check returned error"); \
    144     } while(0)
    145 
    146 #endif
    147 /* ===========================================================================*/
    148 /**
    149  * @name RPC_GetHandle()
    150  * @brief Remote invocation stub for OMX_GetHandle
    151  * @param hRPCCtx [OUT]         : The RPC context handle.
    152  * @param cComponentName [IN]   : Name of the component that is to be created
    153  *                                on Remote core.
    154  * @param pAppData [IN]         : The AppData passed by the user.
    155  * @param pCallBacks [IN]       : The callback pointers passed by the caller.
    156  * @param eCompReturn [OUT]     : This is return value returned by the remote
    157  *                                component.
    158  * @return RPC_OMX_ErrorNone = Successful
    159  */
    160 /* ===========================================================================*/
    161 RPC_OMX_ERRORTYPE RPC_GetHandle(OMX_HANDLETYPE hRPCCtx,
    162     OMX_STRING cComponentName, OMX_PTR pAppData,
    163     OMX_CALLBACKTYPE * pCallBacks, OMX_ERRORTYPE * eCompReturn)
    164 {
    165 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    166 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    167 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    168 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    169 	    NULL, pRetData = NULL;
    170 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    171 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    172 	OMX_HANDLETYPE hComp = NULL;
    173 	OMX_HANDLETYPE hActualComp = NULL;
    174 	OMX_S32 status = 0;
    175 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    176 	struct omx_packet *pOmxPacket = NULL;
    177 
    178 	DOMX_ENTER("");
    179 	DOMX_DEBUG("RPC_GetHandle: Recieved GetHandle request from %s",
    180 	    cComponentName);
    181 
    182 	nFxnIdx = RPC_OMX_FXN_IDX_GET_HANDLE;
    183 	RPC_getPacket(nPacketSize, pPacket);
    184 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    185 
    186 	DOMX_DEBUG("Packing data");
    187 	/*No buffer mapping required */
    188 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    189 	    RPC_OMX_MAP_INFO_TYPE);
    190 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    191 
    192 	RPC_SETFIELDCOPYGEN(pData, nPos, cComponentName,
    193 	    OMX_MAX_STRINGNAME_SIZE);
    194 	RPC_SETFIELDVALUE(pData, nPos, pAppData, OMX_PTR);
    195 
    196 	DOMX_DEBUG("Sending data");
    197 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    198 	    nSize);
    199 
    200 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    201 
    202 	if (*eCompReturn == OMX_ErrorNone)
    203 	{
    204 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    205 		RPC_GETFIELDVALUE(pRetData, nPos, hComp, OMX_HANDLETYPE);
    206 		DOMX_DEBUG("Remote Handle 0x%x", hComp);
    207 		hCtx->hRemoteHandle = hComp;
    208 		/* The handle received above is used for all communications
    209 		   with the remote component but is not the actual component
    210 		   handle (it is actually the rpc context handle which
    211 		   contains lot of other info). The handle recd. below is the
    212 		   actual remote component handle. This is used at present for
    213 		   mark buffer implementation since in that case it is not
    214 		   feasible to send the context handle */
    215 		RPC_GETFIELDVALUE(pRetData, nPos, hActualComp,
    216 		    OMX_HANDLETYPE);
    217 		DOMX_DEBUG("Actual Remote Comp Handle 0x%x", hActualComp);
    218 		hCtx->hActualRemoteCompHandle = hActualComp;
    219 	}
    220 
    221     /* Save context information */
    222     hCtx->pAppData = pAppData;
    223 
    224       EXIT:
    225 	if (pPacket)
    226 		RPC_freePacket(pPacket);
    227 	if (pRetPacket)
    228 		RPC_freePacket(pRetPacket);
    229 
    230 	DOMX_EXIT("");
    231 	return eRPCError;
    232 }
    233 
    234 
    235 
    236 /* ===========================================================================*/
    237 /**
    238  * @name RPC_FreeHandle()
    239  * @brief Remote invocation stub for OMX_FreeHandle
    240  * @param hRPCCtx [IN]      : The RPC context handle.
    241  * @param eCompReturn [OUT] : Return value returned by the remote component.
    242  * @return RPC_OMX_ErrorNone = Successful
    243  */
    244 /* ===========================================================================*/
    245 RPC_OMX_ERRORTYPE RPC_FreeHandle(OMX_HANDLETYPE hRPCCtx,
    246     OMX_ERRORTYPE * eCompReturn)
    247 {
    248 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    249 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    250 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    251 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
    252 	OMX_S32 status = 0;
    253 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    254 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    255 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    256 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    257 	struct omx_packet *pOmxPacket = NULL;
    258 
    259 	DOMX_ENTER("");
    260 
    261 	nFxnIdx = RPC_OMX_FXN_IDX_FREE_HANDLE;
    262 	RPC_getPacket(nPacketSize, pPacket);
    263 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    264 
    265 	/*No buffer mapping required */
    266 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    267 	    RPC_OMX_MAP_INFO_TYPE);
    268 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    269 
    270 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    271 
    272 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    273 	    nSize);
    274 
    275 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    276 
    277       EXIT:
    278 	if (pPacket)
    279 		RPC_freePacket(pPacket);
    280 	if (pRetPacket)
    281 		RPC_freePacket(pRetPacket);
    282 
    283 	DOMX_EXIT("");
    284 	return eRPCError;
    285 
    286 }
    287 
    288 
    289 
    290 /* ===========================================================================*/
    291 /**
    292  * @name RPC_SetParameter()
    293  * @brief Remote invocation stub for OMX_SetParameter
    294  * @param hRPCCtx [IN]      : The RPC context handle.
    295  * @param nParamIndex [IN]  : Same as nParamIndex received at the proxy.
    296  * @param pCompParam [IN]   : Same as pCompParam recieved at the proxy.
    297  * @param eCompReturn [OUT] : Return value returned by the remote component.
    298  * @return RPC_OMX_ErrorNone = Successful
    299  */
    300 /* ===========================================================================*/
    301 RPC_OMX_ERRORTYPE RPC_SetParameter(OMX_HANDLETYPE hRPCCtx,
    302     OMX_INDEXTYPE nParamIndex, OMX_PTR pCompParam,
    303     OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn)
    304 {
    305 
    306 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    307 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    308 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
    309 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    310 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    311 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    312 	OMX_S32 status = 0;
    313 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    314 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    315 	OMX_U32 structSize = 0;
    316 	struct omx_packet *pOmxPacket = NULL;
    317 
    318 	nFxnIdx = RPC_OMX_FXN_IDX_SET_PARAMETER;
    319 	RPC_getPacket(nPacketSize, pPacket);
    320 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    321 
    322 	if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompParam) >= 0 ) {
    323 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF,
    324 			RPC_OMX_MAP_INFO_TYPE);
    325 		nOffset = (pLocBufNeedMap - pCompParam) +
    326 			sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) +
    327 			sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE);
    328 	} else {
    329 		/*No buffer mapping required */
    330 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    331 			RPC_OMX_MAP_INFO_TYPE);
    332 	}
    333 
    334 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    335 
    336 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    337 	RPC_SETFIELDVALUE(pData, nPos, nParamIndex, OMX_INDEXTYPE);
    338 	structSize = RPC_UTIL_GETSTRUCTSIZE(pCompParam);
    339 	RPC_SETFIELDCOPYGEN(pData, nPos, pCompParam, structSize);
    340 
    341 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    342 	    nSize);
    343 
    344 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    345 
    346       EXIT:
    347 	if (pPacket)
    348 		RPC_freePacket(pPacket);
    349 	if (pRetPacket)
    350 		RPC_freePacket(pRetPacket);
    351 
    352 	DOMX_EXIT("");
    353 	return eRPCError;
    354 }
    355 
    356 
    357 
    358 /* ===========================================================================*/
    359 /**
    360  * @name RPC_GetParameter()
    361  * @brief Remote invocation stub for OMX_GetParameter
    362  * @param hRPCCtx [IN]      : The RPC context handle.
    363  * @param nParamIndex [IN]  : Same as nParamIndex received at the proxy.
    364  * @param pCompParam [IN]   : Same as pCompParam recieved at the proxy.
    365  * @param eCompReturn [OUT] : Return value returned by the remote component.
    366  * @return RPC_OMX_ErrorNone = Successful
    367  */
    368 /* ===========================================================================*/
    369 RPC_OMX_ERRORTYPE RPC_GetParameter(OMX_HANDLETYPE hRPCCtx,
    370     OMX_INDEXTYPE nParamIndex, OMX_PTR pCompParam,
    371     OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn)
    372 {
    373 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    374 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    375 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    376 	    NULL, pRetData = NULL;
    377 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    378 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    379 	OMX_U32 nPos = 0, nSize = 0, nDataOffset = 0, nOffset = 0;
    380 	OMX_S32 status = 0;
    381 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    382 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    383 	OMX_U32 structSize = 0;
    384 	struct omx_packet *pOmxPacket = NULL;
    385 
    386 	DOMX_ENTER("");
    387 
    388 	nFxnIdx = RPC_OMX_FXN_IDX_GET_PARAMETER;
    389 	RPC_getPacket(nPacketSize, pPacket);
    390 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    391 
    392 	if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompParam) >= 0 ) {
    393 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF,
    394 			RPC_OMX_MAP_INFO_TYPE);
    395 		nOffset = (pLocBufNeedMap - pCompParam) +
    396 			sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) +
    397 			sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE);
    398 	} else {
    399 		/*No buffer mapping required */
    400 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    401 			RPC_OMX_MAP_INFO_TYPE);
    402 	}
    403 
    404 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    405 
    406 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    407 	RPC_SETFIELDVALUE(pData, nPos, nParamIndex, OMX_INDEXTYPE);
    408 	nDataOffset = nPos;
    409 	structSize = RPC_UTIL_GETSTRUCTSIZE(pCompParam);
    410 	RPC_SETFIELDCOPYGEN(pData, nPos, pCompParam, structSize);
    411 
    412 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    413 	    nSize);
    414 
    415 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    416 
    417 	if (*eCompReturn == OMX_ErrorNone)
    418 	{
    419 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    420 		/*pCompParam is returned in the same location in which it was sent */
    421 		RPC_GETFIELDCOPYGEN(pRetData, nDataOffset, pCompParam,
    422 		    structSize);
    423 	}
    424 
    425       EXIT:
    426 	if (pPacket)
    427 		RPC_freePacket(pPacket);
    428 	if (pRetPacket)
    429 		RPC_freePacket(pRetPacket);
    430 
    431 	DOMX_EXIT("");
    432 	return eRPCError;
    433 }
    434 
    435 
    436 
    437 /* ===========================================================================*/
    438 /**
    439  * @name RPC_SetConfig()
    440  * @brief Remote invocation stub for OMX_SetConfig
    441  * @param hRPCCtx [IN]      : The RPC context handle.
    442  * @param nConfigIndex [IN] : Same as nConfigIndex received at the proxy.
    443  * @param pCompConfig [IN]  : Same as pCompConfig recieved at the proxy.
    444  * @param eCompReturn [OUT] : Return value returned by the remote component.
    445  * @return RPC_OMX_ErrorNone = Successful
    446  */
    447 /* ===========================================================================*/
    448 RPC_OMX_ERRORTYPE RPC_SetConfig(OMX_HANDLETYPE hRPCCtx,
    449     OMX_INDEXTYPE nConfigIndex, OMX_PTR pCompConfig,
    450     OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn)
    451 {
    452 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    453 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    454 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
    455 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    456 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    457 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    458 	OMX_S32 status = 0;
    459 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    460 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    461 	OMX_U32 structSize = 0;
    462 	struct omx_packet *pOmxPacket = NULL;
    463 
    464 	DOMX_ENTER("");
    465 
    466 	nFxnIdx = RPC_OMX_FXN_IDX_SET_CONFIG;
    467 	RPC_getPacket(nPacketSize, pPacket);
    468 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    469 
    470 	if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompConfig) >= 0 ) {
    471 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF,
    472 			RPC_OMX_MAP_INFO_TYPE);
    473 		nOffset = (pLocBufNeedMap - pCompConfig) +
    474 			sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) +
    475 			sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE);
    476 	} else {
    477 		/*No buffer mapping required */
    478 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    479 			RPC_OMX_MAP_INFO_TYPE);
    480 	}
    481 
    482 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    483 
    484 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    485 	RPC_SETFIELDVALUE(pData, nPos, nConfigIndex, OMX_INDEXTYPE);
    486 	structSize = RPC_UTIL_GETSTRUCTSIZE(pCompConfig);
    487 	RPC_SETFIELDCOPYGEN(pData, nPos, pCompConfig, structSize);
    488 
    489 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    490 	    nSize);
    491 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    492 
    493       EXIT:
    494 	if (pPacket)
    495 		RPC_freePacket(pPacket);
    496 	if (pRetPacket)
    497 		RPC_freePacket(pRetPacket);
    498 
    499 	DOMX_EXIT("");
    500 	return eRPCError;
    501 }
    502 
    503 /* ===========================================================================*/
    504 /**
    505  * @name RPC_GetConfig()
    506  * @brief Remote invocation stub for OMX_GetConfig
    507  * @param hRPCCtx [IN]      : The RPC context handle.
    508  * @param nConfigIndex [IN] : Same as nConfigIndex received at the proxy.
    509  * @param pCompConfig [IN]  : Same as pCompConfig recieved at the proxy.
    510  * @param eCompReturn [OUT] : Return value returned by the remote component.
    511  * @return RPC_OMX_ErrorNone = Successful
    512  */
    513 /* ===========================================================================*/
    514 RPC_OMX_ERRORTYPE RPC_GetConfig(OMX_HANDLETYPE hRPCCtx,
    515     OMX_INDEXTYPE nConfigIndex, OMX_PTR pCompConfig,
    516     OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn)
    517 {
    518 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    519 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    520 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    521 		NULL, pRetData = NULL;
    522 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    523 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    524 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0, nDataOffset = 0;
    525 	OMX_S32 status = 0;
    526 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    527 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    528 	OMX_U32 structSize = 0;
    529 	struct omx_packet *pOmxPacket = NULL;
    530 
    531 	DOMX_ENTER("");
    532 
    533 	nFxnIdx = RPC_OMX_FXN_IDX_GET_CONFIG;
    534 	RPC_getPacket(nPacketSize, pPacket);
    535 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    536 
    537 	if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompConfig) >= 0 ) {
    538 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF,
    539 			RPC_OMX_MAP_INFO_TYPE);
    540 		nOffset = (pLocBufNeedMap - pCompConfig) +
    541 			sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) +
    542 			sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE);
    543 	} else {
    544 		/*No buffer mapping required */
    545 		RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    546 			RPC_OMX_MAP_INFO_TYPE);
    547 	}
    548 
    549 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    550 
    551 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    552 	RPC_SETFIELDVALUE(pData, nPos, nConfigIndex, OMX_INDEXTYPE);
    553 	nDataOffset = nPos;
    554 	structSize = RPC_UTIL_GETSTRUCTSIZE(pCompConfig);
    555 	RPC_SETFIELDCOPYGEN(pData, nPos, pCompConfig, structSize);
    556 
    557 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    558 	    nSize);
    559 
    560 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    561 
    562 	if (*eCompReturn == RPC_OMX_ErrorNone)
    563 	{
    564 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    565 		/*pCompParam is returned in the same location in which it was sent */
    566 		RPC_GETFIELDCOPYGEN(pRetData, nDataOffset, pCompConfig,
    567 		    structSize);
    568 	}
    569 
    570       EXIT:
    571 	if (pPacket)
    572 		RPC_freePacket(pPacket);
    573 	if (pRetPacket)
    574 		RPC_freePacket(pRetPacket);
    575 
    576 	DOMX_EXIT("");
    577 	return eRPCError;
    578 }
    579 
    580 
    581 
    582 /* ===========================================================================*/
    583 /**
    584  * @name RPC_SendCommand()
    585  * @brief Remote invocation stub for OMX_SendCommand
    586  * @param hRPCCtx [IN]      : The RPC context handle.
    587  * @param eCmd [IN]         : Same as eCmd received at the proxy.
    588  * @param nParam [IN]       : Same as nParam recieved at the proxy.
    589  * @param pCmdData [IN]     : Same as pCmdData recieved at the proxy.
    590  * @param eCompReturn [OUT] : Return value returned by the remote component.
    591  * @return RPC_OMX_ErrorNone = Successful
    592  */
    593 /* ===========================================================================*/
    594 RPC_OMX_ERRORTYPE RPC_SendCommand(OMX_HANDLETYPE hRPCCtx,
    595     OMX_COMMANDTYPE eCmd, OMX_U32 nParam, OMX_PTR pCmdData,
    596     OMX_ERRORTYPE * eCompReturn)
    597 {
    598 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    599 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    600 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
    601 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    602 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    603 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    604 	OMX_S32 status = 0;
    605 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    606 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    607 	OMX_U32 structSize = 0;
    608 	struct omx_packet *pOmxPacket = NULL;
    609 
    610 	DOMX_ENTER("");
    611 
    612 	nFxnIdx = RPC_OMX_FXN_IDX_SEND_CMD;
    613 	RPC_getPacket(nPacketSize, pPacket);
    614 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    615 
    616 	/*No buffer mapping required */
    617 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    618 	    RPC_OMX_MAP_INFO_TYPE);
    619 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    620 
    621 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    622 	RPC_SETFIELDVALUE(pData, nPos, eCmd, OMX_COMMANDTYPE);
    623 	RPC_SETFIELDVALUE(pData, nPos, nParam, OMX_U32);
    624 
    625 	if (pCmdData != NULL && eCmd == OMX_CommandMarkBuffer)
    626 	{
    627 		/*The RPC_UTIL_GETSTRUCTSIZE will not work here since OMX_MARKTYPE structure
    628 		   does not have nSize field */
    629 		structSize = sizeof(OMX_MARKTYPE);
    630 		RPC_SETFIELDCOPYGEN(pData, nPos, pCmdData, structSize);
    631 	} else if (pCmdData != NULL)
    632 	{
    633 		structSize = RPC_UTIL_GETSTRUCTSIZE(pCmdData);
    634 		RPC_SETFIELDCOPYGEN(pData, nPos, pCmdData, structSize);
    635 	}
    636 
    637 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    638 	    nSize);
    639 
    640 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    641 
    642       EXIT:
    643 	if (pPacket)
    644 		RPC_freePacket(pPacket);
    645 	if (pRetPacket)
    646 		RPC_freePacket(pRetPacket);
    647 
    648 	DOMX_EXIT("");
    649 	return eRPCError;
    650 }
    651 
    652 
    653 
    654 /* ===========================================================================*/
    655 /**
    656  * @name RPC_GetState()
    657  * @brief Remote invocation stub for OMX_GetState
    658  * @param hRPCCtx [IN]      : The RPC context handle.
    659  * @param pState [OUT]      : State variable, to be filled in and returned by
    660  *                            the remote component..
    661  * @param eCompReturn [OUT] : Return value returned by the remote component.
    662  * @return RPC_OMX_ErrorNone = Successful
    663  */
    664 /* ===========================================================================*/
    665 RPC_OMX_ERRORTYPE RPC_GetState(OMX_HANDLETYPE hRPCCtx, OMX_STATETYPE * pState,
    666     OMX_ERRORTYPE * eCompReturn)
    667 {
    668 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    669 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    670 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    671 	    NULL, pRetData = NULL;
    672 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    673 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    674 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    675 	OMX_S32 status = 0;
    676 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    677 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    678 	struct omx_packet *pOmxPacket = NULL;
    679 
    680 	DOMX_ENTER("");
    681 
    682 	nFxnIdx = RPC_OMX_FXN_IDX_GET_STATE;
    683 	RPC_getPacket(nPacketSize, pPacket);
    684 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    685 
    686 	/*No buffer mapping required */
    687 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    688 	    RPC_OMX_MAP_INFO_TYPE);
    689 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    690 
    691 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    692 
    693 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    694 	    nSize);
    695 
    696 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    697 
    698 	if (*eCompReturn == OMX_ErrorNone)
    699 	{
    700 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    701 		RPC_GETFIELDCOPYTYPE(pRetData, nPos, pState, OMX_STATETYPE);
    702 	}
    703 
    704       EXIT:
    705 	if (pPacket)
    706 		RPC_freePacket(pPacket);
    707 	if (pRetPacket)
    708 		RPC_freePacket(pRetPacket);
    709 
    710 	DOMX_EXIT("");
    711 	return eRPCError;
    712 }
    713 
    714 
    715 
    716 /* ===========================================================================*/
    717 /**
    718  * @name RPC_GetComponentVersion()
    719  * @brief Remote invocation stub for OMX_GetComponentVersion
    720  * @param hRPCCtx [IN]            : The RPC context handle.
    721  * @param pComponentName [OUT]    : Component name, to be filled in and returned
    722  *                                  by the remote component.
    723  * @param pComponentVersion [OUT] : Component version info, to be filled in and
    724  *                                  returned by the remote component.
    725  * @param pSpecVersion [OUT]      : Spec version info, to be filled in and
    726  *                                  returned by the remote component.
    727  * @param pComponentUUID [OUT]    : Component UUID info, to be filled in and
    728  *                                  returned by the remote component (optional).
    729  * @param eCompReturn [OUT]       : Return value returned by the remote
    730  *                                  component.
    731  * @return RPC_OMX_ErrorNone = Successful
    732  */
    733 /* ===========================================================================*/
    734 RPC_OMX_ERRORTYPE RPC_GetComponentVersion(OMX_HANDLETYPE hRPCCtx,
    735     OMX_STRING pComponentName, OMX_VERSIONTYPE * pComponentVersion,
    736     OMX_VERSIONTYPE * pSpecVersion, OMX_UUIDTYPE * pComponentUUID,
    737     OMX_ERRORTYPE * eCompReturn)
    738 {
    739 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    740 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    741 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    742 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    743 	    NULL, pRetData = NULL;
    744 	OMX_S32 status = 0;
    745 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    746 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    747 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    748 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    749 	struct omx_packet *pOmxPacket = NULL;
    750 
    751 	DOMX_ENTER("");
    752 
    753 	nFxnIdx = RPC_OMX_FXN_IDX_GET_VERSION;
    754 	RPC_getPacket(nPacketSize, pPacket);
    755 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    756 
    757 	/*No buffer mapping required */
    758 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    759 	    RPC_OMX_MAP_INFO_TYPE);
    760 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    761 
    762 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    763 
    764 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    765 	    nSize);
    766 
    767 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    768 
    769 	if (*eCompReturn == OMX_ErrorNone)
    770 	{
    771 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    772 		RPC_GETFIELDCOPYGEN(pRetData, nPos, pComponentName,
    773 		    OMX_MAX_STRINGNAME_SIZE);
    774 		RPC_GETFIELDCOPYTYPE(pRetData, nPos, pComponentVersion,
    775 		    OMX_VERSIONTYPE);
    776 		RPC_GETFIELDCOPYTYPE(pRetData, nPos, pSpecVersion,
    777 		    OMX_VERSIONTYPE);
    778 		//RPC_GETFIELDCOPYTYPE(pRetData, nPos, pComponentUUID, OMX_UUIDTYPE);
    779 	}
    780 
    781       EXIT:
    782 	if (pPacket)
    783 		RPC_freePacket(pPacket);
    784 	if (pRetPacket)
    785 		RPC_freePacket(pRetPacket);
    786 
    787 	return eRPCError;
    788 }
    789 
    790 
    791 
    792 /* ===========================================================================*/
    793 /**
    794  * @name RPC_GetExtensionIndex()
    795  * @brief Remote invocation stub for OMX_GetExtensionIndex
    796  * @param hRPCCtx [IN]        : The RPC context handle.
    797  * @param cParameterName [IN] : The parameter name sent by the user.
    798  * @param pIndexType [OUT]    : Index type returned by the remote component.
    799  * @param eCompReturn [OUT]   : Return value returned by the remote component.
    800  * @return RPC_OMX_ErrorNone = Successful
    801  */
    802 /* ===========================================================================*/
    803 RPC_OMX_ERRORTYPE RPC_GetExtensionIndex(OMX_HANDLETYPE hRPCCtx,
    804     OMX_STRING cParameterName, OMX_INDEXTYPE * pIndexType,
    805     OMX_ERRORTYPE * eCompReturn)
    806 {
    807 
    808 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    809 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    810 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    811 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    812 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    813 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    814 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    815 	    NULL, pRetData = NULL;
    816 	OMX_S32 status = 0;
    817 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    818 	struct omx_packet *pOmxPacket = NULL;
    819 
    820 	nFxnIdx = RPC_OMX_FXN_IDX_GET_EXT_INDEX;
    821 
    822 	RPC_getPacket(nPacketSize, pPacket);
    823 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    824 
    825 	/*No buffer mapping required */
    826 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    827 	    RPC_OMX_MAP_INFO_TYPE);
    828 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    829 
    830 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    831 	RPC_SETFIELDCOPYGEN(pData, nPos, cParameterName,
    832 	    OMX_MAX_STRINGNAME_SIZE);
    833 
    834 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    835 	    nSize);
    836 
    837 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    838 
    839 	if (*eCompReturn == OMX_ErrorNone)
    840 	{
    841 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    842 		RPC_GETFIELDCOPYTYPE(pRetData, nPos, pIndexType,
    843 		    OMX_INDEXTYPE);
    844 	}
    845 
    846       EXIT:
    847 	if (pPacket)
    848 		RPC_freePacket(pPacket);
    849 	if (pRetPacket)
    850 		RPC_freePacket(pRetPacket);
    851 
    852 	return eRPCError;
    853 
    854 }
    855 
    856 /* ***************************** DATA APIs ******************************** */
    857 
    858 /* ===========================================================================*/
    859 /**
    860  * @name RPC_AllocateBuffer()
    861  * @brief Remote invocation stub for OMX_AllcateBuffer()
    862  * @param size   : Size of the incoming RCM message (parameter used in the RCM alloc call)
    863  * @param *data  : Pointer to the RCM message/buffer received
    864  * @return RPC_OMX_ErrorNone = Successful
    865  * @sa TBD
    866  *
    867  */
    868 /* ===========================================================================*/
    869 RPC_OMX_ERRORTYPE RPC_AllocateBuffer(OMX_HANDLETYPE hRPCCtx,
    870     OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_IN OMX_U32 nPortIndex,
    871     OMX_U32 * pBufHeaderRemote, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes,
    872     OMX_ERRORTYPE * eCompReturn)
    873 {
    874 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
    875 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
    876 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
    877 	    NULL, pRetData = NULL;
    878 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
    879 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
    880 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
    881 	OMX_S32 status = 0;
    882 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
    883 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
    884 	OMX_TI_PLATFORMPRIVATE *pPlatformPrivate = NULL;
    885 	OMX_BUFFERHEADERTYPE *pBufferHdr = *ppBufferHdr;
    886 	struct omx_packet *pOmxPacket = NULL;
    887 
    888 	DOMX_ENTER("");
    889 
    890 	nFxnIdx = RPC_OMX_FXN_IDX_ALLOCATE_BUFFER;
    891 	RPC_getPacket(nPacketSize, pPacket);
    892 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
    893 
    894 	/*No buffer mapping required */
    895 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
    896 	    RPC_OMX_MAP_INFO_TYPE);
    897 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
    898 
    899 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
    900 	RPC_SETFIELDVALUE(pData, nPos, nPortIndex, OMX_U32);
    901 	RPC_SETFIELDVALUE(pData, nPos, pAppPrivate, OMX_PTR);
    902 	RPC_SETFIELDVALUE(pData, nPos, nSizeBytes, OMX_U32);
    903 
    904 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
    905 	    nSize);
    906 
    907 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
    908 
    909 	if (*eCompReturn == OMX_ErrorNone)
    910 	{
    911 		pRetData = ((struct omx_packet *) pRetPacket)->data;
    912 		RPC_GETFIELDVALUE(pRetData, nPos, *pBufHeaderRemote, OMX_U32);
    913 		//save platform private before overwriting
    914 		pPlatformPrivate = (*ppBufferHdr)->pPlatformPrivate;
    915 		//RPC_GETFIELDCOPYTYPE(pData, nPos, pBufferHdr, OMX_BUFFERHEADERTYPE);
    916 		/*Copying each field of the header separately due to padding issues in
    917 		   the buffer header structure */
    918 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nSize, OMX_U32);
    919 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nVersion,
    920 		    OMX_VERSIONTYPE);
    921 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pBuffer,
    922 		    OMX_U8 *);
    923 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nAllocLen,
    924 		    OMX_U32);
    925 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFilledLen,
    926 		    OMX_U32);
    927 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nOffset,
    928 		    OMX_U32);
    929 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pAppPrivate,
    930 		    OMX_PTR);
    931 		RPC_GETFIELDVALUE(pRetData, nPos,
    932 		    pBufferHdr->pPlatformPrivate, OMX_PTR);
    933 		RPC_GETFIELDVALUE(pRetData, nPos,
    934 		    pBufferHdr->pInputPortPrivate, OMX_PTR);
    935 		RPC_GETFIELDVALUE(pRetData, nPos,
    936 		    pBufferHdr->pOutputPortPrivate, OMX_PTR);
    937 		RPC_GETFIELDVALUE(pRetData, nPos,
    938 		    pBufferHdr->hMarkTargetComponent, OMX_HANDLETYPE);
    939 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pMarkData,
    940 		    OMX_PTR);
    941 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTickCount,
    942 		    OMX_U32);
    943 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTimeStamp,
    944 		    OMX_TICKS);
    945 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFlags,
    946 		    OMX_U32);
    947 		RPC_GETFIELDVALUE(pRetData, nPos,
    948 		    pBufferHdr->nInputPortIndex, OMX_U32);
    949 		RPC_GETFIELDVALUE(pRetData, nPos,
    950 		    pBufferHdr->nOutputPortIndex, OMX_U32);
    951 
    952 		(*ppBufferHdr)->pPlatformPrivate = pPlatformPrivate;
    953 
    954 #ifdef TILER_BUFF
    955 		DOMX_DEBUG(" Copying plat pvt. ");
    956 		//if (offset != 0)
    957 		{
    958 			RPC_GETFIELDCOPYTYPE(pRetData, nPos,
    959 			    (OMX_TI_PLATFORMPRIVATE
    960 				*) ((*ppBufferHdr)->pPlatformPrivate),
    961 			    OMX_TI_PLATFORMPRIVATE);
    962 			DOMX_DEBUG("Done copying plat pvt., aux buf = 0x%x",
    963 			    ((OMX_TI_PLATFORMPRIVATE
    964 				    *) ((*ppBufferHdr)->pPlatformPrivate))->
    965 			    pAuxBuf1);
    966 		}
    967 #endif
    968 
    969 	} else
    970 	{
    971 		//DOMX_DEBUG("OMX Error received: 0x%x",
    972 		//  pRPCMsg->msgHeader.nOMXReturn);
    973 	}
    974 
    975       EXIT:
    976 	if (pPacket)
    977 		RPC_freePacket(pPacket);
    978 	if (pRetPacket)
    979 		RPC_freePacket(pRetPacket);
    980 
    981 	DOMX_EXIT("");
    982 	return eRPCError;
    983 }
    984 
    985 /* ===========================================================================*/
    986 /**
    987  * @name RPC_UseBuffer()
    988  * @brief Remote invocation stub for OMX_AllcateBuffer()
    989  * @param hComp: This is the handle on the Remote core, the proxy will replace
    990                  it's handle with actual OMX Component handle that recides on the specified core
    991  * @param ppBufferHdr:
    992  * @param nPortIndex:
    993  * @param pAppPrivate:
    994  * @param eCompReturn: This is return value that will be supplied by Proxy to the caller.
    995  *                    This is actual return value returned by the Remote component
    996  * @return RPC_OMX_ErrorNone = Successful
    997  * @sa TBD
    998  *
    999  */
   1000 /* ===========================================================================*/
   1001 RPC_OMX_ERRORTYPE RPC_UseBuffer(OMX_HANDLETYPE hRPCCtx,
   1002     OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_U32 nPortIndex,
   1003     OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, OMX_U8 * pBuffer,
   1004     OMX_U32 * pBufHeaderRemote, OMX_ERRORTYPE * eCompReturn)
   1005 {
   1006 
   1007 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
   1008 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
   1009 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData =
   1010 	    NULL, pRetData = NULL;
   1011 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
   1012 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
   1013 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
   1014 	OMX_S32 status = 0;
   1015 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
   1016 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
   1017 	OMX_TI_PLATFORMPRIVATE *pPlatformPrivate = NULL;
   1018 	OMX_BUFFERHEADERTYPE *pBufferHdr = *ppBufferHdr;
   1019 	struct omx_packet *pOmxPacket = NULL;
   1020 	RPC_OMX_MAP_INFO_TYPE eMapInfo = RPC_OMX_MAP_INFO_NONE;
   1021 	OMX_PTR pMetaDataBuffer = NULL;
   1022 	OMX_U32 a =32;
   1023 
   1024 	DOMX_ENTER("");
   1025 
   1026 	nFxnIdx = RPC_OMX_FXN_IDX_USE_BUFFER;
   1027 	RPC_getPacket(nPacketSize, pPacket);
   1028 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
   1029 
   1030 	DOMX_DEBUG("Marshaling data");
   1031 	/*Buffer mapping required */
   1032 	eMapInfo = RPC_OMX_MAP_INFO_ONE_BUF;
   1033 	if (((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->
   1034 	    pAuxBuf1 != NULL)
   1035 		eMapInfo = RPC_OMX_MAP_INFO_TWO_BUF;
   1036 	if (((OMX_TI_PLATFORMPRIVATE *)pBufferHdr->pPlatformPrivate)->
   1037 	    pMetaDataBuffer != NULL)
   1038 		eMapInfo = RPC_OMX_MAP_INFO_THREE_BUF;
   1039 
   1040 	/*Offset is the location of the buffer pointer from the start of the data packet */
   1041 	nOffset =
   1042 	    sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) +
   1043 	    sizeof(OMX_HANDLETYPE) + sizeof(OMX_U32) + sizeof(OMX_PTR) +
   1044 	    sizeof(OMX_U32);
   1045 	RPC_SETFIELDVALUE(pData, nPos, eMapInfo, RPC_OMX_MAP_INFO_TYPE);
   1046 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
   1047 
   1048 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
   1049 	RPC_SETFIELDVALUE(pData, nPos, nPortIndex, OMX_U32);
   1050 	RPC_SETFIELDVALUE(pData, nPos, pAppPrivate, OMX_PTR);
   1051 	RPC_SETFIELDVALUE(pData, nPos, nSizeBytes, OMX_U32);
   1052 
   1053 	RPC_SETFIELDVALUE(pData, nPos, pBuffer, OMX_U32);
   1054 	DOMX_DEBUG("eMapInfo = %x",eMapInfo);
   1055 	if (eMapInfo >= RPC_OMX_MAP_INFO_TWO_BUF)
   1056 	{
   1057 		RPC_SETFIELDVALUE(pData, nPos,
   1058 		    ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->
   1059 			pPlatformPrivate)->pAuxBuf1, OMX_U32);
   1060 		DOMX_DEBUG("UV buffer fd= %d",((OMX_TI_PLATFORMPRIVATE *)pBufferHdr->pPlatformPrivate)->pAuxBuf1);
   1061 	}
   1062 
   1063 	if (eMapInfo >= RPC_OMX_MAP_INFO_THREE_BUF)
   1064 	{
   1065 		RPC_SETFIELDVALUE(pData, nPos,
   1066 		    ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->
   1067 			pPlatformPrivate)->pMetaDataBuffer, OMX_U32);
   1068 		DOMX_DEBUG("Metadata buffer = %d",((OMX_TI_PLATFORMPRIVATE *)pBufferHdr->pPlatformPrivate)->pMetaDataBuffer);
   1069 	}
   1070 
   1071 	DOMX_DEBUG("About to send packet");
   1072 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
   1073 	    nSize);
   1074 	DOMX_DEBUG("Remote call returned");
   1075 
   1076 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
   1077 
   1078 	if (*eCompReturn == OMX_ErrorNone)
   1079 	{
   1080 		pRetData = ((struct omx_packet *) pRetPacket)->data;
   1081 		RPC_GETFIELDVALUE(pRetData, nPos, *pBufHeaderRemote, OMX_U32);
   1082 		//save platform private before overwriting
   1083 		pPlatformPrivate = (*ppBufferHdr)->pPlatformPrivate;
   1084 
   1085 		/*Copying each field of the header separately due to padding issues in
   1086 		   the buffer header structure */
   1087 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nSize, OMX_U32);
   1088 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nVersion,
   1089 		    OMX_VERSIONTYPE);
   1090 		/*
   1091 		   Do not expect buffer pointer - local buffer pointer is already
   1092 		   present in the local header.
   1093 		   RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pBuffer,
   1094 		   OMX_U8 *);
   1095 		 */
   1096 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nAllocLen,
   1097 		    OMX_U32);
   1098 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFilledLen,
   1099 		    OMX_U32);
   1100 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nOffset,
   1101 		    OMX_U32);
   1102 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pAppPrivate,
   1103 		    OMX_PTR);
   1104 		//Do not expect PlatformPrivate from Ducati
   1105 		//RPC_GETFIELDVALUE(pRetData, nPos,pBufferHdr->pPlatformPrivate, OMX_PTR);
   1106 		RPC_GETFIELDVALUE(pRetData, nPos,
   1107 		    pBufferHdr->pInputPortPrivate, OMX_PTR);
   1108 		RPC_GETFIELDVALUE(pRetData, nPos,
   1109 		    pBufferHdr->pOutputPortPrivate, OMX_PTR);
   1110 		RPC_GETFIELDVALUE(pRetData, nPos,
   1111 		    pBufferHdr->hMarkTargetComponent, OMX_HANDLETYPE);
   1112 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pMarkData,
   1113 		    OMX_PTR);
   1114 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTickCount,
   1115 		    OMX_U32);
   1116 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTimeStamp,
   1117 		    OMX_TICKS);
   1118 		RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFlags,
   1119 		    OMX_U32);
   1120 		RPC_GETFIELDVALUE(pRetData, nPos,
   1121 		    pBufferHdr->nInputPortIndex, OMX_U32);
   1122 		RPC_GETFIELDVALUE(pRetData, nPos,
   1123 		    pBufferHdr->nOutputPortIndex, OMX_U32);
   1124 
   1125 		//Do not expect PlatformPrivate from Ducati
   1126 		/*
   1127 		(*ppBufferHdr)->pPlatformPrivate = pPlatformPrivate;
   1128 
   1129 		DOMX_DEBUG(" Copying plat pvt. ");
   1130 		RPC_GETFIELDCOPYTYPE(pRetData, nPos,
   1131 		    (OMX_TI_PLATFORMPRIVATE *) ((*ppBufferHdr)->
   1132 			pPlatformPrivate), OMX_TI_PLATFORMPRIVATE);*/
   1133 
   1134 		/*Resetting size as it might be diff on Ducati due to padding issues */
   1135 		pBufferHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE);
   1136 	}
   1137 
   1138       EXIT:
   1139 	if (pPacket)
   1140 		RPC_freePacket(pPacket);
   1141 	if (pRetPacket)
   1142 		RPC_freePacket(pRetPacket);
   1143 
   1144 	DOMX_EXIT("");
   1145 	return eRPCError;
   1146 }
   1147 
   1148 /* ===========================================================================*/
   1149 /**
   1150  * @name RPC_FreeBuffer()
   1151  * @brief Remote invocation stub for OMX_AllcateBuffer()
   1152  * @param size   : Size of the incoming RCM message (parameter used in the RCM alloc call)
   1153  * @param *data  : Pointer to the RCM message/buffer received
   1154  * @return RPC_OMX_ErrorNone = Successful
   1155  * @sa TBD
   1156  *
   1157  */
   1158 /* ===========================================================================*/
   1159 RPC_OMX_ERRORTYPE RPC_FreeBuffer(OMX_HANDLETYPE hRPCCtx,
   1160     OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_U32 BufHdrRemote, OMX_U32 pBuffer,
   1161     OMX_ERRORTYPE * eCompReturn)
   1162 {
   1163 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
   1164 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
   1165 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
   1166 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
   1167 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
   1168 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
   1169 	OMX_S32 status = 0;
   1170 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
   1171 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
   1172 	struct omx_packet *pOmxPacket = NULL;
   1173 
   1174 	DOMX_ENTER("");
   1175 
   1176 	nFxnIdx = RPC_OMX_FXN_IDX_FREE_BUFFER;
   1177 	RPC_getPacket(nPacketSize, pPacket);
   1178 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
   1179 
   1180 	/*No buffer mapping required */
   1181 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
   1182 	    RPC_OMX_MAP_INFO_TYPE);
   1183 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
   1184 
   1185 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
   1186 	RPC_SETFIELDVALUE(pData, nPos, nPortIndex, OMX_U32);
   1187 	RPC_SETFIELDVALUE(pData, nPos, BufHdrRemote, OMX_U32);
   1188 	/* Buffer is being sent separately only to catch NULL buffer errors
   1189 	   in PA mode */
   1190 	RPC_SETFIELDVALUE(pData, nPos, pBuffer, OMX_U32);
   1191 
   1192 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
   1193 	    nSize);
   1194 
   1195 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
   1196 
   1197       EXIT:
   1198 	if (pPacket)
   1199 		RPC_freePacket(pPacket);
   1200 	if (pRetPacket)
   1201 		RPC_freePacket(pRetPacket);
   1202 
   1203 	DOMX_EXIT("");
   1204 	return eRPCError;
   1205 }
   1206 
   1207 
   1208 /* ===========================================================================*/
   1209 /**
   1210  * @name RPC_EmptyThisBuffer()
   1211  * @brief
   1212  * @param size   : Size of the incoming RCM message (parameter used in the RCM alloc call)
   1213  * @param *data  : Pointer to the RCM message/buffer received
   1214  * @return RPC_OMX_ErrorNone = Successful
   1215  * @sa TBD
   1216  *
   1217  */
   1218 /* ===========================================================================*/
   1219 
   1220 RPC_OMX_ERRORTYPE RPC_EmptyThisBuffer(OMX_HANDLETYPE hRPCCtx,
   1221     OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 BufHdrRemote,
   1222     OMX_ERRORTYPE * eCompReturn, OMX_BOOL bMapBuffer)
   1223 {
   1224 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
   1225 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
   1226 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
   1227 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
   1228 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
   1229 	OMX_S32 status = 0;
   1230 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
   1231 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
   1232 	OMX_U8 *pAuxBuf1 = NULL;
   1233 	struct omx_packet *pOmxPacket = NULL;
   1234 	RPC_OMX_MAP_INFO_TYPE eMapInfo = RPC_OMX_MAP_INFO_NONE;
   1235 #ifdef RPC_SYNC_MODE
   1236 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
   1237 #endif
   1238 
   1239 	DOMX_ENTER("");
   1240 
   1241 	nFxnIdx = RPC_OMX_FXN_IDX_EMPTYTHISBUFFER;
   1242 	RPC_getPacket(nPacketSize, pPacket);
   1243 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
   1244 
   1245 	if(bMapBuffer == OMX_TRUE)
   1246 	{
   1247 		pAuxBuf1 = ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1;
   1248 		/*Buffer mapping required */
   1249 		if (((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 == NULL)
   1250 			eMapInfo = RPC_OMX_MAP_INFO_ONE_BUF;
   1251 		else
   1252 			eMapInfo = RPC_OMX_MAP_INFO_TWO_BUF;
   1253 		/*Offset is the location of the buffer pointer from the start of the data packet */
   1254 		nOffset =
   1255 	    		sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) +
   1256 	   		sizeof(OMX_HANDLETYPE) + sizeof(OMX_BUFFERHEADERTYPE *) + 3*sizeof(OMX_U32) +
   1257 			sizeof(OMX_TICKS) + sizeof(OMX_HANDLETYPE) + sizeof(OMX_PTR) + 3*sizeof(OMX_U32);
   1258 	}
   1259 
   1260 	RPC_SETFIELDVALUE(pData, nPos, eMapInfo, RPC_OMX_MAP_INFO_TYPE);
   1261 
   1262 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
   1263 
   1264 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
   1265 	RPC_SETFIELDVALUE(pData, nPos,
   1266 	    (OMX_BUFFERHEADERTYPE *) BufHdrRemote, OMX_BUFFERHEADERTYPE *);
   1267 
   1268 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFilledLen, OMX_U32);
   1269 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOffset, OMX_U32);
   1270 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFlags, OMX_U32);
   1271 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nTimeStamp, OMX_TICKS);
   1272 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->hMarkTargetComponent,
   1273 	    OMX_HANDLETYPE);
   1274 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->pMarkData, OMX_PTR);
   1275 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nAllocLen, OMX_U32);
   1276 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOutputPortIndex, OMX_U32);
   1277 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nInputPortIndex, OMX_U32);
   1278 
   1279 	if(bMapBuffer == OMX_TRUE)
   1280 	{
   1281 		RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->pBuffer, OMX_U32);
   1282 		if (eMapInfo == RPC_OMX_MAP_INFO_TWO_BUF)
   1283 		{
   1284 			RPC_SETFIELDVALUE(pData, nPos,
   1285 			    ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1, OMX_U32);
   1286 		}
   1287 	}
   1288 
   1289 	DOMX_DEBUG(" pBufferHdr = %x BufHdrRemote %x", pBufferHdr,
   1290 	    BufHdrRemote);
   1291 
   1292 #ifdef RPC_SYNC_MODE
   1293 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
   1294 	    nSize);
   1295 
   1296 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
   1297 #else
   1298 	RPC_sendPacket_async(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket,
   1299 	    nFxnIdx);
   1300 	RPC_checkAsyncErrors(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket);
   1301 
   1302 	*eCompReturn = OMX_ErrorNone;
   1303 #endif
   1304 
   1305       EXIT:
   1306 	if (pPacket)
   1307 		RPC_freePacket(pPacket);
   1308 	if (pRetPacket)
   1309 		RPC_freePacket(pRetPacket);
   1310 
   1311 	DOMX_EXIT("");
   1312 	return eRPCError;
   1313 }
   1314 
   1315 
   1316 /* ===========================================================================*/
   1317 /**
   1318  * @name RPC_FillThisBuffer()
   1319  * @brief Remote invocation stub for OMX_AllcateBuffer()
   1320  * @param size   : Size of the incoming RCM message (parameter used in the RCM alloc call)
   1321  * @param *data  : Pointer to the RCM message/buffer received
   1322  * @return RPC_OMX_ErrorNone = Successful
   1323  * @sa TBD
   1324  *
   1325  */
   1326 /* ===========================================================================*/
   1327 RPC_OMX_ERRORTYPE RPC_FillThisBuffer(OMX_HANDLETYPE hRPCCtx,
   1328     OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 BufHdrRemote,
   1329     OMX_ERRORTYPE * eCompReturn)
   1330 {
   1331 	RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;
   1332 	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;
   1333 	OMX_U32 nPacketSize = RPC_PACKET_SIZE;
   1334 	RPC_OMX_FXN_IDX_TYPE nFxnIdx;
   1335 	OMX_U32 nPos = 0, nSize = 0, nOffset = 0;
   1336 	OMX_S32 status = 0;
   1337 	RPC_OMX_CONTEXT *hCtx = hRPCCtx;
   1338 	OMX_HANDLETYPE hComp = hCtx->hRemoteHandle;
   1339 	OMX_U8 *pAuxBuf1 = NULL;
   1340 	struct omx_packet *pOmxPacket = NULL;
   1341 #ifdef RPC_SYNC_MODE
   1342 	TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL;
   1343 #endif
   1344 
   1345 	DOMX_ENTER("");
   1346 
   1347 	nFxnIdx = RPC_OMX_FXN_IDX_FILLTHISBUFFER;
   1348 	RPC_getPacket(nPacketSize, pPacket);
   1349 	RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize);
   1350 
   1351 	/*No buffer mapping required */
   1352 	RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE,
   1353 	    RPC_OMX_MAP_INFO_TYPE);
   1354 	RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32);
   1355 
   1356 	RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE);
   1357 	RPC_SETFIELDVALUE(pData, nPos,
   1358 	    (OMX_BUFFERHEADERTYPE *) BufHdrRemote, OMX_BUFFERHEADERTYPE *);
   1359 
   1360 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFilledLen, OMX_U32);
   1361 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOffset, OMX_U32);
   1362 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFlags, OMX_U32);
   1363 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nAllocLen, OMX_U32);
   1364 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOutputPortIndex, OMX_U32);
   1365 	RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nInputPortIndex, OMX_U32);
   1366 
   1367 	DOMX_DEBUG(" pBufferHdr = %x BufHdrRemote %x", pBufferHdr,
   1368 	    BufHdrRemote);
   1369 
   1370 #ifdef RPC_SYNC_MODE
   1371 	RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket,
   1372 	    nSize);
   1373 
   1374 	*eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result);
   1375 
   1376 #else
   1377 	RPC_sendPacket_async(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket,
   1378 	    nFxnIdx);
   1379 	RPC_checkAsyncErrors(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket);
   1380 
   1381 	*eCompReturn = OMX_ErrorNone;
   1382 #endif
   1383 
   1384       EXIT:
   1385 	if (pPacket)
   1386 		RPC_freePacket(pPacket);
   1387 	if (pRetPacket)
   1388 		RPC_freePacket(pRetPacket);
   1389 
   1390 	DOMX_EXIT("");
   1391 	return eRPCError;
   1392 }
   1393 
   1394 
   1395 /* ***************************** EMPTY APIs ******************************** */
   1396 
   1397 /* ===========================================================================*/
   1398 /**
   1399  * @name EMPTY-STUB
   1400  * @brief
   1401  * @param
   1402  * @return
   1403  *
   1404  */
   1405 /* ===========================================================================*/
   1406 OMX_ERRORTYPE RPC_EventHandler(OMX_HANDLETYPE hRPCCtx, OMX_PTR pAppData,
   1407     OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData)
   1408 {
   1409 	return RPC_OMX_ErrorNone;
   1410 }
   1411 
   1412 OMX_ERRORTYPE RPC_EmptyBufferDone(OMX_HANDLETYPE hRPCCtx, OMX_PTR pAppData,
   1413     OMX_BUFFERHEADERTYPE * pBuffer)
   1414 {
   1415 	return RPC_OMX_ErrorNone;
   1416 }
   1417 
   1418 OMX_ERRORTYPE RPC_FillBufferDone(OMX_HANDLETYPE hRPCCtx, OMX_PTR pAppData,
   1419     OMX_BUFFERHEADERTYPE * pBuffer)
   1420 {
   1421 	return RPC_OMX_ErrorNone;
   1422 }
   1423 
   1424 RPC_OMX_ERRORTYPE RPC_ComponentTunnelRequest(OMX_HANDLETYPE hRPCCtx,
   1425     OMX_IN OMX_U32 nPort, OMX_HANDLETYPE hTunneledhRemoteHandle,
   1426     OMX_U32 nTunneledPort, OMX_INOUT OMX_TUNNELSETUPTYPE * pTunnelSetup,
   1427     OMX_ERRORTYPE * nCmdStatus)
   1428 {
   1429 	return RPC_OMX_ErrorNone;
   1430 }
   1431