static OMX_ERRORTYPE OMX_ConfigureDynamicPFramesInH264E( OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 nCurrentFrameRate, OMX_U32 nTargetFrameRate) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_U32 remainder = 0; OMX_U16 nTargetPFrames =0; /* Target Pframes to be provided to Encoder */ OMX_U16 nCurrentPFrames = 0; /* Current pFrame Value configured to Encoder */ OMX_VIDEO_CONFIG_AVCINTRAPERIOD tPframeH264e; OMX_VIDEO_PARAM_AVCTYPE h264type; OMX_COMPONENTTYPE *pHandle; if (hComponent == NULL){ DOMX_ERROR("Component is invalid/ not present "); return OMX_ErrorBadParameter; } pHandle = (OMX_COMPONENTTYPE *) hComponent; /* Initialise the OMX structures */ OMX_INIT_STRUCT(tPframeH264e, OMX_VIDEO_CONFIG_AVCINTRAPERIOD); OMX_INIT_STRUCT(h264type,OMX_VIDEO_PARAM_AVCTYPE); /* Read number of B Frames if not read yet */ if(!nBFrames){ h264type.nPortIndex = 1; eError = pHandle->GetParameter(hComponent,OMX_IndexParamVideoAvc,&h264type); if(eError != OMX_ErrorNone) { DOMX_ERROR(" Error while reading component info = %d",eError); return eError; } nBFrames = h264type.nBFrames; } /* Read Current pFrames set in Encoder */ tPframeH264e.nPortIndex = 1; eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoAVCIntraPeriod,&tPframeH264e); if(eError != OMX_ErrorNone) { DOMX_ERROR(" Error while Getting PFrame info, Error code = %d",eError); return eError; } nCurrentPFrames = tPframeH264e.nPFrames; /* Calculate Target P Frames */ nTargetPFrames = (nCurrentPFrames * nTargetFrameRate) /nCurrentFrameRate; /* Number of pFrames should be multiple of (B FRAMES + 1) */ remainder = nTargetPFrames % (nBFrames + 1); nTargetPFrames = nTargetPFrames - remainder; if(nTargetPFrames == nCurrentPFrames){ DOMX_INFO(" No Change in P Frames, No Update required"); return OMX_ErrorNone; } /* Update the new PFrames to the Encoder */ tPframeH264e.nPFrames = nTargetPFrames; eError = pHandle->SetConfig(hComponent,OMX_IndexConfigVideoAVCIntraPeriod,&tPframeH264e); if(eError != OMX_ErrorNone) { DOMX_ERROR(" Error while setting PFrame info, Error code = %d",eError); } return eError; }
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_ERRORTYPE dcc_eError = OMX_ErrorNone; OMX_COMPONENTTYPE *pHandle = NULL; PROXY_COMPONENT_PRIVATE *pComponentPrivate; OMX_U32 i = 0, j = 0; OMX_PROXY_CAM_PRIVATE* pCamPrv; MEMPLUGIN_ERRORTYPE eMemError = MEMPLUGIN_ERROR_NONE; pHandle = (OMX_COMPONENTTYPE *) hComponent; TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; DOMX_ENTER("_____________________INSIDE CAMERA PROXY" "WRAPPER__________________________\n"); pHandle->pComponentPrivate = (PROXY_COMPONENT_PRIVATE *) TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); pComponentPrivate = (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; if (pHandle->pComponentPrivate == NULL) { DOMX_ERROR(" ERROR IN ALLOCATING PROXY COMPONENT" "PRIVATE STRUCTURE"); eError = OMX_ErrorInsufficientResources; goto EXIT; } TIMM_OSAL_Memset(pComponentPrivate, 0, sizeof(PROXY_COMPONENT_PRIVATE)); pComponentPrivate->cCompName = TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); /*Copying component Name - this will be picked up in the proxy common */ assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH); TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, strlen(COMPONENT_NAME) + 1); pComponentPrivate->pCompProxyPrv = (OMX_PROXY_CAM_PRIVATE *) TIMM_OSAL_Malloc(sizeof(OMX_PROXY_CAM_PRIVATE), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); PROXY_assert(pComponentPrivate->pCompProxyPrv != NULL, OMX_ErrorInsufficientResources, "Could not allocate memory for proxy component private data structure"); pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pComponentPrivate->pCompProxyPrv; TIMM_OSAL_Memset(pComponentPrivate->pCompProxyPrv, 0, sizeof(OMX_PROXY_CAM_PRIVATE)); pComponentPrivate->bMapBuffers = OMX_TRUE; /*Calling Proxy Common Init() */ eError = OMX_ProxyCommonInit(hComponent); if (eError != OMX_ErrorNone) { DOMX_ERROR("\Error in Initializing Proxy"); TIMM_OSAL_Free(pComponentPrivate->cCompName); TIMM_OSAL_Free(pComponentPrivate); TIMM_OSAL_Free(pComponentPrivate->pCompProxyPrv); goto EXIT; }
static OMX_ERRORTYPE CameraSetParam(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE eError = OMX_ErrorNone; PROXY_COMPONENT_PRIVATE *pCompPrv; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *)hComponent; pCompPrv = (PROXY_COMPONENT_PRIVATE *)hComp->pComponentPrivate; switch (nParamIndex) { case OMX_TI_IndexParamComponentBufferAllocation: eError = GLUE_CameraSetParam(hComponent, nParamIndex, pComponentParameterStructure); goto EXIT; break; default: break; } eError = __PROXY_SetParameter(hComponent, nParamIndex, pComponentParameterStructure, NULL, 0); EXIT: if (eError != OMX_ErrorNone) { DOMX_ERROR(" CameraSetParam: Error in SetParam 0x%x", eError); } return eError; }
MEMPLUGIN_ERRORTYPE MemPlugin_ION_Open(void *pMemPluginHandle,OMX_U32 *pClient) { MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE; OMX_U32 memClient = 0; memClient = ion_open(); if(memClient == 0) { DOMX_ERROR("ion open failed"); eError = MEMPLUGIN_ERROR_UNDEFINED; goto EXIT; } else { *pClient = memClient; } EXIT: if(eError != MEMPLUGIN_ERROR_NONE) { DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError); } else { DOMX_EXIT("%s: executed successfully",__FUNCTION__); } return eError; }
MEMPLUGIN_ERRORTYPE MemPlugin_ION_Init(void **pMemPluginHandle) { MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE; MEMPLUGIN_OBJECT *pMemPluginHdl; pMemPluginHdl = TIMM_OSAL_MallocExtn(sizeof(MEMPLUGIN_OBJECT), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT, NULL); if(pMemPluginHdl == NULL) { eError = MEMPLUGIN_ERROR_NORESOURCES; DOMX_ERROR("%s: allocation failed",__FUNCTION__); goto EXIT; } TIMM_OSAL_Memset(pMemPluginHdl, 0, sizeof(MEMPLUGIN_OBJECT)); pMemPluginHdl->fpOpen = MemPlugin_ION_Open; pMemPluginHdl->fpClose = MemPlugin_ION_Close; pMemPluginHdl->fpConfig = MemPlugin_ION_Configure; pMemPluginHdl->fpAlloc = MemPlugin_ION_Alloc; pMemPluginHdl->fpFree = MemPlugin_ION_Free; pMemPluginHdl->fpDeInit = MemPlugin_ION_DeInit; *pMemPluginHandle = pMemPluginHdl; EXIT: if(eError != MEMPLUGIN_ERROR_NONE) { DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError); } else { DOMX_EXIT("%s: executed successfully",__FUNCTION__); } return eError; }
/* ===========================================================================*/ OMX_ERRORTYPE OMX_CameraVtcFreeMemory(OMX_IN OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE eError = OMX_ErrorNone; PROXY_COMPONENT_PRIVATE *pCompPrv; OMX_PROXY_CAM_PRIVATE* pCamPrv; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; OMX_U32 i = 0; RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; MEMPLUGIN_BUFFER_PARAMS delBuffer_params; MEMPLUGIN_BUFFER_PROPERTIES delBuffer_prop; pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pCompPrv->pCompProxyPrv; MEMPLUGIN_BUFFER_PARAMS_INIT(delBuffer_params); for(i=0; i < MAX_NUM_INTERNAL_BUFFERS; i++) { if (pCamPrv->sInternalBuffers[i][0].pBufferHandle != NULL) { eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pCamPrv->sInternalBuffers[i][0].pRegBufferHandle, NULL , IONPointers); if (eRPCError != RPC_OMX_ErrorNone) { DOMX_ERROR("%s: DOMX: Unexpected error occurred while Unregistering Y Buffer#%d: eRPCError = 0x%x", __func__, i, eRPCError); } delBuffer_prop.sBuffer_accessor.pBufferHandle = pCamPrv->sInternalBuffers[i][0].pBufferHandle; MemPlugin_Free(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&delBuffer_params,&delBuffer_prop); pCamPrv->sInternalBuffers[i][0].pRegBufferHandle = NULL; pCamPrv->sInternalBuffers[i][0].pBufferHandle = NULL; DOMX_DEBUG("%s: DOMX: #%d Y Memory freed; eRPCError = 0x%x", __func__, i, eRPCError); } if (pCamPrv->sInternalBuffers[i][1].pBufferHandle != NULL) { eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pCamPrv->sInternalBuffers[i][1].pRegBufferHandle, NULL , IONPointers); if (eRPCError != RPC_OMX_ErrorNone) { DOMX_ERROR("%s: DOMX: Unexpected error occurred while Unregistering UV Buffer#%d: eRPCError = 0x%x", __func__, i, eRPCError); } delBuffer_prop.sBuffer_accessor.pBufferHandle = pCamPrv->sInternalBuffers[i][1].pBufferHandle; MemPlugin_Free(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&delBuffer_params,&delBuffer_prop); pCamPrv->sInternalBuffers[i][1].pRegBufferHandle = NULL; pCamPrv->sInternalBuffers[i][1].pBufferHandle = NULL; DOMX_DEBUG("%s: DOMX: #%d UV Memory freed; eRPCError = 0x%x", __func__, i, eRPCError); } } EXIT: DOMX_EXIT("eError: %d", eError); return eError; }
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_ERRORTYPE dcc_eError = OMX_ErrorNone; OMX_COMPONENTTYPE *pHandle = NULL; PROXY_COMPONENT_PRIVATE *pComponentPrivate; pHandle = (OMX_COMPONENTTYPE *) hComponent; TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; DOMX_ENTER("_____________________INSIDE CAMERA PROXY" "WRAPPER__________________________\n"); pHandle->pComponentPrivate = (PROXY_COMPONENT_PRIVATE *) TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); pComponentPrivate = (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; if (pHandle->pComponentPrivate == NULL) { DOMX_ERROR(" ERROR IN ALLOCATING PROXY COMPONENT" "PRIVATE STRUCTURE"); eError = OMX_ErrorInsufficientResources; goto EXIT; } pComponentPrivate->cCompName = TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); /*Copying component Name - this will be picked up in the proxy common */ assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH); TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, strlen(COMPONENT_NAME) + 1); /*Calling Proxy Common Init() */ eError = OMX_ProxyCommonInit(hComponent); if (eError != OMX_ErrorNone) { DOMX_ERROR("\Error in Initializing Proxy"); TIMM_OSAL_Free(pComponentPrivate->cCompName); TIMM_OSAL_Free(pComponentPrivate); goto EXIT; }
static OMX_ERRORTYPE OMX_ConfigureDynamicFrameRate( OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_STRING hCompName) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_U32 nTargetFrameRate = 0; /* Target Frame Rate to be provided to Encoder */ OMX_U32 nCurrentFrameRate = 0; /* Current Frame Rate currently set in Encoder */ OMX_CONFIG_FRAMERATETYPE tFrameRate; OMX_COMPONENTTYPE *pHandle; if (hComponent == NULL){ DOMX_ERROR("Component is invalid/ not present "); return OMX_ErrorBadParameter; } pHandle = (OMX_COMPONENTTYPE *) hComponent; /* Initialise the OMX structures */ OMX_INIT_STRUCT(tFrameRate,OMX_CONFIG_FRAMERATETYPE); /* Intialise nLastFrameRateUpdateTime for the 1st frame */ if((!nFrameCounter) && (!nLastFrameRateUpdateTime)){ nLastFrameRateUpdateTime = pBufferHdr-> nTimeStamp; } /* Increment the Frame Counter and Calculate Frame Rate*/ nFrameCounter++; nVideoTime = pBufferHdr->nTimeStamp - nLastFrameRateUpdateTime; if(nVideoTime < 0) { return OMX_ErrorBadParameter; } /*Get Port Frame Rate if not read yet*/ if(!nFrameRateThreshold) { tFrameRate.nPortIndex = 1; /* Output Port Index */ /* Read Current FrameRate */ eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoFramerate,&tFrameRate); nFrameRateThreshold = tFrameRate.xEncodeFramerate >>16; nPortFrameRate = nFrameRateThreshold; DOMX_INFO(" Port Frame Rate is %d ", nPortFrameRate); }
static OMX_ERRORTYPE Camera_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_COMMANDTYPE eCmd, OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData) { OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn; static OMX_BOOL dcc_loaded = OMX_FALSE; OMX_ERRORTYPE dcc_eError = OMX_ErrorNone; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; PROXY_COMPONENT_PRIVATE *pCompPrv; OMX_PROXY_CAM_PRIVATE *pCamPrv; MEMPLUGIN_BUFFER_PARAMS delBuffer_params; MEMPLUGIN_BUFFER_PROPERTIES delBuffer_prop; pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pCompPrv->pCompProxyPrv; MEMPLUGIN_BUFFER_PARAMS_INIT(delBuffer_params); if ((eCmd == OMX_CommandStateSet) && (nParam == (OMX_STATETYPE) OMX_StateIdle)) { /* Allocate memory for Video VTC usecase, if applicable. */ eError = _OMX_CameraVtcAllocateMemory(hComponent); if (eError != OMX_ErrorNone) { DOMX_ERROR("DOMX: _OMX_CameraVtcAllocateMemory completed with error 0x%x\n", eError); goto EXIT; } if (!dcc_loaded) { dcc_eError = DCC_Init(hComponent); if (dcc_eError != OMX_ErrorNone) { DOMX_ERROR(" Error in DCC Init"); } /* Configure Ducati to use DCC buffer from A9 side *ONLY* if DCC_Init is successful. */ if (dcc_eError == OMX_ErrorNone) { dcc_eError = send_DCCBufPtr(hComponent); if (dcc_eError != OMX_ErrorNone) { DOMX_ERROR(" Error in Sending DCC Buf ptr"); } DCC_DeInit(hComponent); } dcc_loaded = OMX_TRUE; } } else if (eCmd == OMX_CommandPortDisable) { int i, j; for (i = 0; i < PROXY_MAXNUMOFPORTS; i++) { if ((i == nParam) || (nParam == OMX_ALL)) { for (j = 0; j < MAX_NUM_INTERNAL_BUFFERS; j++) { if (pCamPrv->gComponentBufferAllocation[i][j]) { delBuffer_prop.sBuffer_accessor.pBufferHandle = pCamPrv->gComponentBufferAllocation[i][j]; MemPlugin_Free(pCompPrv->pMemPluginHandle, pCompPrv->nMemmgrClientDesc, &delBuffer_params,&delBuffer_prop); pCamPrv->gComponentBufferAllocation[i][j] = NULL; } } } } } if ((eCmd == OMX_CommandStateSet) && (nParam == (OMX_STATETYPE) OMX_StateLoaded)) { /* Clean up resources for Video VTC usecase. */ OMX_CameraVtcFreeMemory(hComponent); } eError = PROXY_SendCommand(hComponent,eCmd,nParam,pCmdData); EXIT: DOMX_EXIT("eError: %d", eError); return eError; }
/* ===========================================================================*/ static OMX_ERRORTYPE _OMX_CameraVtcAllocateMemory(OMX_IN OMX_HANDLETYPE hComponent) { OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; OMX_STATETYPE tState= OMX_StateInvalid; PROXY_COMPONENT_PRIVATE *pCompPrv; OMX_PROXY_CAM_PRIVATE* pCamPrv; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; OMX_U32 i = 0; OMX_CONFIG_RECTTYPE tFrameDim; OMX_U32 nFrmWidth, nFrmHeight; OMX_TI_PARAM_VTCSLICE tVtcConfig; RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pCompPrv->pCompProxyPrv; _PROXY_OMX_INIT_PARAM(&tFrameDim, OMX_CONFIG_RECTTYPE); _PROXY_OMX_INIT_PARAM(&tVtcConfig, OMX_TI_PARAM_VTCSLICE); /* Get the current state of the component */ eError = OMX_GetState(hComponent, &tState); if(OMX_ErrorNone != eError) { DOMX_ERROR("%s: Error in fetching current state - %d", __func__, tState); } else { if (tState == OMX_StateLoaded) { DOMX_DEBUG("%s: Current state returned is %d", __func__, tState); if(OMX_GetParameter(hComponent, OMX_TI_IndexParamVtcSlice, &tVtcConfig) == OMX_ErrorNone) { if (tVtcConfig.nSliceHeight != 0 ) { OMX_CONFIG_BOOLEANTYPE tVstabParam; OMX_PARAM_VIDEONOISEFILTERTYPE tVnfParam; OMX_TI_PARAM_VTCSLICE *pVtcConfig = &tVtcConfig; tFrameDim.nPortIndex = PREVIEW_PORT; //Preview Port if(OMX_GetParameter(hComponent, OMX_TI_IndexParam2DBufferAllocDimension, &tFrameDim) == OMX_ErrorNone){ DOMX_DEBUG("Acquired OMX_TI_IndexParam2DBufferAllocDimension data. nWidth = %d, nHeight = %d.\n\n", tFrameDim.nWidth, tFrameDim.nHeight); nFrmWidth = tFrameDim.nWidth; nFrmHeight = tFrameDim.nHeight; }else { DOMX_DEBUG("%s: No OMX_TI_IndexParam2DBufferAllocDimension data.\n\n", __func__); nFrmWidth = MAX_VTC_WIDTH_WITH_VNF; nFrmHeight = MAX_VTC_HEIGHT_WITH_VNF; } _PROXY_OMX_INIT_PARAM(&tVnfParam, OMX_PARAM_VIDEONOISEFILTERTYPE); _PROXY_OMX_INIT_PARAM(&tVstabParam, OMX_CONFIG_BOOLEANTYPE); eError = OMX_GetParameter(hComponent, OMX_IndexParamFrameStabilisation, &tVstabParam); if(eError != OMX_ErrorNone) { DOMX_ERROR("OMX_GetParameter for OMX_IndexParamFrameStabilisation returned error %x", eError); goto EXIT; } tVnfParam.nPortIndex = PREVIEW_PORT; eError = OMX_GetParameter(hComponent, OMX_IndexParamVideoNoiseFilter, &tVnfParam); if(eError != OMX_ErrorNone) { DOMX_ERROR("OMX_GetParameter for OMX_IndexParamVideoNoiseFilter returned error %x", eError); goto EXIT; } DOMX_DEBUG(" Acquired OMX_TI_IndexParamVtcSlice data. nSliceHeight = %d, bVstabOn = %d, Vnfmode = %d, nWidth = %d, nHeight = %d.\n\n", tVtcConfig.nSliceHeight, tVstabParam.bEnabled, tVnfParam.eMode, nFrmWidth, nFrmHeight); if (tVstabParam.bEnabled == OMX_FALSE && tVnfParam.eMode != OMX_VideoNoiseFilterModeOff) { eError = GLUE_CameraVtcAllocateMemory(hComponent, pVtcConfig, nFrmWidth, nFrmHeight); if(eError != OMX_ErrorNone) { DOMX_ERROR("Allocate Memory for vtc config returned error %x", eError); goto EXIT; } } } } } } EXIT: DOMX_EXIT("eError: %d", eError); return eError; }
MEMPLUGIN_ERRORTYPE MemPlugin_ION_Alloc(void *pMemPluginHandle, OMX_U32 nClient, MEMPLUGIN_BUFFER_PARAMS *pIonBufferParams, MEMPLUGIN_BUFFER_PROPERTIES *pIonBufferProp) { OMX_S16 ret; struct ion_handle *temp; size_t stride; MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE; MEMPLUGIN_ION_PARAMS sIonParams; MEMPLUGIN_OBJECT *pMemPluginHdl = (MEMPLUGIN_OBJECT *)pMemPluginHandle; if(pIonBufferParams->nWidth <= 0) { eError = MEMPLUGIN_ERROR_BADPARAMETER; DOMX_ERROR("%s: width should be positive %d", __FUNCTION__,pIonBufferParams->nWidth); goto EXIT; } if(pMemPluginHdl->pPluginExtendedInfo == NULL) { MEMPLUGIN_ION_PARAMS_INIT(&sIonParams); } else { MEMPLUGIN_ION_PARAMS_COPY(((MEMPLUGIN_ION_PARAMS *)pMemPluginHdl->pPluginExtendedInfo),sIonParams); } if(pIonBufferParams->eBuffer_type == DEFAULT) { ret = (OMX_S16)ion_alloc(nClient, pIonBufferParams->nWidth, sIonParams.nAlign, sIonParams.alloc_flags, &temp); if(ret || (int)temp == -ENOMEM) { if(sIonParams.alloc_flags != OMAP_ION_HEAP_SECURE_INPUT) { //for non default types of allocation - no retry with tiler 1d - throw error //STARGO: ducati secure heap is too small, need to allocate from heap #if 0 DOMX_ERROR("FAILED to allocate secure buffer of size=%d. ret=0x%x",pIonBufferParams->nWidth, ret); eError = MEMPLUGIN_ERROR_NORESOURCES; goto EXIT; #endif DOMX_ERROR("FAILED to allocate secure buffer of size=%d. ret=0x%x - trying tiler 1d space",pIonBufferParams->nWidth, ret); pIonBufferParams->eBuffer_type = TILER1D; pIonBufferParams->eTiler_format = MEMPLUGIN_TILER_FORMAT_PAGE; sIonParams.alloc_flags = OMAP_ION_HEAP_TILER_MASK; sIonParams.nAlign = -1; } else { // for default non tiler (OMAP_ION_HEAP_SECURE_INPUT) retry allocating from tiler 1D DOMX_DEBUG("FAILED to allocate from non tiler space - trying tiler 1d space"); pIonBufferParams->eBuffer_type = TILER1D; pIonBufferParams->eTiler_format = MEMPLUGIN_TILER_FORMAT_PAGE; sIonParams.alloc_flags = OMAP_ION_HEAP_TILER_MASK; sIonParams.nAlign = -1; } } } if(pIonBufferParams->eBuffer_type == TILER1D) { ret = (OMX_S16)ion_alloc_tiler(nClient, pIonBufferParams->nWidth, pIonBufferParams->nHeight, pIonBufferParams->eTiler_format, sIonParams.alloc_flags, &temp, &(pIonBufferProp->nStride)); if (ret || ((int)temp == -ENOMEM)) { DOMX_ERROR("FAILED to allocate buffer of size=%d. ret=0x%x",pIonBufferParams->nWidth, ret); eError = MEMPLUGIN_ERROR_NORESOURCES; goto EXIT; } } else if(pIonBufferParams->eBuffer_type == TILER2D) { DOMX_ERROR("Tiler 2D not implemented"); eError = MEMPLUGIN_ERROR_NOTIMPLEMENTED; goto EXIT; } else if(!temp) { DOMX_ERROR("Undefined option for buffer type"); eError = MEMPLUGIN_ERROR_UNDEFINED; goto EXIT; } pIonBufferProp->sBuffer_accessor.pBufferHandle = (OMX_PTR)temp; pIonBufferProp->nStride = stride; if(pIonBufferParams->bMap == OMX_TRUE) { ret = (OMX_S16) ion_map(nClient, pIonBufferProp->sBuffer_accessor.pBufferHandle, pIonBufferParams->nWidth*pIonBufferParams->nHeight, sIonParams.prot, sIonParams.map_flags, sIonParams.nOffset, (unsigned char **) &(pIonBufferProp->sBuffer_accessor.pBufferMappedAddress), &(pIonBufferProp->sBuffer_accessor.bufferFd)); if(ret < 0) { DOMX_ERROR("userspace mapping of ION buffers returned error"); eError = MEMPLUGIN_ERROR_NORESOURCES; goto EXIT; } } else { ret = (OMX_S16) ion_share(nClient, pIonBufferProp->sBuffer_accessor.pBufferHandle, &(pIonBufferProp->sBuffer_accessor.bufferFd)); if(ret < 0) { DOMX_ERROR("ION share returned error"); eError = MEMPLUGIN_ERROR_NORESOURCES; goto EXIT; } } EXIT: if (eError != MEMPLUGIN_ERROR_NONE) { DOMX_EXIT("%s exited with error 0x%x",__FUNCTION__,eError); return eError; } else { DOMX_EXIT("%s executed successfully",__FUNCTION__); return MEMPLUGIN_ERROR_NONE; } }
OMX_ERRORTYPE GLUE_CameraSetParam(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure) { OMX_ERRORTYPE eError = OMX_ErrorNone; MEMPLUGIN_ERRORTYPE eMemError = MEMPLUGIN_ERROR_NONE; MEMPLUGIN_BUFFER_PARAMS newBuffer_params,delBuffer_params; MEMPLUGIN_BUFFER_PROPERTIES newBuffer_prop,delBuffer_prop; OMX_S32 ret = 0; PROXY_COMPONENT_PRIVATE *pCompPrv; OMX_PROXY_CAM_PRIVATE* pCamPrv; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *)hComponent; OMX_U32 stride_Y = 0; OMX_TI_PARAM_COMPONENTBUFALLOCTYPE *bufferalloc = NULL; int size = 0; MEMPLUGIN_ION_PARAMS *pIonParams; MEMPLUGIN_OBJECT *pMemPluginHdl; DOMX_ENTER("%s: ENTERING",__FUNCTION__); pCompPrv = (PROXY_COMPONENT_PRIVATE *)hComp->pComponentPrivate; pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pCompPrv->pCompProxyPrv; pMemPluginHdl = ((MEMPLUGIN_OBJECT *)pCompPrv->pMemPluginHandle); pIonParams = ((MEMPLUGIN_ION_PARAMS *)pMemPluginHdl->pPluginExtendedInfo); MEMPLUGIN_BUFFER_PARAMS_INIT(newBuffer_params); MEMPLUGIN_BUFFER_PARAMS_INIT(delBuffer_params); switch (nParamIndex) { case OMX_TI_IndexParamComponentBufferAllocation: { OMX_U32 port = 0, index = 0; int fd; bufferalloc = (OMX_TI_PARAM_COMPONENTBUFALLOCTYPE *) pComponentParameterStructure; port = bufferalloc->nPortIndex; index = bufferalloc->nIndex; newBuffer_params.nWidth = bufferalloc->nAllocWidth * bufferalloc->nAllocLines; newBuffer_params.eBuffer_type = TILER1D; newBuffer_params.eTiler_format = MEMPLUGIN_TILER_FORMAT_PAGE; if(pIonParams == NULL) { pIonParams = TIMM_OSAL_MallocExtn(sizeof(MEMPLUGIN_ION_PARAMS), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT, NULL); if(pIonParams == NULL) { DOMX_ERROR("%s:Error allocating pPluginExtendedInfo",__FUNCTION__); goto EXIT; } pMemPluginHdl->pPluginExtendedInfo = pIonParams; } MEMPLUGIN_ION_PARAMS_INIT(pIonParams); //override alloc_flags for tiler 1d non secure pIonParams->alloc_flags = OMAP_ION_HEAP_TILER_MASK; eMemError = MemPlugin_Alloc(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&newBuffer_params,&newBuffer_prop); if(eMemError != MEMPLUGIN_ERROR_NONE) { DOMX_ERROR("%s:allocation failed size: %d",newBuffer_params.nWidth*newBuffer_params.nHeight); eError = OMX_ErrorInsufficientResources; goto EXIT; } bufferalloc->pBuf[0] = (OMX_PTR)newBuffer_prop.sBuffer_accessor.bufferFd; eError = __PROXY_SetParameter(hComponent, OMX_TI_IndexParamComponentBufferAllocation, bufferalloc, &bufferalloc->pBuf[0], 1); if (eError != OMX_ErrorNone) { MemPlugin_Free(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc, &newBuffer_params,&newBuffer_prop); } else { if (pCamPrv->gComponentBufferAllocation[port][index]) { delBuffer_prop.sBuffer_accessor.pBufferHandle = pCamPrv->gComponentBufferAllocation[port][index]; MemPlugin_Free(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&delBuffer_params,&delBuffer_prop); } pCamPrv->gComponentBufferAllocation[port][index] = newBuffer_prop.sBuffer_accessor.pBufferHandle; } close (newBuffer_prop.sBuffer_accessor.bufferFd); newBuffer_prop.sBuffer_accessor.bufferFd = -1; } goto EXIT; break; default: break; } EXIT: pMemPluginHdl->pPluginExtendedInfo = NULL; if (eError != OMX_ErrorNone) { DOMX_ERROR("%s: Error 0x%x",__FUNCTION__, eError); } return eError; }
OMX_ERRORTYPE GLUE_CameraVtcAllocateMemory(OMX_IN OMX_HANDLETYPE hComponent, OMX_TI_PARAM_VTCSLICE *pVtcConfig, OMX_U32 nFrmWidth, OMX_U32 nFrmHeight) { OMX_U32 i; OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; PROXY_COMPONENT_PRIVATE *pCompPrv; OMX_PROXY_CAM_PRIVATE* pCamPrv; OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; MEMPLUGIN_BUFFER_PARAMS newBuffer_params,delBuffer_params; MEMPLUGIN_BUFFER_PROPERTIES newBuffer_prop,delBuffer_prop; RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; MEMPLUGIN_ERRORTYPE eMemError = MEMPLUGIN_ERROR_NONE; MEMPLUGIN_ION_PARAMS *pIonParams; MEMPLUGIN_OBJECT *pMemPluginHdl; pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pCompPrv->pCompProxyPrv; pMemPluginHdl = ((MEMPLUGIN_OBJECT *)pCompPrv->pMemPluginHandle); pIonParams = ((MEMPLUGIN_ION_PARAMS *)pMemPluginHdl->pPluginExtendedInfo); MEMPLUGIN_BUFFER_PARAMS_INIT(newBuffer_params); MEMPLUGIN_BUFFER_PARAMS_INIT(delBuffer_params); for(i=0; i < MAX_NUM_INTERNAL_BUFFERS; i++) { pVtcConfig->nInternalBuffers = i; newBuffer_params.nWidth = nFrmWidth; newBuffer_params.nHeight = nFrmHeight; newBuffer_params.eBuffer_type = TILER1D; newBuffer_params.eTiler_format = MEMPLUGIN_TILER_FORMAT_8BIT; if(pIonParams == NULL) { pIonParams = TIMM_OSAL_MallocExtn(sizeof(MEMPLUGIN_ION_PARAMS), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT, NULL); if(pIonParams == NULL) { DOMX_ERROR("%s:Error allocating pPluginExtendedInfo",__FUNCTION__); goto EXIT; } pMemPluginHdl->pPluginExtendedInfo = pIonParams; } MEMPLUGIN_ION_PARAMS_INIT(pIonParams); //override alloc_flags for tiler 1d non secure pIonParams->alloc_flags = OMAP_ION_HEAP_TILER_MASK; eMemError = MemPlugin_Alloc(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&newBuffer_params,&newBuffer_prop); if(eMemError != MEMPLUGIN_ERROR_NONE) { DOMX_ERROR("%s:allocation failed size: %d",newBuffer_params.nWidth*newBuffer_params.nHeight); eError = OMX_ErrorInsufficientResources; goto EXIT; } eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, newBuffer_prop.sBuffer_accessor.bufferFd, -1, &pCamPrv->sInternalBuffers[i][0].pRegBufferHandle, NULL, IONPointers); PROXY_checkRpcError(); pVtcConfig->IonBufhdl[0] = (OMX_PTR)pCamPrv->sInternalBuffers[i][0].pRegBufferHandle; pCamPrv->sInternalBuffers[i][0].pBufferHandle = newBuffer_prop.sBuffer_accessor.pBufferHandle; close (newBuffer_prop.sBuffer_accessor.bufferFd); newBuffer_prop.sBuffer_accessor.bufferFd = -1; DOMX_DEBUG(" DOMX: ION Buffer#%d: Y: 0x%x, eError = 0x%x, eRPCError = 0x%x\n", i, pVtcConfig->IonBufhdl[0], eError, eRPCError); MEMPLUGIN_BUFFER_PARAMS_INIT(newBuffer_params); newBuffer_params.nWidth = nFrmWidth/2; newBuffer_params.nHeight = nFrmHeight/2; newBuffer_params.eBuffer_type = TILER1D; newBuffer_params.eTiler_format = MEMPLUGIN_TILER_FORMAT_16BIT; pIonParams->alloc_flags = OMAP_ION_HEAP_TILER_MASK; eMemError = MemPlugin_Alloc(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&newBuffer_params,&newBuffer_prop); if(eMemError != MEMPLUGIN_ERROR_NONE) { DOMX_ERROR("%s:allocation failed size: %d",newBuffer_params.nWidth*newBuffer_params.nHeight); eError = OMX_ErrorInsufficientResources; if (pCamPrv->sInternalBuffers[i][0].pRegBufferHandle != NULL) { eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pCamPrv->sInternalBuffers[i][0].pRegBufferHandle, NULL , IONPointers); PROXY_checkRpcError(); } MEMPLUGIN_BUFFER_PARAMS_INIT(delBuffer_params); delBuffer_prop.sBuffer_accessor.pBufferHandle = pCamPrv->sInternalBuffers[i][0].pBufferHandle; MemPlugin_Free(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&delBuffer_params,&delBuffer_prop ); pCamPrv->sInternalBuffers[i][0].pBufferHandle = NULL; goto EXIT; } eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, newBuffer_prop.sBuffer_accessor.bufferFd,-1, &pCamPrv->sInternalBuffers[i][1].pRegBufferHandle, NULL, IONPointers); PROXY_checkRpcError(); pVtcConfig->IonBufhdl[1] = pCamPrv->sInternalBuffers[i][1].pRegBufferHandle; pCamPrv->sInternalBuffers[i][1].pBufferHandle = newBuffer_prop.sBuffer_accessor.pBufferHandle; close (newBuffer_prop.sBuffer_accessor.bufferFd); DOMX_DEBUG("DOMX: ION Buffer#%d: UV: 0x%x, eError: 0x%x eRPCError: 0x%x\n", i, pVtcConfig->IonBufhdl[1],eError,eRPCError); eError = __PROXY_SetParameter(hComponent, OMX_TI_IndexParamVtcSlice, pVtcConfig, pVtcConfig->IonBufhdl, 2); if (eError != OMX_ErrorNone) { DOMX_ERROR("DOMX: PROXY_SetParameter for OMX_TI_IndexParamVtcSlice completed with error 0x%x\n", eError); OMX_CameraVtcFreeMemory(hComponent); goto EXIT; } } EXIT: pMemPluginHdl->pPluginExtendedInfo = NULL; if (eError != OMX_ErrorNone) { DOMX_ERROR("%s: Error 0x%x",__FUNCTION__, eError); } return eError; }