summaryrefslogtreecommitdiffstats
path: root/exynos/multimedia/openmax/osal
diff options
context:
space:
mode:
Diffstat (limited to 'exynos/multimedia/openmax/osal')
-rw-r--r--exynos/multimedia/openmax/osal/Android.mk44
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Android.cpp579
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Android.h81
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_ETC.c154
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_ETC.h48
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Event.c217
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Event.h61
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Library.c54
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Library.h46
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Log.c53
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Log.h78
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Memory.c71
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Memory.h48
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.c93
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.h47
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Queue.c174
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Queue.h66
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.c134
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.h49
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Thread.c158
-rw-r--r--exynos/multimedia/openmax/osal/SEC_OSAL_Thread.h48
21 files changed, 2303 insertions, 0 deletions
diff --git a/exynos/multimedia/openmax/osal/Android.mk b/exynos/multimedia/openmax/osal/Android.mk
new file mode 100644
index 0000000..e4ceba0
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/Android.mk
@@ -0,0 +1,44 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OSAL_Android.cpp \
+ SEC_OSAL_Event.c \
+ SEC_OSAL_Queue.c \
+ SEC_OSAL_ETC.c \
+ SEC_OSAL_Mutex.c \
+ SEC_OSAL_Thread.c \
+ SEC_OSAL_Memory.c \
+ SEC_OSAL_Semaphore.c \
+ SEC_OSAL_Library.c \
+ SEC_OSAL_Log.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libsecosal
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_USE_V4L2), false)
+ifeq ($(BOARD_USE_S3D_SUPPORT), true)
+LOCAL_CFLAGS += -DS3D_SUPPORT
+endif
+endif
+
+LOCAL_STATIC_LIBRARIES :=
+LOCAL_SHARED_LIBRARIES := libcutils libutils \
+ libui \
+ libhardware \
+ libandroid_runtime \
+ libsurfaceflinger_client \
+ libbinder \
+ libmedia
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Android.cpp b/exynos/multimedia/openmax/osal/SEC_OSAL_Android.cpp
new file mode 100644
index 0000000..bb41720
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Android.cpp
@@ -0,0 +1,579 @@
+/*
+ * Copyright 2011 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Android.cpp
+ * @brief
+ * @author Seungbeom Kim (sbcrux.kim@samsung.com)
+ * @author Hyeyeon Chung (hyeon.chung@samsung.com)
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @author Jinsung Yang (jsgood.yang@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ui/android_native_buffer.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferMapper.h>
+#include <ui/Rect.h>
+#include <media/stagefright/HardwareAPI.h>
+#include <hardware/hardware.h>
+#include <media/stagefright/MetadataBufferType.h>
+
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OMX_Baseport.h"
+#include "SEC_OMX_Basecomponent.h"
+#include "SEC_OMX_Macros.h"
+#include "SEC_OMX_Vdec.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_OSAL_Android"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+using namespace android;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE useAndroidNativeBuffer(
+ SEC_OMX_BASEPORT *pSECPort,
+ OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_U32 nPortIndex,
+ OMX_PTR pAppPrivate,
+ OMX_U32 nSizeBytes,
+ OMX_U8 *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ unsigned int i = 0;
+
+ FunctionIn();
+
+ if (pSECPort == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECPort->portState != OMX_StateIdle) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) {
+ if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pSECPort->bufferHeader[i] = temp_bufferHeader;
+ pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ temp_bufferHeader->pBuffer = pBuffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if (nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+
+ pSECPort->assignedBufferNum++;
+ if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) {
+ pSECPort->portDefinition.bPopulated = OMX_TRUE;
+ /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */
+ SEC_OSAL_SemaphorePost(pSECPort->loadedResource);
+ /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */
+ }
+ *ppBufferHdr = temp_bufferHeader;
+ goto EXIT;
+ }
+ }
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_LockANBHandle(
+ OMX_IN OMX_U32 handle,
+ OMX_IN OMX_U32 width,
+ OMX_IN OMX_U32 height,
+ OMX_IN OMX_COLOR_FORMATTYPE format,
+ OMX_OUT OMX_PTR *vaddr)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+ buffer_handle_t bufferHandle = (buffer_handle_t) handle;
+ Rect bounds(width, height);
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: handle: 0x%x", __func__, handle);
+
+ int usage = 0;
+
+ switch (format) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_RL:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL:
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_RL:
+#endif
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_YUV_ADDR;
+ break;
+ default:
+ usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
+ break;
+ }
+
+ if (mapper.lock(bufferHandle, usage, bounds, vaddr) != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: mapper.lock() fail", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: buffer locked: 0x%x", __func__, *vaddr);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_UnlockANBHandle(OMX_IN OMX_U32 handle)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+ buffer_handle_t bufferHandle = (buffer_handle_t) handle;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: handle: 0x%x", __func__, handle);
+
+ if (mapper.unlock(bufferHandle) != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: mapper.unlock() fail", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: buffer unlocked: 0x%x", __func__, handle);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_GetPhysANBHandle(
+ OMX_IN OMX_U32 handle,
+ OMX_OUT OMX_PTR *paddr)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+ buffer_handle_t bufferHandle = (buffer_handle_t) handle;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: handle: 0x%x", __func__, handle);
+
+ if (mapper.getphys(bufferHandle, paddr) != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: mapper.getphys() fail", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_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 *vaddr)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ android_native_buffer_t *pANB = (android_native_buffer_t *) pBuffer;
+
+ ret = SEC_OSAL_LockANBHandle((OMX_U32)pANB->handle, width, height, format, vaddr);
+ *pStride = pANB->stride;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_UnlockANB(OMX_IN OMX_PTR pBuffer)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ android_native_buffer_t *pANB = (android_native_buffer_t *) pBuffer;
+
+ ret = SEC_OSAL_UnlockANBHandle((OMX_U32)pANB->handle);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_GetPhysANB(
+ OMX_IN OMX_PTR pBuffer,
+ OMX_OUT OMX_PTR *paddr)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ android_native_buffer_t *pANB = (android_native_buffer_t *) pBuffer;
+
+ ret = SEC_OSAL_GetPhysANBHandle((OMX_U32)pANB->handle, paddr);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_GetANBParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamGetAndroidNativeBuffer:
+ {
+ GetAndroidNativeBufferUsageParams *pANBParams = (GetAndroidNativeBufferUsageParams *) ComponentParameterStructure;
+ OMX_U32 portIndex = pANBParams->nPortIndex;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: OMX_IndexParamGetAndroidNativeBuffer", __func__);
+
+ ret = SEC_OMX_Check_SizeVersion(pANBParams, sizeof(GetAndroidNativeBufferUsageParams));
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_Check_SizeVersion(GetAndroidNativeBufferUsageParams) is failed", __func__);
+ goto EXIT;
+ }
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ /* NOTE: OMX_IndexParamGetAndroidNativeBuffer returns original 'nUsage' without any
+ * modifications since currently not defined what the 'nUsage' is for.
+ */
+ pANBParams->nUsage |= 0;
+ }
+ break;
+
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: Unsupported index (%d)", __func__, nIndex);
+ ret = OMX_ErrorUnsupportedIndex;
+ goto EXIT;
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SetANBParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+
+ switch (nIndex) {
+ case OMX_IndexParamEnableAndroidBuffers:
+ {
+ EnableAndroidNativeBuffersParams *pANBParams = (EnableAndroidNativeBuffersParams *) ComponentParameterStructure;
+ OMX_U32 portIndex = pANBParams->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: OMX_IndexParamEnableAndroidNativeBuffers", __func__);
+
+ ret = SEC_OMX_Check_SizeVersion(pANBParams, sizeof(EnableAndroidNativeBuffersParams));
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_Check_SizeVersion(EnableAndroidNativeBuffersParams) is failed", __func__);
+ goto EXIT;
+ }
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSECPort->bIsANBEnabled = pANBParams->enable;
+ }
+ break;
+
+ case OMX_IndexParamUseAndroidNativeBuffer:
+ {
+ UseAndroidNativeBufferParams *pANBParams = (UseAndroidNativeBufferParams *) ComponentParameterStructure;
+ OMX_U32 portIndex = pANBParams->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ android_native_buffer_t *pANB;
+ OMX_U32 nSizeBytes;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: OMX_IndexParamUseAndroidNativeBuffer, portIndex: %d", __func__, portIndex);
+
+ ret = SEC_OMX_Check_SizeVersion(pANBParams, sizeof(UseAndroidNativeBufferParams));
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_Check_SizeVersion(UseAndroidNativeBufferParams) is failed", __func__);
+ goto EXIT;
+ }
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if (pSECPort->portState != OMX_StateIdle) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: Port state should be IDLE", __func__);
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ pANB = pANBParams->nativeBuffer.get();
+
+ /* MALI alignment restriction */
+ nSizeBytes = ALIGN(pANB->width, 16) * ALIGN(pANB->height, 16);
+ nSizeBytes += ALIGN(pANB->width / 2, 16) * ALIGN(pANB->height / 2, 16) * 2;
+
+ ret = useAndroidNativeBuffer(pSECPort,
+ pANBParams->bufferHeader,
+ pANBParams->nPortIndex,
+ pANBParams->pAppPrivate,
+ nSizeBytes,
+ (OMX_U8 *) pANB);
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: useAndroidNativeBuffer is failed", __func__);
+ goto EXIT;
+ }
+ }
+ break;
+
+ case OMX_IndexParamStoreMetaDataBuffer:
+ {
+ StoreMetaDataInBuffersParams *pANBParams = (StoreMetaDataInBuffersParams *) ComponentParameterStructure;
+ OMX_U32 portIndex = pANBParams->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s: OMX_IndexParamStoreMetaDataBuffer", __func__);
+
+ ret = SEC_OMX_Check_SizeVersion(pANBParams, sizeof(StoreMetaDataInBuffersParams));
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_Check_SizeVersion(StoreMetaDataInBuffersParams) is failed", __func__);
+ goto EXIT;
+ }
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSECPort->bStoreMetaData = pANBParams->bStoreMetaData;
+ }
+ break;
+
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: Unsupported index (%d)", __func__, nIndex);
+ ret = OMX_ErrorUnsupportedIndex;
+ goto EXIT;
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_GetInfoFromMetaData(OMX_IN SEC_OMX_DATA *pBuffer,
+ OMX_OUT OMX_PTR *ppBuf)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ MetadataBufferType type;
+ buffer_handle_t pBufHandle;
+
+ FunctionIn();
+
+/*
+ * meta data contains the following data format.
+ * payload depends on the MetadataBufferType
+ * --------------------------------------------------------------
+ * | MetadataBufferType | payload |
+ * --------------------------------------------------------------
+ *
+ * If MetadataBufferType is kMetadataBufferTypeCameraSource, then
+ * --------------------------------------------------------------
+ * | kMetadataBufferTypeCameraSource | physical addr. of Y |physical addr. of CbCr |
+ * --------------------------------------------------------------
+ *
+ * If MetadataBufferType is kMetadataBufferTypeGrallocSource, then
+ * --------------------------------------------------------------
+ * | kMetadataBufferTypeGrallocSource | buffer_handle_t |
+ * --------------------------------------------------------------
+ */
+
+ /* MetadataBufferType */
+ memcpy(&type, (MetadataBufferType *)(pBuffer->dataBuffer), sizeof(type));
+
+ if (type == kMetadataBufferTypeCameraSource) {
+ /* physical addr. of Y */
+ ppBuf[0] = (OMX_PTR)(pBuffer->dataBuffer + sizeof(type));
+ /* physical addr. of CbCr */
+ ppBuf[1] = (OMX_PTR)(pBuffer->dataBuffer + sizeof(type) + sizeof(pBuffer->dataBuffer));
+ } else if (type == kMetadataBufferTypeGrallocSource) {
+ /* buffer_handle_t */
+ memcpy(&pBufHandle, pBuffer->dataBuffer + sizeof(type), sizeof(buffer_handle_t));
+ ppBuf[0] = (OMX_PTR)pBufHandle;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Android.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Android.h
new file mode 100644
index 0000000..67029f5
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Android.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Android.h
+ * @brief
+ * @author Seungbeom Kim (sbcrux.kim@samsung.com)
+ * @author Hyeyeon Chung (hyeon.chung@samsung.com)
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @author Jinsung Yang (jsgood.yang@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_ANDROID
+#define SEC_OSAL_ANDROID
+
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+#include "OMX_Index.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE SEC_OSAL_GetANBParameter(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE SEC_OSAL_SetANBParameter(OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+
+OMX_ERRORTYPE SEC_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 *vaddr);
+
+OMX_ERRORTYPE SEC_OSAL_GetPhysANB(OMX_IN OMX_PTR pBuffer,
+ OMX_OUT OMX_PTR *paddr);
+
+OMX_ERRORTYPE SEC_OSAL_UnlockANB(OMX_IN OMX_PTR pBuffer);
+
+OMX_ERRORTYPE SEC_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_PTR *vaddr);
+
+OMX_ERRORTYPE SEC_OSAL_UnlockANBHandle(OMX_IN OMX_U32 pBuffer);
+
+OMX_ERRORTYPE SEC_OSAL_GetPhysANBHandle(OMX_IN OMX_U32 pBuffer,
+ OMX_OUT OMX_PTR *paddr);
+
+OMX_ERRORTYPE SEC_OSAL_GetInfoFromMetaData(OMX_IN SEC_OMX_DATA *pBuffer,
+ OMX_OUT OMX_PTR *pOutBuffer);
+
+OMX_ERRORTYPE SEC_OSAL_CheckANB(OMX_IN SEC_OMX_DATA *pBuffer,
+ OMX_OUT OMX_BOOL *bIsANBEnabled);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_ETC.c b/exynos/multimedia/openmax/osal/SEC_OSAL_ETC.c
new file mode 100644
index 0000000..1bce154
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_ETC.c
@@ -0,0 +1,154 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_ETC.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_ETC.h"
+
+
+#ifndef HAVE_GETLINE
+ssize_t getline(char **ppLine, size_t *pLen, FILE *pStream)
+{
+ char *pCurrentPointer = NULL;
+ size_t const chunk = 512;
+
+ size_t defaultBufferSize = chunk + 1;
+ size_t retSize = 0;
+
+ if (*ppLine == NULL) {
+ *ppLine = (char *)malloc(defaultBufferSize);
+ if (*ppLine == NULL) {
+ retSize = -1;
+ goto EXIT;
+ }
+ *pLen = defaultBufferSize;
+ }
+ else {
+ if (*pLen < defaultBufferSize) {
+ *ppLine = (char *)realloc(*ppLine, defaultBufferSize);
+ if (*ppLine == NULL) {
+ retSize = -1;
+ goto EXIT;
+ }
+ *pLen = defaultBufferSize;
+ }
+ }
+
+ while (1) {
+ size_t i;
+ size_t j = 0;
+ size_t readByte = 0;
+
+ pCurrentPointer = *ppLine + readByte;
+
+ i = fread(pCurrentPointer, 1, chunk, pStream);
+ if (i < chunk && ferror(pStream)) {
+ retSize = -1;
+ goto EXIT;
+ }
+ while (j < i) {
+ ++j;
+ if (*pCurrentPointer++ == (char)'\n') {
+ *pCurrentPointer = '\0';
+ if (j != i) {
+ if (fseek(pStream, j - i, SEEK_CUR)) {
+ retSize = -1;
+ goto EXIT;
+ }
+ if (feof(pStream))
+ clearerr(pStream);
+ }
+ readByte += j;
+ retSize = readByte;
+ goto EXIT;
+ }
+ }
+
+ readByte += j;
+ if (feof(pStream)) {
+ if (readByte) {
+ retSize = readByte;
+ goto EXIT;
+ }
+ if (!i) {
+ retSize = -1;
+ goto EXIT;
+ }
+ }
+
+ i = ((readByte + (chunk * 2)) / chunk) * chunk;
+ if (i != *pLen) {
+ *ppLine = (char *)realloc(*ppLine, i);
+ if (*ppLine == NULL) {
+ retSize = -1;
+ goto EXIT;
+ }
+ *pLen = i;
+ }
+ }
+
+EXIT:
+ return retSize;
+}
+#endif /* HAVE_GETLINE */
+
+OMX_PTR SEC_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src)
+{
+ return strcpy(dest, src);
+}
+
+OMX_PTR SEC_OSAL_Strncpy(OMX_PTR dest, OMX_PTR src, size_t num)
+{
+ return strncpy(dest, src, num);
+}
+
+OMX_S32 SEC_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2)
+{
+ return strcmp(str1, str2);
+}
+
+OMX_S32 SEC_OSAL_Strncmp(OMX_PTR str1, OMX_PTR str2, size_t num)
+{
+ return strncmp(str1, str2, num);
+}
+
+OMX_PTR SEC_OSAL_Strcat(OMX_PTR dest, OMX_PTR src)
+{
+ return strcat(dest, src);
+}
+
+OMX_PTR SEC_OSAL_Strncat(OMX_PTR dest, OMX_PTR src, size_t num)
+{
+ return strncat(dest, src, num);
+}
+
+size_t SEC_OSAL_Strlen(const char *str)
+{
+ return strlen(str);
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_ETC.h b/exynos/multimedia/openmax/osal/SEC_OSAL_ETC.h
new file mode 100644
index 0000000..f311f26
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_ETC.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_ETC.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_ETC
+#define SEC_OSAL_ETC
+
+#include "OMX_Types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_PTR SEC_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src);
+OMX_S32 SEC_OSAL_Strncmp(OMX_PTR str1, OMX_PTR str2, size_t num);
+OMX_S32 SEC_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2);
+OMX_PTR SEC_OSAL_Strcat(OMX_PTR dest, OMX_PTR src);
+size_t SEC_OSAL_Strlen(const char *str);
+ssize_t getline(char **ppLine, size_t *len, FILE *stream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Event.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Event.c
new file mode 100644
index 0000000..383b62c
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Event.c
@@ -0,0 +1,217 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/*
+ * @file SEC_OSAL_Event.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <errno.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Mutex.h"
+#include "SEC_OSAL_Event.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_OSAL_EVENT"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+OMX_ERRORTYPE SEC_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle)
+{
+ SEC_OSAL_THREADEVENT *event;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ event = (SEC_OSAL_THREADEVENT *)SEC_OSAL_Malloc(sizeof(SEC_OSAL_THREADEVENT));
+ if (!event) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Memset(event, 0, sizeof(SEC_OSAL_THREADEVENT));
+ event->signal = OMX_FALSE;
+
+ ret = SEC_OSAL_MutexCreate(&event->mutex);
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Free(event);
+ goto EXIT;
+ }
+
+ if (pthread_cond_init(&event->condition, NULL)) {
+ SEC_OSAL_MutexTerminate(event->mutex);
+ SEC_OSAL_Free(event);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ *eventHandle = (OMX_HANDLETYPE)event;
+ ret = OMX_ErrorNone;
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle)
+{
+ SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (!event) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ ret = SEC_OSAL_MutexLock(event->mutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (pthread_cond_destroy(&event->condition)) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ ret = SEC_OSAL_MutexUnlock(event->mutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ ret = SEC_OSAL_MutexTerminate(event->mutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Free(event);
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SignalReset(OMX_HANDLETYPE eventHandle)
+{
+ SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (!event) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ ret = SEC_OSAL_MutexLock(event->mutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ event->signal = OMX_FALSE;
+
+ SEC_OSAL_MutexUnlock(event->mutex);
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SignalSet(OMX_HANDLETYPE eventHandle)
+{
+ SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (!event) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ ret = SEC_OSAL_MutexLock(event->mutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ event->signal = OMX_TRUE;
+ pthread_cond_signal(&event->condition);
+
+ SEC_OSAL_MutexUnlock(event->mutex);
+
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms)
+{
+ SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ struct timespec timeout;
+ struct timeval now;
+ int funcret = 0;
+ OMX_U32 tv_us;
+
+ FunctionIn();
+
+ if (!event) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ gettimeofday(&now, NULL);
+
+ tv_us = now.tv_usec + ms * 1000;
+ timeout.tv_sec = now.tv_sec + tv_us / 1000000;
+ timeout.tv_nsec = (tv_us % 1000000) * 1000;
+
+ ret = SEC_OSAL_MutexLock(event->mutex);
+ if (ret != OMX_ErrorNone) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if (ms == 0) {
+ if (!event->signal)
+ ret = OMX_ErrorTimeout;
+ } else if (ms == DEF_MAX_WAIT_TIME) {
+ while (!event->signal)
+ pthread_cond_wait(&event->condition, (pthread_mutex_t *)(event->mutex));
+ ret = OMX_ErrorNone;
+ } else {
+ while (!event->signal) {
+ funcret = pthread_cond_timedwait(&event->condition, (pthread_mutex_t *)(event->mutex), &timeout);
+ if ((!event->signal) && (funcret == ETIMEDOUT)) {
+ ret = OMX_ErrorTimeout;
+ break;
+ }
+ }
+ }
+
+ SEC_OSAL_MutexUnlock(event->mutex);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Event.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Event.h
new file mode 100644
index 0000000..8ae2eb5
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Event.h
@@ -0,0 +1,61 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Event.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_EVENT
+#define SEC_OSAL_EVENT
+
+#include <pthread.h>
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+
+#define DEF_MAX_WAIT_TIME 0xFFFFFFFF
+
+typedef struct _SEC_OSAL_THREADEVENT
+{
+ OMX_BOOL signal;
+ OMX_HANDLETYPE mutex;
+ pthread_cond_t condition;
+} SEC_OSAL_THREADEVENT;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+OMX_ERRORTYPE SEC_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle);
+OMX_ERRORTYPE SEC_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle);
+OMX_ERRORTYPE SEC_OSAL_SignalReset(OMX_HANDLETYPE eventHandle);
+OMX_ERRORTYPE SEC_OSAL_SignalSet(OMX_HANDLETYPE eventHandle);
+OMX_ERRORTYPE SEC_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Library.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Library.c
new file mode 100644
index 0000000..f400794
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Library.c
@@ -0,0 +1,54 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Library.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "SEC_OSAL_Library.h"
+
+
+void *SEC_OSAL_dlopen(const char *filename, int flag)
+{
+ return dlopen(filename, flag);
+}
+
+void *SEC_OSAL_dlsym(void *handle, const char *symbol)
+{
+ return dlsym(handle, symbol);
+}
+
+int SEC_OSAL_dlclose(void *handle)
+{
+ return dlclose(handle);
+}
+
+const char *SEC_OSAL_dlerror(void)
+{
+ return dlerror();
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Library.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Library.h
new file mode 100644
index 0000000..27ac42e
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Library.h
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Library.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_LIBRARY
+#define SEC_OSAL_LIBRARY
+
+#include "OMX_Types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *SEC_OSAL_dlopen(const char *filename, int flag);
+void *SEC_OSAL_dlsym(void *handle, const char *symbol);
+int SEC_OSAL_dlclose(void *handle);
+const char *SEC_OSAL_dlerror(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Log.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Log.c
new file mode 100644
index 0000000..ea95174
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Log.c
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Log.c
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <utils/Log.h>
+
+#include "SEC_OSAL_Log.h"
+
+
+void _SEC_OSAL_Log(SEC_LOG_LEVEL logLevel, const char *tag, const char *msg, ...)
+{
+ va_list argptr;
+
+ va_start(argptr, msg);
+
+ switch (logLevel) {
+ case SEC_LOG_TRACE:
+ __android_log_vprint(ANDROID_LOG_DEBUG, tag, msg, argptr);
+ break;
+ case SEC_LOG_WARNING:
+ __android_log_vprint(ANDROID_LOG_WARN, tag, msg, argptr);
+ break;
+ case SEC_LOG_ERROR:
+ __android_log_vprint(ANDROID_LOG_ERROR, tag, msg, argptr);
+ break;
+ default:
+ __android_log_vprint(ANDROID_LOG_VERBOSE, tag, msg, argptr);
+ }
+
+ va_end(argptr);
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Log.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Log.h
new file mode 100644
index 0000000..b993b90
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Log.h
@@ -0,0 +1,78 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Log.h
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ * 2010.8.27 : Add trace function
+ */
+
+#ifndef SEC_OSAL_LOG
+#define SEC_OSAL_LOG
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef SEC_LOG_OFF
+#define SEC_LOG
+#endif
+
+#ifndef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_LOG"
+#endif
+
+#ifdef SEC_TRACE_ON
+#define SEC_TRACE
+#endif
+
+typedef enum _LOG_LEVEL
+{
+ SEC_LOG_TRACE,
+ SEC_LOG_WARNING,
+ SEC_LOG_ERROR
+} SEC_LOG_LEVEL;
+
+#ifdef SEC_LOG
+#define SEC_OSAL_Log(a, ...) ((void)_SEC_OSAL_Log(a, SEC_LOG_TAG, __VA_ARGS__))
+#else
+#define SEC_OSAL_Log(a, ...) \
+ do { \
+ if (a == SEC_LOG_ERROR) \
+ ((void)_SEC_OSAL_Log(a, SEC_LOG_TAG, __VA_ARGS__)); \
+ } while (0)
+#endif
+
+#ifdef SEC_TRACE
+#define FunctionIn() _SEC_OSAL_Log(SEC_LOG_TRACE, SEC_LOG_TAG, "%s In , Line: %d", __FUNCTION__, __LINE__)
+#define FunctionOut() _SEC_OSAL_Log(SEC_LOG_TRACE, SEC_LOG_TAG, "%s Out , Line: %d", __FUNCTION__, __LINE__)
+#else
+#define FunctionIn() ((void *)0)
+#define FunctionOut() ((void *)0)
+#endif
+
+extern void _SEC_OSAL_Log(SEC_LOG_LEVEL logLevel, const char *tag, const char *msg, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Memory.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Memory.c
new file mode 100644
index 0000000..bf5224d
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Memory.c
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Memory.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OSAL_Memory.h"
+
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+static int mem_cnt = 0;
+
+OMX_PTR SEC_OSAL_Malloc(OMX_U32 size)
+{
+ mem_cnt++;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "alloc count: %d", mem_cnt);
+
+ return (OMX_PTR)malloc(size);
+}
+
+void SEC_OSAL_Free(OMX_PTR addr)
+{
+ mem_cnt--;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "free count: %d", mem_cnt);
+
+ if (addr)
+ free(addr);
+
+ return;
+}
+
+OMX_PTR SEC_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n)
+{
+ return memset(dest, c, n);
+}
+
+OMX_PTR SEC_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
+{
+ return memcpy(dest, src, n);
+}
+
+OMX_PTR SEC_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
+{
+ return memmove(dest, src, n);
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Memory.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Memory.h
new file mode 100644
index 0000000..fed5cac
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Memory.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Memory.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_MEMORY
+#define SEC_OSAL_MEMORY
+
+#include "OMX_Types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_PTR SEC_OSAL_Malloc(OMX_U32 size);
+void SEC_OSAL_Free(OMX_PTR addr);
+OMX_PTR SEC_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n);
+OMX_PTR SEC_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n);
+OMX_PTR SEC_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.c
new file mode 100644
index 0000000..b8f7b79
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.c
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Mutex.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Mutex.h"
+
+
+OMX_ERRORTYPE SEC_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle)
+{
+ pthread_mutex_t *mutex;
+
+ mutex = (pthread_mutex_t *)SEC_OSAL_Malloc(sizeof(pthread_mutex_t));
+ if (!mutex)
+ return OMX_ErrorInsufficientResources;
+
+ if (pthread_mutex_init(mutex, NULL) != 0) {
+ SEC_OSAL_Free(mutex);
+ return OMX_ErrorUndefined;
+ }
+
+ *mutexHandle = (OMX_HANDLETYPE)mutex;
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle)
+{
+ pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
+
+ if (mutex == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (pthread_mutex_destroy(mutex) != 0)
+ return OMX_ErrorUndefined;
+
+ SEC_OSAL_Free(mutex);
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle)
+{
+ pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
+ int result;
+
+ if (mutex == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (pthread_mutex_lock(mutex) != 0)
+ return OMX_ErrorUndefined;
+
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle)
+{
+ pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
+ int result;
+
+ if (mutex == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (pthread_mutex_unlock(mutex) != 0)
+ return OMX_ErrorUndefined;
+
+ return OMX_ErrorNone;
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.h
new file mode 100644
index 0000000..2dd63bc
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Mutex.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Mutex.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+*/
+
+#ifndef SEC_OSAL_MUTEX
+#define SEC_OSAL_MUTEX
+
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE SEC_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle);
+OMX_ERRORTYPE SEC_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle);
+OMX_ERRORTYPE SEC_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle);
+OMX_ERRORTYPE SEC_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Queue.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Queue.c
new file mode 100644
index 0000000..4ecd8dc
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Queue.c
@@ -0,0 +1,174 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Queue.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Mutex.h"
+#include "SEC_OSAL_Queue.h"
+
+
+OMX_ERRORTYPE SEC_OSAL_QueueCreate(SEC_QUEUE *queueHandle)
+{
+ int i = 0;
+ SEC_QElem *newqelem = NULL;
+ SEC_QElem *currentqelem = NULL;
+ SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle;
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (!queue)
+ return OMX_ErrorBadParameter;
+
+ ret = SEC_OSAL_MutexCreate(&queue->qMutex);
+ if (ret != OMX_ErrorNone)
+ return ret;
+
+ queue->first = (SEC_QElem *)SEC_OSAL_Malloc(sizeof(SEC_QElem));
+ if (queue->first == NULL)
+ return OMX_ErrorInsufficientResources;
+
+ SEC_OSAL_Memset(queue->first, 0, sizeof(SEC_QElem));
+ currentqelem = queue->last = queue->first;
+ queue->numElem = 0;
+
+ for (i = 0; i < (MAX_QUEUE_ELEMENTS - 2); i++) {
+ newqelem = (SEC_QElem *)SEC_OSAL_Malloc(sizeof(SEC_QElem));
+ if (newqelem == NULL) {
+ while (queue->first != NULL) {
+ currentqelem = queue->first->qNext;
+ SEC_OSAL_Free((OMX_PTR)queue->first);
+ queue->first = currentqelem;
+ }
+ return OMX_ErrorInsufficientResources;
+ } else {
+ SEC_OSAL_Memset(newqelem, 0, sizeof(SEC_QElem));
+ currentqelem->qNext = newqelem;
+ currentqelem = newqelem;
+ }
+ }
+
+ currentqelem->qNext = queue->first;
+
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_QueueTerminate(SEC_QUEUE *queueHandle)
+{
+ int i = 0;
+ SEC_QElem *currentqelem = NULL;
+ SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ if (!queue)
+ return OMX_ErrorBadParameter;
+
+ for ( i = 0; i < (MAX_QUEUE_ELEMENTS - 2); i++) {
+ currentqelem = queue->first->qNext;
+ SEC_OSAL_Free(queue->first);
+ queue->first = currentqelem;
+ }
+
+ if(queue->first) {
+ SEC_OSAL_Free(queue->first);
+ queue->first = NULL;
+ }
+
+ ret = SEC_OSAL_MutexTerminate(queue->qMutex);
+
+ return ret;
+}
+
+int SEC_OSAL_Queue(SEC_QUEUE *queueHandle, void *data)
+{
+ SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle;
+ if (queue == NULL)
+ return -1;
+
+ SEC_OSAL_MutexLock(queue->qMutex);
+
+ if ((queue->last->data != NULL) || (queue->numElem >= MAX_QUEUE_ELEMENTS)) {
+ SEC_OSAL_MutexUnlock(queue->qMutex);
+ return -1;
+ }
+ queue->last->data = data;
+ queue->last = queue->last->qNext;
+ queue->numElem++;
+
+ SEC_OSAL_MutexUnlock(queue->qMutex);
+ return 0;
+}
+
+void *SEC_OSAL_Dequeue(SEC_QUEUE *queueHandle)
+{
+ void *data = NULL;
+ SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle;
+ if (queue == NULL)
+ return NULL;
+
+ SEC_OSAL_MutexLock(queue->qMutex);
+
+ if ((queue->first->data == NULL) || (queue->numElem <= 0)) {
+ SEC_OSAL_MutexUnlock(queue->qMutex);
+ return NULL;
+ }
+ data = queue->first->data;
+ queue->first->data = NULL;
+ queue->first = queue->first->qNext;
+ queue->numElem--;
+
+ SEC_OSAL_MutexUnlock(queue->qMutex);
+ return data;
+}
+
+int SEC_OSAL_GetElemNum(SEC_QUEUE *queueHandle)
+{
+ int ElemNum = 0;
+ SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle;
+ if (queue == NULL)
+ return -1;
+
+ SEC_OSAL_MutexLock(queue->qMutex);
+ ElemNum = queue->numElem;
+ SEC_OSAL_MutexUnlock(queue->qMutex);
+ return ElemNum;
+}
+
+int SEC_OSAL_SetElemNum(SEC_QUEUE *queueHandle, int ElemNum)
+{
+ SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle;
+ if (queue == NULL)
+ return -1;
+
+ SEC_OSAL_MutexLock(queue->qMutex);
+ queue->numElem = ElemNum;
+ SEC_OSAL_MutexUnlock(queue->qMutex);
+ return ElemNum;
+}
+
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Queue.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Queue.h
new file mode 100644
index 0000000..d1dee11
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Queue.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Queue.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_QUEUE
+#define SEC_OSAL_QUEUE
+
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+
+#define MAX_QUEUE_ELEMENTS 10
+
+typedef struct _SEC_QElem
+{
+ void *data;
+ struct _SEC_QElem *qNext;
+} SEC_QElem;
+
+typedef struct _SEC_QUEUE
+{
+ SEC_QElem *first;
+ SEC_QElem *last;
+ int numElem;
+ OMX_HANDLETYPE qMutex;
+} SEC_QUEUE;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE SEC_OSAL_QueueCreate(SEC_QUEUE *queueHandle);
+OMX_ERRORTYPE SEC_OSAL_QueueTerminate(SEC_QUEUE *queueHandle);
+int SEC_OSAL_Queue(SEC_QUEUE *queueHandle, void *data);
+void *SEC_OSAL_Dequeue(SEC_QUEUE *queueHandle);
+int SEC_OSAL_GetElemNum(SEC_QUEUE *queueHandle);
+int SEC_OSAL_SetElemNum(SEC_QUEUE *queueHandle, int ElemNum);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.c
new file mode 100644
index 0000000..be9b9cb
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.c
@@ -0,0 +1,134 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Semaphore.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <semaphore.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Semaphore.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_LOG_SEMA"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle)
+{
+ sem_t *sema;
+
+ sema = (sem_t *)SEC_OSAL_Malloc(sizeof(sem_t));
+ if (!sema)
+ return OMX_ErrorInsufficientResources;
+
+ if (sem_init(sema, 0, 0) != 0) {
+ SEC_OSAL_Free(sema);
+ return OMX_ErrorUndefined;
+ }
+
+ *semaphoreHandle = (OMX_HANDLETYPE)sema;
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle)
+{
+ sem_t *sema = (sem_t *)semaphoreHandle;
+
+ if (sema == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (sem_destroy(sema) != 0)
+ return OMX_ErrorUndefined;
+
+ SEC_OSAL_Free(sema);
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle)
+{
+ sem_t *sema = (sem_t *)semaphoreHandle;
+
+ FunctionIn();
+
+ if (sema == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (sem_wait(sema) != 0)
+ return OMX_ErrorUndefined;
+
+ FunctionOut();
+
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle)
+{
+ sem_t *sema = (sem_t *)semaphoreHandle;
+
+ FunctionIn();
+
+ if (sema == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (sem_post(sema) != 0)
+ return OMX_ErrorUndefined;
+
+ FunctionOut();
+
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val)
+{
+ sem_t *sema = (sem_t *)semaphoreHandle;
+
+ if (sema == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (sem_init(sema, 0, val) != 0)
+ return OMX_ErrorUndefined;
+
+ return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SEC_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val)
+{
+ sem_t *sema = (sem_t *)semaphoreHandle;
+ int semaVal = 0;
+
+ if (sema == NULL)
+ return OMX_ErrorBadParameter;
+
+ if (sem_getvalue(sema, &semaVal) != 0)
+ return OMX_ErrorUndefined;
+
+ *val = (OMX_S32)semaVal;
+
+ return OMX_ErrorNone;
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.h
new file mode 100644
index 0000000..431cba4
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Semaphore.h
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Semaphore.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_SEMAPHORE
+#define SEC_OSAL_SEMAPHORE
+
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle);
+OMX_ERRORTYPE SEC_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle);
+OMX_ERRORTYPE SEC_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle);
+OMX_ERRORTYPE SEC_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle);
+OMX_ERRORTYPE SEC_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val);
+OMX_ERRORTYPE SEC_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Thread.c b/exynos/multimedia/openmax/osal/SEC_OSAL_Thread.c
new file mode 100644
index 0000000..730b4a9
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Thread.c
@@ -0,0 +1,158 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Thread.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <errno.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Thread.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_LOG_THREAD"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+typedef struct _SEC_THREAD_HANDLE_TYPE
+{
+ pthread_t pthread;
+ pthread_attr_t attr;
+ struct sched_param schedparam;
+ int stack_size;
+} SEC_THREAD_HANDLE_TYPE;
+
+
+OMX_ERRORTYPE SEC_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument)
+{
+ FunctionIn();
+
+ int result = 0;
+ int detach_ret = 0;
+ SEC_THREAD_HANDLE_TYPE *thread;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ thread = SEC_OSAL_Malloc(sizeof(SEC_THREAD_HANDLE_TYPE));
+ SEC_OSAL_Memset(thread, 0, sizeof(SEC_THREAD_HANDLE_TYPE));
+
+ pthread_attr_init(&thread->attr);
+ if (thread->stack_size != 0)
+ pthread_attr_setstacksize(&thread->attr, thread->stack_size);
+
+ /* set priority */
+ if (thread->schedparam.sched_priority != 0)
+ pthread_attr_setschedparam(&thread->attr, &thread->schedparam);
+
+ detach_ret = pthread_attr_setdetachstate(&thread->attr, PTHREAD_CREATE_JOINABLE);
+ if (detach_ret != 0) {
+ SEC_OSAL_Free(thread);
+ *threadHandle = NULL;
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ result = pthread_create(&thread->pthread, &thread->attr, function_name, (void *)argument);
+ /* pthread_setschedparam(thread->pthread, SCHED_RR, &thread->schedparam); */
+
+ switch (result) {
+ case 0:
+ *threadHandle = (OMX_HANDLETYPE)thread;
+ ret = OMX_ErrorNone;
+ break;
+ case EAGAIN:
+ SEC_OSAL_Free(thread);
+ *threadHandle = NULL;
+ ret = OMX_ErrorInsufficientResources;
+ break;
+ default:
+ SEC_OSAL_Free(thread);
+ *threadHandle = NULL;
+ ret = OMX_ErrorUndefined;
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle)
+{
+ FunctionIn();
+
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle;
+
+ if (!thread) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pthread_join(thread->pthread, NULL) != 0) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Free(thread);
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OSAL_ThreadCancel(OMX_HANDLETYPE threadHandle)
+{
+ SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle;
+
+ if (!thread)
+ return OMX_ErrorBadParameter;
+
+ /* thread_cancel(thread->pthread); */
+ pthread_exit(&thread->pthread);
+ pthread_join(thread->pthread, NULL);
+
+ SEC_OSAL_Free(thread);
+ return OMX_ErrorNone;
+}
+
+void SEC_OSAL_ThreadExit(void *value_ptr)
+{
+ pthread_exit(value_ptr);
+ return;
+}
+
+void SEC_OSAL_SleepMillisec(OMX_U32 ms)
+{
+ usleep(ms * 1000);
+ return;
+}
diff --git a/exynos/multimedia/openmax/osal/SEC_OSAL_Thread.h b/exynos/multimedia/openmax/osal/SEC_OSAL_Thread.h
new file mode 100644
index 0000000..ce1262d
--- /dev/null
+++ b/exynos/multimedia/openmax/osal/SEC_OSAL_Thread.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Thread.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OSAL_THREAD
+#define SEC_OSAL_THREAD
+
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE SEC_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument);
+OMX_ERRORTYPE SEC_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle);
+OMX_ERRORTYPE SEC_OSAL_ThreadCancel(OMX_HANDLETYPE threadHandle);
+void SEC_OSAL_ThreadExit(void *value_ptr);
+void SEC_OSAL_SleepMillisec(OMX_U32 ms);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif