From 9d7f3c9550db35b835be9ca679befbca171c0333 Mon Sep 17 00:00:00 2001 From: SeungBeom Kim Date: Mon, 30 Mar 2015 18:12:37 +0200 Subject: [PATCH] osal: Fix OSAL lock anb type casting Backported-from: hardware/samsung_slsi/exynos5 Change-Id: Ifc8cfeaa247be26bc673fc51ef501f81ed8dc8f7 Signed-off-by: Andreas Schneider --- component/video/dec/Exynos_OMX_Vdec.c | 4 +- component/video/dec/Exynos_OMX_VdecControl.c | 8 ++-- component/video/enc/Exynos_OMX_Venc.c | 6 ++- component/video/enc/Exynos_OMX_VencControl.c | 6 +-- osal/Exynos_OSAL_Android.cpp | 46 +++----------------- osal/Exynos_OSAL_Android.h | 10 +---- 6 files changed, 21 insertions(+), 59 deletions(-) diff --git a/component/video/dec/Exynos_OMX_Vdec.c b/component/video/dec/Exynos_OMX_Vdec.c index cb32d85..154f814 100644 --- a/component/video/dec/Exynos_OMX_Vdec.c +++ b/component/video/dec/Exynos_OMX_Vdec.c @@ -375,7 +375,7 @@ OMX_BOOL Exynos_CSC_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA #ifdef USE_ANB if (exynosOutputPort->bIsANBEnabled == OMX_TRUE) { - Exynos_OSAL_LockANB(pOutputBuf, nImageWidth, nImageHeight, eColorFormat, &stride, planes); + Exynos_OSAL_LockANBHandle(pOutputBuf, nImageWidth, nImageHeight, eColorFormat, &stride, planes); nImageWidth = stride; outputUseBuffer->dataLen = sizeof(void *); @@ -489,7 +489,7 @@ OMX_BOOL Exynos_CSC_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA #ifdef USE_ANB if (exynosOutputPort->bIsANBEnabled == OMX_TRUE) { - Exynos_OSAL_UnlockANB(pOutputBuf); + Exynos_OSAL_UnlockANBHandle(pOutputBuf); } #endif diff --git a/component/video/dec/Exynos_OMX_VdecControl.c b/component/video/dec/Exynos_OMX_VdecControl.c index c29666f..d2b2647 100644 --- a/component/video/dec/Exynos_OMX_VdecControl.c +++ b/component/video/dec/Exynos_OMX_VdecControl.c @@ -474,7 +474,7 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 por } else if (portIndex == OUTPUT_PORT_INDEX) { #ifdef USE_ANB if (pExynosPort->bIsANBEnabled == OMX_TRUE) - Exynos_OSAL_UnlockANB(pExynosPort->processData.bufferHeader->pBuffer); + Exynos_OSAL_UnlockANBHandle((OMX_U32)pExynosPort->processData.bufferHeader->pBuffer); #endif Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader); } @@ -487,7 +487,7 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 por if (portIndex == OUTPUT_PORT_INDEX) { #ifdef USE_ANB if (pExynosPort->bIsANBEnabled == OMX_TRUE) - Exynos_OSAL_UnlockANB(pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer); + Exynos_OSAL_UnlockANBHandle((OMX_U32)pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer); #endif Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader); } else if (portIndex == INPUT_PORT_INDEX) { @@ -1625,7 +1625,7 @@ OMX_ERRORTYPE Exynos_Shared_ANBBufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, E if ((pUseBuffer->bufferHeader != NULL) && (pUseBuffer->bufferHeader->pBuffer != NULL) && (pExynosPort->exceptionFlag == GENERAL_STATE)) { - Exynos_OSAL_LockANB(pUseBuffer->bufferHeader->pBuffer, width, height, pExynosPort->portDefinition.format.video.eColorFormat, &stride, planes); + Exynos_OSAL_LockANBHandle(pUseBuffer->bufferHeader->pBuffer, width, height, pExynosPort->portDefinition.format.video.eColorFormat, &stride, planes); pUseBuffer->dataLen = sizeof(void *); } else { ret = OMX_ErrorBadParameter; @@ -1684,7 +1684,7 @@ OMX_ERRORTYPE Exynos_Shared_DataToANBBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_D } if (pExynosPort->bIsANBEnabled == OMX_TRUE) { - Exynos_OSAL_UnlockANB(pUseBuffer->bufferHeader->pBuffer); + Exynos_OSAL_UnlockANBHandle((OMX_U32)pUseBuffer->bufferHeader->pBuffer); } else { Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); ret = OMX_ErrorBadParameter; diff --git a/component/video/enc/Exynos_OMX_Venc.c b/component/video/enc/Exynos_OMX_Venc.c index 919a8b4..66f6a32 100644 --- a/component/video/enc/Exynos_OMX_Venc.c +++ b/component/video/enc/Exynos_OMX_Venc.c @@ -322,6 +322,7 @@ OMX_BOOL Exynos_CSC_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA /* kMetadataBufferTypeGrallocSource */ /* ARGB8888 converted to YUV420SemiPlanar */ ExynosVideoPlane planes[MAX_BUFFER_PLANE]; + OMX_U32 stride; csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_Format32bitARGB8888); csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar); @@ -337,7 +338,7 @@ OMX_BOOL Exynos_CSC_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA codecInputBuffer->dataSize += nPlaneSize[i]; csc_src_color_format = omx_2_hal_pixel_format((unsigned int)pVideoEnc->ANBColorFormat); - if (OMX_ErrorNone != Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatAndroidOpaque, planes)) { + if (OMX_ErrorNone != Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatAndroidOpaque, &stride, planes)) { Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: Exynos_OSAL_LockANBHandle() failed", __FUNCTION__); ret = OMX_FALSE; goto EXIT; @@ -570,8 +571,9 @@ OMX_BOOL Exynos_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_ #ifdef USE_DMA_BUF if (eColorFormat == OMX_COLOR_FormatAndroidOpaque) { ExynosVideoPlane planes[MAX_BUFFER_PLANE]; + OMX_U32 stride; - Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatAndroidOpaque, planes); + Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatAndroidOpaque, &stride, planes); for (plane = 0; plane < exynosInputPort->nPlaneCnt; plane++) { srcInputData->buffer.multiPlaneBuffer.fd[plane] = planes[plane].fd; diff --git a/component/video/enc/Exynos_OMX_VencControl.c b/component/video/enc/Exynos_OMX_VencControl.c index 81b9502..7d9806a 100644 --- a/component/video/enc/Exynos_OMX_VencControl.c +++ b/component/video/enc/Exynos_OMX_VencControl.c @@ -524,7 +524,7 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort( OMX_PTR ppBuf[MAX_BUFFER_PLANE]; if (OMX_ErrorNone == Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pExynosPort->processData.bufferHeader->pBuffer, ppBuf)) - Exynos_OSAL_UnlockANBHandle(ppBuf[0]); + Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]); } #endif Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader); @@ -546,7 +546,7 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort( OMX_PTR ppBuf[MAX_BUFFER_PLANE]; if (OMX_ErrorNone == Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, ppBuf)) - Exynos_OSAL_UnlockANBHandle(ppBuf[0]); + Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]); } #endif Exynos_OMX_InputBufferReturn(pOMXComponent, @@ -1936,7 +1936,7 @@ OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATA OMX_PTR ppBuf[MAX_BUFFER_PLANE]; if (OMX_ErrorNone == Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pUseBuffer->bufferHeader->pBuffer, ppBuf)) - Exynos_OSAL_UnlockANBHandle(ppBuf[0]); + Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]); } return ret; diff --git a/osal/Exynos_OSAL_Android.cpp b/osal/Exynos_OSAL_Android.cpp index c87068b..8a8a86c 100644 --- a/osal/Exynos_OSAL_Android.cpp +++ b/osal/Exynos_OSAL_Android.cpp @@ -68,6 +68,7 @@ OMX_ERRORTYPE Exynos_OSAL_LockANBHandle( OMX_IN OMX_U32 width, OMX_IN OMX_U32 height, OMX_IN OMX_COLOR_FORMATTYPE format, + OMX_OUT OMX_U32 *pStride, OMX_OUT OMX_PTR planes) { FunctionIn(); @@ -128,6 +129,8 @@ OMX_ERRORTYPE Exynos_OSAL_LockANBHandle( vplanes[1].addr = vaddr[1]; vplanes[2].addr = vaddr[2]; + *pStride = priv_hnd->stride; + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: buffer locked: 0x%x", __func__, *vaddr); EXIT: @@ -178,43 +181,6 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OSAL_LockANB( - OMX_IN OMX_PTR pBuffer, - OMX_IN OMX_U32 width, - OMX_IN OMX_U32 height, - OMX_IN OMX_COLOR_FORMATTYPE format, - OMX_OUT OMX_U32 *pStride, - OMX_OUT OMX_PTR planes) -{ - FunctionIn(); - - OMX_ERRORTYPE ret = OMX_ErrorNone; - android_native_buffer_t *pANB = (android_native_buffer_t *) pBuffer; - - ret = Exynos_OSAL_LockANBHandle((OMX_U32)pANB->handle, width, height, format, planes); - *pStride = pANB->stride; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE Exynos_OSAL_UnlockANB(OMX_IN OMX_PTR pBuffer) -{ - FunctionIn(); - - OMX_ERRORTYPE ret = OMX_ErrorNone; - android_native_buffer_t *pANB = (android_native_buffer_t *) pBuffer; - - ret = Exynos_OSAL_UnlockANBHandle((OMX_U32)pANB->handle); - -EXIT: - FunctionOut(); - - return ret; -} - OMX_ERRORTYPE useAndroidNativeBuffer( EXYNOS_OMX_BASEPORT *pExynosPort, OMX_BUFFERHEADERTYPE **ppBufferHdr, @@ -254,6 +220,8 @@ OMX_ERRORTYPE useAndroidNativeBuffer( for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { + OMX_U32 stride; + pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader; pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED); INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); @@ -267,7 +235,7 @@ OMX_ERRORTYPE useAndroidNativeBuffer( width = pExynosPort->portDefinition.format.video.nFrameWidth; height = pExynosPort->portDefinition.format.video.nFrameHeight; - Exynos_OSAL_LockANB(temp_bufferHeader->pBuffer, width, height, + Exynos_OSAL_LockANBHandle((OMX_U32)temp_bufferHeader->pBuffer, width, height, pExynosPort->portDefinition.format.video.eColorFormat, &stride, planes); #ifdef USE_DMA_BUF @@ -278,7 +246,7 @@ OMX_ERRORTYPE useAndroidNativeBuffer( pExynosPort->extendBufferHeader[i].pYUVBuf[0] = planes[0].addr; pExynosPort->extendBufferHeader[i].pYUVBuf[1] = planes[1].addr; pExynosPort->extendBufferHeader[i].pYUVBuf[2] = planes[2].addr; - Exynos_OSAL_UnlockANB(temp_bufferHeader->pBuffer); + Exynos_OSAL_UnlockANBHandle((OMX_U32)temp_bufferHeader->pBuffer); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "useAndroidNativeBuffer: buf %d pYUVBuf[0]:0x%x , pYUVBuf[1]:0x%x ", i, pExynosPort->extendBufferHeader[i].pYUVBuf[0], pExynosPort->extendBufferHeader[i].pYUVBuf[1]); diff --git a/osal/Exynos_OSAL_Android.h b/osal/Exynos_OSAL_Android.h index a0c21fb..db6a3bb 100644 --- a/osal/Exynos_OSAL_Android.h +++ b/osal/Exynos_OSAL_Android.h @@ -47,19 +47,11 @@ OMX_ERRORTYPE Exynos_OSAL_SetANBParameter(OMX_IN OMX_HANDLETYPE hComponent, OMX_COLOR_FORMATTYPE Exynos_OSAL_GetANBColorFormat(OMX_IN OMX_U32 handle); -OMX_ERRORTYPE Exynos_OSAL_LockANB(OMX_IN OMX_PTR pBuffer, - OMX_IN OMX_U32 width, - OMX_IN OMX_U32 height, - OMX_IN OMX_COLOR_FORMATTYPE format, - OMX_OUT OMX_U32 *pStride, - OMX_OUT OMX_PTR planes); - -OMX_ERRORTYPE Exynos_OSAL_UnlockANB(OMX_IN OMX_PTR pBuffer); - OMX_ERRORTYPE Exynos_OSAL_LockANBHandle(OMX_IN OMX_U32 pBuffer, OMX_IN OMX_U32 width, OMX_IN OMX_U32 height, OMX_IN OMX_COLOR_FORMATTYPE format, + OMX_OUT OMX_U32 *pStride, OMX_OUT OMX_PTR planes); OMX_ERRORTYPE Exynos_OSAL_UnlockANBHandle(OMX_IN OMX_U32 pBuffer); -- 2.20.1