Add original Samsung hardware projects

Change-Id: I79380bc91acf57ca5f3e56fb64af76f4c45f6566
Signed-off-by: Sam Protsenko <joe.skb7@gmail.com>
This commit is contained in:
Sam Protsenko
2023-09-08 19:45:36 -05:00
committed by Tim Zimmermann
commit d70d919c01
217 changed files with 127074 additions and 0 deletions

225
openmax/osal/Android.mk Normal file
View File

@@ -0,0 +1,225 @@
LOCAL_PATH := $(call my-dir)
ifeq ($(BOARD_USE_SKYPE_HD), true)
#################################
#### libExynosOMX_SkypeHD_Enc ###
#################################
include $(CLEAR_VARS)
LOCAL_CFLAGS :=
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libExynosOMX_SkypeHD_Enc
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CFLAGS += -DUSE_VENDOR_IMAGE
LOCAL_CFLAGS += -DUSE_SKYPE_HD
LOCAL_CFLAGS += -DBUILD_ENC
LOCAL_SRC_FILES := Exynos_OSAL_SkypeHD.c
LOCAL_C_INCLUDES := \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_COMPONENT)/common \
$(EXYNOS_OMX_COMPONENT)/video/enc \
$(EXYNOS_OMX_COMPONENT)/video/enc/h264 \
$(EXYNOS_VIDEO_CODEC)/include \
$(TOP)/hardware/samsung_slsi/exynos/include
ifeq ($(BOARD_USE_KHRONOS_OMX_HEADER), true)
LOCAL_CFLAGS += -DUSE_KHRONOS_OMX_HEADER
LOCAL_C_INCLUDES += $(EXYNOS_OMX_INC)/khronos
else
ifeq ($(BOARD_USE_ANDROID), true)
LOCAL_HEADER_LIBRARIES := media_plugin_headers
LOCAL_CFLAGS += -DUSE_ANDROID
endif
endif
ifdef BOARD_EXYNOS_S10B_FORMAT_ALIGN
LOCAL_CFLAGS += -DS10B_FORMAT_8B_ALIGNMENT=$(BOARD_EXYNOS_S10B_FORMAT_ALIGN)
endif
LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-label
include $(BUILD_STATIC_LIBRARY)
#################################
#### libExynosOMX_SkypeHD_Dec ###
#################################
include $(CLEAR_VARS)
LOCAL_CFLAGS :=
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libExynosOMX_SkypeHD_Dec
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CFLAGS += -DUSE_VENDOR_IMAGE
LOCAL_CFLAGS += -DUSE_SKYPE_HD
LOCAL_CFLAGS += -DBUILD_DEC
LOCAL_SRC_FILES := Exynos_OSAL_SkypeHD.c
LOCAL_C_INCLUDES := \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_COMPONENT)/common \
$(EXYNOS_OMX_COMPONENT)/video/dec \
$(EXYNOS_OMX_COMPONENT)/video/dec/h264 \
$(EXYNOS_VIDEO_CODEC)/include \
$(TOP)/hardware/samsung_slsi/exynos/include
ifeq ($(BOARD_USE_KHRONOS_OMX_HEADER), true)
LOCAL_CFLAGS += -DUSE_KHRONOS_OMX_HEADER
LOCAL_C_INCLUDES += $(EXYNOS_OMX_INC)/khronos
else
ifeq ($(BOARD_USE_ANDROID), true)
LOCAL_HEADER_LIBRARIES := media_plugin_headers
LOCAL_CFLAGS += -DUSE_ANDROID
endif
endif
ifdef BOARD_EXYNOS_S10B_FORMAT_ALIGN
LOCAL_CFLAGS += -DS10B_FORMAT_8B_ALIGNMENT=$(BOARD_EXYNOS_S10B_FORMAT_ALIGN)
endif
LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-label
include $(BUILD_STATIC_LIBRARY)
endif # for Skype HD
##########################
#### libExynosOMX_OSAL ###
##########################
include $(CLEAR_VARS)
LOCAL_CFLAGS :=
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
Exynos_OSAL_Event.c \
Exynos_OSAL_Queue.c \
Exynos_OSAL_ETC.c \
Exynos_OSAL_Mutex.c \
Exynos_OSAL_Thread.c \
Exynos_OSAL_Memory.c \
Exynos_OSAL_Semaphore.c \
Exynos_OSAL_Library.c \
Exynos_OSAL_Log.c \
Exynos_OSAL_SharedMemory.c
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libExynosOMX_OSAL
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CFLAGS += -DUSE_VENDOR_IMAGE
ifeq ($(BOARD_USE_DMA_BUF), true)
LOCAL_CFLAGS += -DUSE_DMA_BUF
endif
ifeq ($(BOARD_USE_CSC_HW), true)
LOCAL_CFLAGS += -DUSE_CSC_HW
endif
ifeq ($(BOARD_USE_NON_CACHED_GRAPHICBUFFER), true)
LOCAL_CFLAGS += -DUSE_NON_CACHED_GRAPHICBUFFER
endif
ifdef BOARD_MFC_CHROMA_VALIGN
LOCAL_CFLAGS += -DCHROMA_VALIGN=$(BOARD_MFC_CHROMA_VALIGN)
else
LOCAL_CFLAGS += -DCHROMA_VALIGN=1
endif
ifeq ($(BOARD_USE_WA_ION_BUF_REF), true)
LOCAL_CFLAGS += -DUSE_WA_ION_BUF_REF
endif
ifeq ($(BOARD_USES_EXYNOS_GRALLOC_VERSION), 3)
LOCAL_CFLAGS += -DUSE_WA_ION_BUF_REF
endif
LOCAL_STATIC_LIBRARIES := libExynosVideoApi
LOCAL_SHARED_LIBRARIES := \
libc \
libcutils \
libutils \
liblog \
libion \
libhardware \
libhidlbase \
libui \
libexynosgraphicbuffer \
libion_exynos \
libepicoperator
LOCAL_C_INCLUDES := \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_COMPONENT)/common \
$(EXYNOS_OMX_COMPONENT)/video/dec \
$(EXYNOS_OMX_COMPONENT)/video/enc \
$(EXYNOS_VIDEO_CODEC)/include \
$(TOP)/hardware/samsung_slsi/exynos/include \
$(TOP)/hardware/samsung_slsi/exynos/libion/include \
$(TOP)/system/core/libsystem/include/
ifeq ($(BOARD_USE_ANDROID), true)
LOCAL_SRC_FILES += \
Exynos_OSAL_Android.cpp \
Exynos_OSAL_ImageConverter.cpp
LOCAL_STATIC_LIBRARIES += libVendorVideoApi
ifeq ($(BOARD_USES_EXYNOS_DATASPACE_FEATURE), true)
LOCAL_CFLAGS += -DUSE_BT709_SUPPORT
endif
ifeq ($(BOARD_USES_EXYNOS_GRALLOC_VERSION), 0)
LOCAL_CFLAGS += -DGRALLOC_VERSION0
LOCAL_CFLAGS += -DUSE_PRIV_FORMAT
else
LOCAL_CFLAGS += -DUSE_PRIV_USAGE
endif
endif
ifeq ($(BOARD_USE_SKYPE_HD), true)
LOCAL_CFLAGS += -DUSE_SKYPE_HD
endif
ifeq ($(BOARD_USE_KHRONOS_OMX_HEADER), true)
LOCAL_CFLAGS += -DUSE_KHRONOS_OMX_HEADER
LOCAL_C_INCLUDES += $(EXYNOS_OMX_INC)/khronos
else
ifeq ($(BOARD_USE_ANDROID), true)
LOCAL_HEADER_LIBRARIES := media_plugin_headers
LOCAL_CFLAGS += -DUSE_ANDROID
endif
endif
ifeq ($(BOARD_USE_FULL_ST2094_40), true)
LOCAL_CFLAGS += -DUSE_FULL_ST2094_40
endif
ifdef BOARD_EXYNOS_S10B_FORMAT_ALIGN
LOCAL_CFLAGS += -DS10B_FORMAT_8B_ALIGNMENT=$(BOARD_EXYNOS_S10B_FORMAT_ALIGN)
endif
ifeq ($(BOARD_HAS_SCALER_ALIGN_RESTRICTION), true)
LOCAL_CFLAGS += -DMSCL_EXT_SIZE=512
else
LOCAL_CFLAGS += -DMSCL_EXT_SIZE=0
endif
LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-label
include $(BUILD_STATIC_LIBRARY)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
/*
* Copyright 2012 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 Exynos_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 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_ANDROID
#define Exynos_OSAL_ANDROID
#include "OMX_Types.h"
#include "OMX_Core.h"
#include "OMX_Index.h"
#include "Exynos_OMX_Baseport.h"
#include "Exynos_OSAL_SharedMemory.h"
#include "ExynosVideoApi.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_HANDLETYPE Exynos_OSAL_RefCount_Create();
OMX_ERRORTYPE Exynos_OSAL_RefCount_Reset(OMX_HANDLETYPE hREF);
OMX_ERRORTYPE Exynos_OSAL_RefCount_Terminate(OMX_HANDLETYPE hREF);
OMX_ERRORTYPE Exynos_OSAL_RefCount_Increase(OMX_HANDLETYPE hREF, OMX_PTR pBuffer, EXYNOS_OMX_BASEPORT *pExynosPort);
OMX_ERRORTYPE Exynos_OSAL_RefCount_Decrease(OMX_HANDLETYPE hREF, OMX_PTR pBuffer, ReleaseDPB dpbFD[VIDEO_BUFFER_MAX_NUM], EXYNOS_OMX_BASEPORT *pExynosPort);
OMX_ERRORTYPE Exynos_OSAL_SetPrependSPSPPSToIDR(OMX_PTR pComponentParameterStructure,
OMX_PTR pbPrependSpsPpsToIdr);
OMX_U32 Exynos_OSAL_GetDisplayExtraBufferCount(void);
void getColorAspectsPreferBitstream(EXYNOS_OMX_VIDEO_COLORASPECTS *pBSCA, EXYNOS_OMX_VIDEO_COLORASPECTS *pFWCA, void *pParam);
void getColorAspectsPreferFramework(EXYNOS_OMX_VIDEO_COLORASPECTS *pBSCA, EXYNOS_OMX_VIDEO_COLORASPECTS *pFWCA, void *pParam);
void Exynos_OSAL_GetColorAspectsForBitstream(EXYNOS_OMX_VIDEO_COLORASPECTS *pFWCA, EXYNOS_OMX_VIDEO_COLORASPECTS *pBSCA);
void Exynos_OSAL_ColorSpaceToColorAspects(int colorSpace, EXYNOS_OMX_VIDEO_COLORASPECTS *colorAspects);
OMX_ERRORTYPE setHDR10PlusInfoForFramework(OMX_COMPONENTTYPE *pOMXComponent, void *pHDRDynamicInfo);
OMX_ERRORTYPE setHDR10PlusInfoForVendorPath(OMX_COMPONENTTYPE *pOMXComponent, void *pExynosHDR10PlusInfo, void *pHDRDynamicInfo);
OMX_ERRORTYPE Exynos_OSAL_AddVendorExt(OMX_HANDLETYPE hComponent, OMX_STRING cExtName, OMX_INDEXTYPE nIndex);
void Exynos_OSAL_DelVendorExts(OMX_HANDLETYPE hComponent);
OMX_ERRORTYPE Exynos_OSAL_GetVendorExt(OMX_HANDLETYPE hComponent, OMX_PTR pConfig);
OMX_ERRORTYPE Exynos_OSAL_SetVendorExt(OMX_HANDLETYPE hComponent, OMX_PTR pConfig);
OMX_HANDLETYPE Exynos_OSAL_CreatePerformanceHandle(OMX_BOOL bIsEncoder);
void Exynos_OSAL_Performance(OMX_HANDLETYPE handle, int value, int fps);
void Exynos_OSAL_ReleasePerformanceHandle(OMX_HANDLETYPE handle);
OMX_ERRORTYPE Exynos_OSAL_UpdateDataSpaceFromAspects(EXYNOS_OMX_VIDEO_COLORASPECTS *pFWCA);
void Exynos_OSAL_UpdateDataSpaceFromBitstream(EXYNOS_OMX_BASECOMPONENT *pExynosComponent);
void Exynos_OSAL_UpdateDataspaceToGraphicMeta(OMX_PTR pBuf, int nDataSpace);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_ETC.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_ETC
#define Exynos_OSAL_ETC
#include "OMX_Types.h"
#include "Exynos_OMX_Def.h"
#ifdef PERFORMANCE_DEBUG
#include <sys/time.h>
#endif
#define INT_TO_PTR(var) ((void *)(unsigned long)var)
#define PTR_TO_INT(var) ((int)(unsigned long)var)
#ifdef __cplusplus
extern "C" {
#endif
size_t Exynos_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src);
OMX_S32 Exynos_OSAL_Strncmp(OMX_PTR str1, OMX_PTR str2, size_t num);
OMX_S32 Exynos_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2);
const char* Exynos_OSAL_Strstr(const char *str1, const char *str2);
size_t Exynos_OSAL_Strcat(OMX_PTR dest, OMX_PTR src);
size_t Exynos_OSAL_Strlen(const char *str);
/* perf */
typedef enum _PERF_ID_TYPE {
PERF_ID_CSC = 0,
PERF_ID_DEC,
PERF_ID_ENC,
PERF_ID_USER,
PERF_ID_MAX,
} PERF_ID_TYPE;
void Exynos_OSAL_PerfInit(PERF_ID_TYPE id);
void Exynos_OSAL_PerfStart(PERF_ID_TYPE id);
void Exynos_OSAL_PerfStop(PERF_ID_TYPE id);
OMX_U32 Exynos_OSAL_PerfFrame(PERF_ID_TYPE id);
OMX_U32 Exynos_OSAL_PerfTotal(PERF_ID_TYPE id);
OMX_U32 Exynos_OSAL_PerfFrameCount(PERF_ID_TYPE id);
int Exynos_OSAL_PerfOver30ms(PERF_ID_TYPE id);
void Exynos_OSAL_PerfPrint(OMX_STRING prefix, PERF_ID_TYPE id);
unsigned int Exynos_OSAL_GetPlaneCount(OMX_COLOR_FORMATTYPE eOMXFormat, PLANE_TYPE ePlaneType);
void Exynos_OSAL_GetPlaneSize(OMX_COLOR_FORMATTYPE eColorFormat, PLANE_TYPE ePlaneType, OMX_U32 nWidth, OMX_U32 nHeight, unsigned int nDataLen[MAX_BUFFER_PLANE], unsigned int nAllocLen[MAX_BUFFER_PLANE]);
OMX_U32 Exynos_OSAL_GetOutBufferSize(OMX_U32 nWidth, OMX_U32 nHeight, OMX_U32 nDefaultBufferSize);
int Exynos_OSAL_OMX2VideoFormat(OMX_COLOR_FORMATTYPE eColorFormat, PLANE_TYPE ePlaneType);
OMX_COLOR_FORMATTYPE Exynos_OSAL_Video2OMXFormat(int nVideoFormat);
OMX_COLOR_FORMATTYPE Exynos_OSAL_HAL2OMXColorFormat(unsigned int nHALFormat);
unsigned int Exynos_OSAL_OMX2HALPixelFormat(OMX_COLOR_FORMATTYPE eOMXFormat, PLANE_TYPE ePlaneType);
int Exynos_OSAL_DataSpaceToColorSpace(int nDataSpace, int nFormat);
void Exynos_OSAL_GetRGBColorTypeForBitStream(EXYNOS_OMX_VIDEO_COLORASPECTS *pColorAspects, int nDataSpace, int nFormat);
inline static const char *stateString(OMX_STATETYPE i) {
switch (i) {
case OMX_StateInvalid: return "OMX_StateInvaild";
case OMX_StateLoaded: return "OMX_StateLoaded";
case OMX_StateIdle: return "OMX_StateIdle";
case OMX_StateExecuting: return "OMX_StateExecuting";
case OMX_StatePause: return "OMX_StatePause";
case OMX_StateWaitForResources: return "OMX_StateWaitForResources";
default: return "??";
}
}
#ifdef PERFORMANCE_DEBUG
void Exynos_OSAL_Get_Perf_Property();
OMX_ERRORTYPE Exynos_OSAL_CountCreate(OMX_HANDLETYPE *hPerfInfo);
void Exynos_OSAL_CountTerminate(OMX_HANDLETYPE *hPerfInfo);
OMX_S32 Exynos_OSAL_CountIncrease(OMX_HANDLETYPE *hPerfInfo, OMX_BUFFERHEADERTYPE *pBufferHeader, int nPortIndex);
OMX_S32 Exynos_OSAL_CountDecrease(OMX_HANDLETYPE *hPerfInfo, OMX_BUFFERHEADERTYPE *pBufferHeader, int nPortIndex);
OMX_S32 Exynos_OSAL_V4L2CountIncrease(OMX_HANDLETYPE *hPerfInfo, OMX_BUFFERHEADERTYPE *pBufferHeader, int nPortIndex);
OMX_S32 Exynos_OSAL_V4L2CountDecrease(OMX_HANDLETYPE *hPerfInfo, OMX_BUFFERHEADERTYPE *pBufferHeader, int nPortIndex);
void Exynos_OSAL_CountReset(OMX_HANDLETYPE *hPerfInfo);
void Exynos_OSAL_PrintPerfInfo(OMX_HANDLETYPE *hSrcPerfInfo, OMX_HANDLETYPE *hDstPerfInfo, OMX_BUFFERHEADERTYPE *pBufferHeader);
//void Exynos_OSAL_PrintCountInfo(OMX_PTR *pStartHandle, BUFFER_TIME dstBufferInfo);
//OMX_ERRORTYPE Exynos_OSAL_GetCountInfoUseOMXBuffer(OMX_HANDLETYPE hCountHandle, OMX_BUFFERHEADERTYPE *OMXBufferHeader, BUFFER_TIME *pBufferInfo);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,220 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Event.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>
#include <sys/time.h>
#include "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_Mutex.h"
#include "Exynos_OSAL_Event.h"
#undef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "Exynos_OSAL_EVENT"
//#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
OMX_ERRORTYPE Exynos_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle)
{
Exynos_OSAL_THREADEVENT *event;
OMX_ERRORTYPE ret = OMX_ErrorNone;
event = (Exynos_OSAL_THREADEVENT *)Exynos_OSAL_Malloc(sizeof(Exynos_OSAL_THREADEVENT));
if (!event) {
ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
Exynos_OSAL_Memset(event, 0, sizeof(Exynos_OSAL_THREADEVENT));
event->signal = OMX_FALSE;
ret = Exynos_OSAL_MutexCreate(&event->mutex);
if (ret != OMX_ErrorNone) {
Exynos_OSAL_Free(event);
goto EXIT;
}
if (pthread_cond_init(&event->condition, NULL)) {
Exynos_OSAL_MutexTerminate(event->mutex);
Exynos_OSAL_Free(event);
ret = OMX_ErrorUndefined;
goto EXIT;
}
*eventHandle = (OMX_HANDLETYPE)event;
ret = OMX_ErrorNone;
EXIT:
return ret;
}
OMX_ERRORTYPE Exynos_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle)
{
Exynos_OSAL_THREADEVENT *event = (Exynos_OSAL_THREADEVENT *)eventHandle;
OMX_ERRORTYPE ret = OMX_ErrorNone;
if (!event) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
ret = Exynos_OSAL_MutexLock(event->mutex);
if (ret != OMX_ErrorNone) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
if (pthread_cond_destroy(&event->condition)) {
Exynos_OSAL_MutexUnlock(event->mutex);
ret = OMX_ErrorUndefined;
goto EXIT;
}
ret = Exynos_OSAL_MutexUnlock(event->mutex);
if (ret != OMX_ErrorNone) {
ret = OMX_ErrorUndefined;
goto EXIT;
}
ret = Exynos_OSAL_MutexTerminate(event->mutex);
if (ret != OMX_ErrorNone) {
ret = OMX_ErrorUndefined;
goto EXIT;
}
Exynos_OSAL_Free(event);
EXIT:
return ret;
}
OMX_ERRORTYPE Exynos_OSAL_SignalReset(OMX_HANDLETYPE eventHandle)
{
Exynos_OSAL_THREADEVENT *event = (Exynos_OSAL_THREADEVENT *)eventHandle;
OMX_ERRORTYPE ret = OMX_ErrorNone;
if (!event) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
ret = Exynos_OSAL_MutexLock(event->mutex);
if (ret != OMX_ErrorNone) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
event->signal = OMX_FALSE;
Exynos_OSAL_MutexUnlock(event->mutex);
EXIT:
return ret;
}
OMX_ERRORTYPE Exynos_OSAL_SignalSet(OMX_HANDLETYPE eventHandle)
{
Exynos_OSAL_THREADEVENT *event = (Exynos_OSAL_THREADEVENT *)eventHandle;
OMX_ERRORTYPE ret = OMX_ErrorNone;
if (!event) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
ret = Exynos_OSAL_MutexLock(event->mutex);
if (ret != OMX_ErrorNone) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
event->signal = OMX_TRUE;
pthread_cond_signal(&event->condition);
Exynos_OSAL_MutexUnlock(event->mutex);
EXIT:
return ret;
}
OMX_ERRORTYPE Exynos_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms)
{
Exynos_OSAL_THREADEVENT *event = (Exynos_OSAL_THREADEVENT *)eventHandle;
OMX_ERRORTYPE ret = OMX_ErrorNone;
struct timespec timeout;
struct timeval now;
int funcret = 0;
long tv_us, tv_ns;
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);
tv_ns = (tv_us % 1000000) * 1000;
timeout.tv_nsec = tv_ns;
ret = Exynos_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;
}
}
}
Exynos_OSAL_MutexUnlock(event->mutex);
EXIT:
FunctionOut();
return ret;
}

View File

@@ -0,0 +1,61 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Event.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_EVENT
#define Exynos_OSAL_EVENT
#include <pthread.h>
#include "OMX_Types.h"
#include "OMX_Core.h"
#define DEF_MAX_WAIT_TIME 0xFFFFFFFF
typedef struct _Exynos_OSAL_THREADEVENT
{
OMX_BOOL signal;
OMX_HANDLETYPE mutex;
pthread_cond_t condition;
} Exynos_OSAL_THREADEVENT;
#ifdef __cplusplus
extern "C" {
#endif
OMX_ERRORTYPE Exynos_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle);
OMX_ERRORTYPE Exynos_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle);
OMX_ERRORTYPE Exynos_OSAL_SignalReset(OMX_HANDLETYPE eventHandle);
OMX_ERRORTYPE Exynos_OSAL_SignalSet(OMX_HANDLETYPE eventHandle);
OMX_ERRORTYPE Exynos_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,403 @@
/*
* Copyright 2019 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 Exynos_OSAL_ImageConverter.c
* @brief
* @author Taehwan Kim (t_h.kim@samsung.com)
* @author Byunggwan Kang (bk0917.kang@samsung.com)
* @author Seungbeom Kim (sbcrux.kim@samsung.com)
* @version 1.0.0
* @history
* 2019.02.12 : Create
*/
#include <dlfcn.h>
#include <media/hardware/HardwareAPI.h>
#include <media/hardware/MetadataBufferType.h>
#include <media/stagefright/foundation/ColorUtils.h>
#include "Exynos_OMX_Basecomponent.h"
#include "Exynos_OMX_Def.h"
#include "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_Library.h"
#include "Exynos_OSAL_ETC.h"
#include "Exynos_OSAL_Platform.h"
#include "Exynos_OSAL_ImageConverter.h"
#include "VendorVideoAPI.h"
#undef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "Exynos_OSAL_ImageConverter"
//#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
using namespace android;
#ifdef __cplusplus
extern "C" {
#endif
#define CHECK_HDR10(f, r, p, t, c) \
((f == (OMX_COLOR_FORMATTYPE)OMX_COLOR_FormatYUV420Planar16) && \
(r == ColorAspects::RangeLimited) && \
(p == ColorAspects::PrimariesBT2020) && \
(t == ColorAspects::TransferST2084) && \
(c == ColorAspects::MatrixBT2020))
#define LUMINANCE_DIV_FACTOR 10000.0
#define LIB_NAME "libImageFormatConverter.so"
#define LIB_FN_NAME_INIT "CL_HDR2SDR_ARM_init"
#define LIB_FN_NAME_DEINIT "CL_HDR2SDR_ARM_deinit"
#define LIB_FN_NAME_RUN "CL_HDR2SDR_ARM_convert"
typedef enum _Image_ColorFormat {
INVALID = -1,
TP10_UBWC_QCOM = 0,
P010_LINEAR = 1,
NV12 = 2,
RGBA = 3,
YV12 = 4,
NV21 = 5,
} Image_ColorFormat;
typedef enum _ALGO_t {
NONE = 0,
NORMAL = 1,
HI_JACK = 2,
} ALGO_t;
typedef struct _MULTIPLANE_t {
int handle;
void *host_ptr;
int size;
} MULTIPLANE_t;
typedef struct _HDR2SDR_config_params_t {
Image_ColorFormat color_format;
MULTIPLANE_t buffer[3];
} HDR2SDR_config_params_t;
typedef struct _HDR10PLUS_DYNAMIC_INFO {
unsigned char country_code; // 0xB5
unsigned short provider_code; // 0x003C
unsigned short provider_oriented_code; // 0x0001
unsigned char application_identifier;
unsigned char application_version;
unsigned int display_max_luminance;
//unsigned char targeted_system_display_actual_peak_luminance_flag = 0;
//--------------------------------------------------------------------
/* window = 1, fixed point at this moment */
unsigned int maxscl[3];
unsigned int avg_maxrgb;
unsigned char num_maxrgb_percentiles;
unsigned char maxrgb_percentages[15];
unsigned int maxrgb_percentiles[15];
//unsigned char fraction_bright_pixels = 1;
//--------------------------------------------------------------------
//unsigned char mastering_display_actual_peak_luminance_flag = 0;
//--------------------------------------------------------------------
/* window = 1, fixed point at this moment */
unsigned char tone_mapping_flag; // 1
unsigned short knee_point_x; //[ ~ 4095]
unsigned short knee_point_y; //[ ~ 4095]
unsigned char num_bezier_curve_anchors; // 10 [ ~ 15]
unsigned short bezier_curve_anchors[15];
//unsigned char color_saturation_mapping_flag = 0;
//--------------------------------------------------------------------
} HDR10PLUS_DYNAMIC_INFO;
typedef OMX_BOOL (*ConvertInitFunc)(const unsigned int width, const unsigned int height, const ALGO_t algo, void **user_data, const bool usage);
typedef void (*ConvertDeinitFunc)(void *user_data);
typedef OMX_BOOL (*ConvertRunFunc)(HDR2SDR_config_params_t *In_params, HDR2SDR_config_params_t *Out_params, HDR10PLUS_DYNAMIC_INFO *meta, unsigned int mastering_max_luminance, void *user_data);
typedef struct _EXYNOS_OMX_IMG_CONV_HANDLE {
void *pLibHandle;
ConvertInitFunc Init;
ConvertDeinitFunc Deinit;
ConvertRunFunc Run;
void *pUserData;
OMX_BOOL bHasDynamicInfo;
HDR10PLUS_DYNAMIC_INFO *pDynamicInfo;
} EXYNOS_OMX_IMG_CONV_HANDLE;
OMX_HANDLETYPE Exynos_OSAL_ImgConv_Create(
OMX_U32 nWidth,
OMX_U32 nHeight,
OMX_U32 nMode)
{
EXYNOS_OMX_IMG_CONV_HANDLE *pHandle = NULL;
pHandle = (EXYNOS_OMX_IMG_CONV_HANDLE *)Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_IMG_CONV_HANDLE));
if (pHandle == NULL) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Malloc()", __FUNCTION__);
goto EXIT;
}
pHandle->pDynamicInfo = (HDR10PLUS_DYNAMIC_INFO *)Exynos_OSAL_Malloc(sizeof(HDR10PLUS_DYNAMIC_INFO));
if (pHandle->pDynamicInfo == NULL) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Malloc()", __FUNCTION__);
Exynos_OSAL_Free(pHandle);
pHandle = NULL;
goto EXIT;
}
pHandle->pLibHandle = Exynos_OSAL_dlopen(LIB_NAME, RTLD_NOW|RTLD_GLOBAL);
if (pHandle->pLibHandle == NULL) {
Exynos_OSAL_Log(EXYNOS_LOG_ESSENTIAL, "[%s] Failed to Exynos_OSAL_dlopen() : reason(%s)",
__FUNCTION__, Exynos_OSAL_dlerror());
Exynos_OSAL_Free(pHandle->pDynamicInfo);
Exynos_OSAL_Free(pHandle);
pHandle = NULL;
goto EXIT;
}
pHandle->Init = (ConvertInitFunc)Exynos_OSAL_dlsym(pHandle->pLibHandle, (const char *)LIB_FN_NAME_INIT);
pHandle->Deinit = (ConvertDeinitFunc)Exynos_OSAL_dlsym(pHandle->pLibHandle, (const char *)LIB_FN_NAME_DEINIT);
pHandle->Run = (ConvertRunFunc)Exynos_OSAL_dlsym(pHandle->pLibHandle, (const char *)LIB_FN_NAME_RUN);
if ((pHandle->Init == NULL) ||
(pHandle->Deinit == NULL) ||
(pHandle->Run == NULL)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_dlsym()", __FUNCTION__);
Exynos_OSAL_dlclose(pHandle->pLibHandle);
Exynos_OSAL_Free(pHandle->pDynamicInfo);
Exynos_OSAL_Free(pHandle);
pHandle = NULL;
goto EXIT;
}
if (pHandle->Init(nWidth, nHeight, ((nMode == 0)? NORMAL:HI_JACK), &pHandle->pUserData, false) != OMX_TRUE) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Init()", __FUNCTION__);
Exynos_OSAL_dlclose(pHandle->pLibHandle);
Exynos_OSAL_Free(pHandle->pDynamicInfo);
Exynos_OSAL_Free(pHandle);
pHandle = NULL;
goto EXIT;
}
pHandle->bHasDynamicInfo = OMX_FALSE;
EXIT:
return (OMX_HANDLETYPE)pHandle;
}
void Exynos_OSAL_ImgConv_Terminate(OMX_HANDLETYPE hImgConv)
{
EXYNOS_OMX_IMG_CONV_HANDLE *pHandle = (EXYNOS_OMX_IMG_CONV_HANDLE *)hImgConv;
if (pHandle == NULL)
return;
if (pHandle->Deinit != NULL)
pHandle->Deinit(pHandle->pUserData);
Exynos_OSAL_dlclose(pHandle->pLibHandle);
if (pHandle->pDynamicInfo != NULL)
Exynos_OSAL_Free(pHandle->pDynamicInfo);
Exynos_OSAL_Free(pHandle);
pHandle = NULL;
}
OMX_ERRORTYPE Exynos_OSAL_ImgConv_Run(
OMX_HANDLETYPE hImgConv,
OMX_COMPONENTTYPE *pOMXComponent,
OMX_PTR pBuffer,
OMX_PTR pHDRDynamic)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_IMG_CONV_HANDLE *pHandle = (EXYNOS_OMX_IMG_CONV_HANDLE *)hImgConv;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
/* graphic buffer */
EXYNOS_OMX_MULTIPLANE_BUFFER bufferInfo;
EXYNOS_OMX_LOCK_RANGE range;
OMX_U32 stride = 0;
unsigned int nAllocLen[MAX_BUFFER_PLANE] = { 0, 0, 0 };
unsigned int nDataLen[MAX_BUFFER_PLANE] = { 0, 0, 0 };
/* HDR information */
EXYNOS_OMX_VIDEO_COLORASPECTS *pFWCA = NULL; /* framework */
EXYNOS_OMX_VIDEO_COLORASPECTS *pBSCA = NULL; /* bitstream */
DescribeColorAspectsParams CA;
/* parmas for image convert */
HDR2SDR_config_params_t inConfig, outConfig;
OMX_U16 max_display_luminance_cd_m2 = 0;
int i;
if ((pHandle == NULL) ||
(pOMXComponent == NULL) ||
(pBuffer == NULL)) {
Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "[%s] invalid parameters", __FUNCTION__);
ret = OMX_ErrorBadParameter;
goto EXIT;
}
pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
if (pExynosComponent->codecType == HW_VIDEO_DEC_CODEC) {
pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]);
if (pExynosPort->eMetaDataType != METADATA_TYPE_GRAPHIC) {
/* not supported */
Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "[%p][%s] meta type is wrong(0x%x)",
pExynosComponent, __FUNCTION__, pExynosPort->eMetaDataType);
ret = OMX_ErrorBadParameter;
goto EXIT;
}
range.nWidth = pExynosPort->portDefinition.format.video.nFrameWidth;
range.nHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
range.eColorFormat = pExynosPort->portDefinition.format.video.eColorFormat;
pFWCA = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].ColorAspects;
pBSCA = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX].ColorAspects;
if (Exynos_OSAL_Strstr(pExynosComponent->componentName, "VP9") ||
Exynos_OSAL_Strstr(pExynosComponent->componentName, "vp9")) {
/* In case of VP9, should rely on information in webm container */
getColorAspectsPreferFramework(pBSCA, pFWCA, (void *)&CA);
} else {
/* generally, rely on information in bitstream */
getColorAspectsPreferBitstream(pBSCA, pFWCA, (void *)&CA);
}
} else {
/* not supported */
ret = OMX_ErrorUndefined;
goto EXIT;
}
ret = Exynos_OSAL_LockMetaData(pBuffer, range, &stride, &bufferInfo, pExynosPort->eMetaDataType);
if (ret != OMX_ErrorNone) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%p][%s]: Failed to Exynos_OSAL_LockMetaData()",
pExynosComponent, __FUNCTION__);
goto EXIT;
}
if (!CHECK_HDR10(bufferInfo.eColorFormat, CA.sAspects.mRange, CA.sAspects.mPrimaries,
CA.sAspects.mTransfer, CA.sAspects.mMatrixCoeffs)) {
/* it is not HDR10 */
ret = OMX_ErrorUndefined;
goto EXIT;
}
Exynos_OSAL_GetPlaneSize(bufferInfo.eColorFormat, pExynosPort->ePlaneType, stride, range.nHeight, nDataLen, nAllocLen);
Exynos_OSAL_Memset(&inConfig, 1, sizeof(inConfig));
Exynos_OSAL_Memset(&outConfig, 1, sizeof(outConfig));
inConfig.color_format = P010_LINEAR;
inConfig.buffer[0].handle = bufferInfo.fd[0];
inConfig.buffer[0].size = nAllocLen[0];
inConfig.buffer[0].host_ptr = bufferInfo.addr[0];
inConfig.buffer[1].handle = bufferInfo.fd[1];
inConfig.buffer[1].size = nAllocLen[1];
inConfig.buffer[1].host_ptr = bufferInfo.addr[1];
outConfig.color_format = P010_LINEAR;
if (pHDRDynamic != NULL) {
ExynosHdrDynamicInfo *DY = (ExynosHdrDynamicInfo *)pHDRDynamic;
if (DY->valid != 0) {
HDR10PLUS_DYNAMIC_INFO info;
memset(&info, 0, sizeof(info));
info.country_code = DY->data.country_code;
info.provider_code = DY->data.provider_code;
info.provider_oriented_code = DY->data.provider_oriented_code;
info.application_identifier = DY->data.application_identifier;
info.application_version = DY->data.application_version;
#ifdef USE_FULL_ST2094_40
info.display_max_luminance = DY->data.targeted_system_display_maximum_luminance;
for (int i = 0; i < 3; i++) {
info.maxscl[i] = DY->data.maxscl[0][i];
}
info.avg_maxrgb = DY->data.average_maxrgb[0];
info.num_maxrgb_percentiles = DY->data.num_maxrgb_percentiles[0];
for (int i = 0; i < info.num_maxrgb_percentiles; i++) {
info.maxrgb_percentages[i] = DY->data.maxrgb_percentages[0][i];
info.maxrgb_percentiles[i] = DY->data.maxrgb_percentiles[0][i];
}
info.tone_mapping_flag = DY->data.tone_mapping.tone_mapping_flag[0];
info.knee_point_x = DY->data.tone_mapping.knee_point_x[0];
info.knee_point_y = DY->data.tone_mapping.knee_point_y[0];
info.num_bezier_curve_anchors = DY->data.tone_mapping.num_bezier_curve_anchors[0];
for (int i = 0; i < info.num_bezier_curve_anchors; i++) {
info.bezier_curve_anchors[i] = DY->data.tone_mapping.bezier_curve_anchors[0][i];
}
#else // USE_FULL_ST2094_40
info.display_max_luminance = DY->data.display_maximum_luminance;
for (int i = 0; i < 3; i++) {
info.maxscl[i] = DY->data.maxscl[i];
}
info.num_maxrgb_percentiles = DY->data.num_maxrgb_percentiles;
for (int i = 0; i < info.num_maxrgb_percentiles; i++) {
info.maxrgb_percentages[i] = DY->data.maxrgb_percentages[i];
info.maxrgb_percentiles[i] = DY->data.maxrgb_percentiles[i];
}
info.tone_mapping_flag = DY->data.tone_mapping.tone_mapping_flag;
info.knee_point_x = DY->data.tone_mapping.knee_point_x;
info.knee_point_y = DY->data.tone_mapping.knee_point_y;
info.num_bezier_curve_anchors = DY->data.tone_mapping.num_bezier_curve_anchors;
for (int i = 0; i < info.num_bezier_curve_anchors; i++) {
info.bezier_curve_anchors[i] = DY->data.tone_mapping.bezier_curve_anchors[i];
}
#endif
if (memcmp(pHandle->pDynamicInfo, &info, sizeof(info))) {
pHandle->bHasDynamicInfo = OMX_TRUE;
memcpy(pHandle->pDynamicInfo, &info, sizeof(info));
}
}
}
max_display_luminance_cd_m2 = (int)((pExynosPort->HDRStaticInfo.nMaxDisplayLuminance / LUMINANCE_DIV_FACTOR) + 0.5);
if (pHandle->Run != NULL) {
pHandle->Run(&inConfig, &outConfig, ((pHandle->bHasDynamicInfo == OMX_TRUE)? pHandle->pDynamicInfo:NULL),
max_display_luminance_cd_m2, pHandle->pUserData);
} else {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
EXIT:
if ((pBuffer != NULL) && (pExynosPort != NULL))
Exynos_OSAL_UnlockMetaData(pBuffer, pExynosPort->eMetaDataType);
return ret;
}
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2019 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 Exynos_OSAL_ImageConverter.h
* @brief
* @author Taehwan Kim (t_h.kim@samsung.com)
* @author Byunggwan Kang (bk0917.kang@samsung.com)
* @author Seungbeom Kim (sbcrux.kim@samsung.com)
* @version 1.0.0
* @history
* 2019.02.12 : Create
*/
#ifndef Exynos_OSAL_IMAGE_CONVERTER
#define Exynos_OSAL_IMAGE_CONVERTER
#include "OMX_Types.h"
#include "OMX_Component.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_HANDLETYPE Exynos_OSAL_ImgConv_Create(OMX_U32 nWidth, OMX_U32 nHeight, OMX_U32 nMode);
void Exynos_OSAL_ImgConv_Terminate(OMX_HANDLETYPE hImgConv);
OMX_ERRORTYPE Exynos_OSAL_ImgConv_Run(OMX_HANDLETYPE hImgConv, OMX_COMPONENTTYPE *pOMXComponent, OMX_PTR pBuffer, OMX_PTR pHDRDynamic);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,108 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Library.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <sys/utsname.h>
#include "Exynos_OSAL_Library.h"
#include "Exynos_OSAL_ETC.h"
#include "Exynos_OSAL_Memory.h"
#undef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "EXYNOS_OSAL_LIB"
#include "Exynos_OSAL_Log.h"
void *Exynos_OSAL_dlopen(const char *filename, int flag)
{
return dlopen(filename, flag);
}
void *Exynos_OSAL_dlsym(void *handle, const char *symbol)
{
return dlsym(handle, symbol);
}
int Exynos_OSAL_dlclose(void *handle)
{
return dlclose(handle);
}
const char *Exynos_OSAL_dlerror(void)
{
return dlerror();
}
const char *Exynos_OSAL_GetLibPath(void)
{
#ifdef USE_VENDOR_IMAGE
const char *ANDROID_LIB_INSTALL_PATH = "/vendor/lib/omx/";
const char *ANDROID_LIB64_INSTALL_PATH = "/vendor/lib64/omx/";
#else
const char *ANDROID_LIB_INSTALL_PATH = "/system/lib/omx/";
const char *ANDROID_LIB64_INSTALL_PATH = "/system/lib64/omx/";
#endif
const char *OTHERS_LIB_INSTALL_PATH = "/usr/lib/";
const char *OTHERS_LIB64_INSTALL_PATH = "/usr/lib/";
struct utsname buf;
Exynos_OSAL_Memset(&buf, 0, sizeof(buf));
#ifndef USE_ANDROID
/* try to get system info */
if (uname(&buf) < 0) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to uname()", __FUNCTION__);
return (IS_64BIT_OS)? ANDROID_LIB64_INSTALL_PATH:ANDROID_LIB_INSTALL_PATH;
}
if (Exynos_OSAL_Strncmp(buf.sysname, "Linux", Exynos_OSAL_Strlen("Linux")) != 0) {
/* others */
return (IS_64BIT_OS)? OTHERS_LIB64_INSTALL_PATH:OTHERS_LIB_INSTALL_PATH;
}
#endif
/* default : android */
return (IS_64BIT_OS)? ANDROID_LIB64_INSTALL_PATH:ANDROID_LIB_INSTALL_PATH;
}
int Exynos_OSAL_CheckLibName(char *pLibName)
{
if (pLibName == NULL)
return -1;
/* it should be started as "libOMX.Exynos." */
if (Exynos_OSAL_Strncmp(pLibName, "libOMX.Exynos.", Exynos_OSAL_Strlen("libOMX.Exynos.")) == 0) {
/* it should be delimited as ".so" */
char *pExtPosit =(((char *)pLibName) + (Exynos_OSAL_Strlen(pLibName) - 3));
if (Exynos_OSAL_Strncmp(pExtPosit, ".so", Exynos_OSAL_Strlen(".so")) == 0)
return 0;
}
return -1;
}

View File

@@ -0,0 +1,48 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Library.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_LIBRARY
#define Exynos_OSAL_LIBRARY
#include "OMX_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
void *Exynos_OSAL_dlopen(const char *filename, int flag);
void *Exynos_OSAL_dlsym(void *handle, const char *symbol);
int Exynos_OSAL_dlclose(void *handle);
const char *Exynos_OSAL_dlerror(void);
const char *Exynos_OSAL_GetLibPath(void);
int Exynos_OSAL_CheckLibName(char *pLibName);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,126 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Log.c
* @brief
* @author Yunji Kim (yunji.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <log/log.h>
#include <cutils/properties.h>
#include "Exynos_OSAL_Log.h"
#include "Exynos_OSAL_ETC.h"
/* =======TAG=========
EXYNOS_RM
EXYNOS_LOG
EXYNOS_COMP_REGS
EXYNOS_OMX_CORE
EXYNOS_LOG_THREAD
EXYNOS_LOG_SEMA
Exynos_OSAL_SkypeHD
Exynos_OSAL_Android
Exynos_OSAL_EVENT
EXYNOS_BASE_COMP
EXYNOS_BASE_PORT
EXYNOS_VIDEO_DEC
EXYNOS_VIDEO_DECCONTROL
EXYNOS_H264_DEC
EXYNOS_HEVC_DEC
EXYNOS_MPEG2_DEC
EXYNOS_MPEG4_DEC
EXYNOS_WMV_DEC
EXYNOS_VP8_DEC
EXYNOS_VP9_DEC
EXYNOS_VIDEO_ENC
EXYNOS_VIDEO_ENCCONTROL
EXYNOS_HEVC_ENC
EXYNOS_H264_ENC
EXYNOS_MPEG4_ENC
EXYNOS_VP8_ENC
EXYNOS_VP9_ENC
======================*/
static char debugProp[PROPERTY_VALUE_MAX];
typedef enum _DEBUG_LEVEL
{
LOG_LEVEL_ALL = EXYNOS_LOG_FUNC_TRACE,
LOG_LEVEL2 = EXYNOS_LOG_TRACE,
LOG_LEVEL1 = EXYNOS_LOG_ESSENTIAL,
LOG_DEFAULT = EXYNOS_LOG_INFO,
LOG_LEVELTAG,
} EXYNOS_DEBUG_LEVEL;
static unsigned int log_prop = LOG_DEFAULT;
void Exynos_OSAL_Get_Log_Property()
{
#ifdef EXYNOS_LOG
if (property_get("ro.vendor.debug.omx.level", debugProp, NULL) > 0) {
if(!(Exynos_OSAL_Strncmp(debugProp, "0", 1))) {
log_prop = LOG_DEFAULT;
} else if (!(Exynos_OSAL_Strncmp(debugProp, "1", 1))) {
log_prop = LOG_LEVEL1;
} else if (!(Exynos_OSAL_Strncmp(debugProp, "2", 1))) {
log_prop = LOG_LEVEL2;
} else if (!(Exynos_OSAL_Strncmp(debugProp, "3", 1))) {
log_prop = LOG_LEVEL_ALL;
} else {
log_prop = LOG_LEVELTAG;
}
}
#endif
}
void _Exynos_OSAL_Log(EXYNOS_LOG_LEVEL logLevel, const char *tag, const char *msg, ...)
{
va_list argptr;
#ifdef EXYNOS_LOG
if (log_prop == LOG_LEVELTAG) {
if(!Exynos_OSAL_Strstr(debugProp, tag))
return;
} else if (logLevel < log_prop)
return;
#endif
va_start(argptr, msg);
switch (logLevel) {
case EXYNOS_LOG_FUNC_TRACE:
__android_log_vprint(ANDROID_LOG_VERBOSE, tag, msg, argptr);
break;
case EXYNOS_LOG_TRACE:
__android_log_vprint(ANDROID_LOG_DEBUG, tag, msg, argptr);
break;
case EXYNOS_LOG_ESSENTIAL:
case EXYNOS_LOG_INFO:
__android_log_vprint(ANDROID_LOG_INFO, tag, msg, argptr);
break;
case EXYNOS_LOG_WARNING:
__android_log_vprint(ANDROID_LOG_WARN, tag, msg, argptr);
break;
case EXYNOS_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);
}

View File

@@ -0,0 +1,86 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Log.h
* @brief
* @author Yunji Kim (yunji.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
* 2012.8.27 : Add trace function
*/
#ifndef EXYNOS_OSAL_LOG
#define EXYNOS_OSAL_LOG
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXYNOS_LOG_OFF
#define EXYNOS_LOG
#endif
#ifndef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "EXYNOS_LOG"
#endif
#define EXYNOS_TRACE_FUNCTION_INFO
#ifndef USE_ANDROID
#define PROPERTY_KEY_MAX 32
#define PROPERTY_VALUE_MAX 92
#endif
typedef enum _LOG_LEVEL
{
EXYNOS_LOG_FUNC_TRACE,
EXYNOS_LOG_TRACE,
EXYNOS_LOG_ESSENTIAL,
EXYNOS_LOG_INFO,
EXYNOS_LOG_WARNING,
EXYNOS_LOG_ERROR
} EXYNOS_LOG_LEVEL;
#ifdef EXYNOS_LOG
#define Exynos_OSAL_Log(a, ...) ((void)_Exynos_OSAL_Log(a, EXYNOS_LOG_TAG, __VA_ARGS__))
#else
#define Exynos_OSAL_Log(a, ...) \
do { \
if ((a == EXYNOS_LOG_ERROR) || \
(a == EXYNOS_LOG_WARNING)) \
((void)_Exynos_OSAL_Log(a, EXYNOS_LOG_TAG, __VA_ARGS__)); \
} while (0)
#endif
#ifdef EXYNOS_TRACE_FUNCTION_INFO
#define FunctionIn() _Exynos_OSAL_Log(EXYNOS_LOG_FUNC_TRACE, EXYNOS_LOG_TAG, "%s In , Line: %d", __FUNCTION__, __LINE__)
#define FunctionOut() _Exynos_OSAL_Log(EXYNOS_LOG_FUNC_TRACE, EXYNOS_LOG_TAG, "%s Out , Line: %d", __FUNCTION__, __LINE__)
#else
#define FunctionIn() ((void *)0)
#define FunctionOut() ((void *)0)
#endif
void Exynos_OSAL_Get_Log_Property();
void _Exynos_OSAL_Log(EXYNOS_LOG_LEVEL logLevel, const char *tag, const char *msg, ...);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,92 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Memory.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include "Exynos_OSAL_Memory.h"
//#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
static int mem_cnt = 0;
OMX_PTR Exynos_OSAL_Malloc(OMX_U32 size)
{
OMX_PTR addr = NULL;
addr = (OMX_PTR)malloc(size);
if (addr != NULL) {
mem_cnt++;
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, mem_cnt);
}
return addr;
}
void Exynos_OSAL_Free(OMX_PTR addr)
{
if (addr) {
free(addr);
mem_cnt--;
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, mem_cnt);
}
return;
}
OMX_PTR Exynos_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n)
{
return memset(dest, c, n);
}
OMX_PTR Exynos_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
{
return memcpy(dest, src, n);
}
OMX_PTR Exynos_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
{
return memmove(dest, src, n);
}
OMX_S32 Exynos_OSAL_Memcmp(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
{
return memcmp(dest, src, n);
}
OMX_PTR Exynos_OSAL_Mmap(OMX_PTR addr, size_t length, OMX_S32 prot, OMX_S32 flags, unsigned long fd, off_t offset)
{
return mmap(addr, length, prot, flags, fd, offset);
}
OMX_S32 Exynos_OSAL_Munmap(OMX_PTR addr, size_t length)
{
return munmap(addr, length);
}

View File

@@ -0,0 +1,51 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Memory.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_MEMORY
#define Exynos_OSAL_MEMORY
#include "OMX_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_PTR Exynos_OSAL_Malloc(OMX_U32 size);
void Exynos_OSAL_Free(OMX_PTR addr);
OMX_PTR Exynos_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n);
OMX_PTR Exynos_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n);
OMX_PTR Exynos_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n);
OMX_S32 Exynos_OSAL_Memcmp(OMX_PTR dest, OMX_PTR src, OMX_S32 n);
OMX_PTR Exynos_OSAL_Mmap(OMX_PTR addr, size_t length, OMX_S32 prot, OMX_S32 flags, unsigned long fd, off_t offset);
OMX_S32 Exynos_OSAL_Munmap(OMX_PTR addr, size_t length);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,90 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Mutex.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_Mutex.h"
OMX_ERRORTYPE Exynos_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle)
{
pthread_mutex_t *mutex;
mutex = (pthread_mutex_t *)Exynos_OSAL_Malloc(sizeof(pthread_mutex_t));
if (!mutex)
return OMX_ErrorInsufficientResources;
if (pthread_mutex_init(mutex, NULL) != 0) {
Exynos_OSAL_Free(mutex);
return OMX_ErrorUndefined;
}
*mutexHandle = (OMX_HANDLETYPE)mutex;
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_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;
Exynos_OSAL_Free(mutex);
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle)
{
pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
if (mutex == NULL)
return OMX_ErrorBadParameter;
if (pthread_mutex_lock(mutex) != 0)
return OMX_ErrorUndefined;
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle)
{
pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle;
if (mutex == NULL)
return OMX_ErrorBadParameter;
if (pthread_mutex_unlock(mutex) != 0)
return OMX_ErrorUndefined;
return OMX_ErrorNone;
}

View File

@@ -0,0 +1,47 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Mutex.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_MUTEX
#define Exynos_OSAL_MUTEX
#include "OMX_Types.h"
#include "OMX_Core.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_ERRORTYPE Exynos_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle);
OMX_ERRORTYPE Exynos_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle);
OMX_ERRORTYPE Exynos_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle);
OMX_ERRORTYPE Exynos_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,69 @@
/*
* Copyright 2016 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 Exynos_OSAL_Platform.h
* @brief
* @author Taehwan Kim (t_h.kim@samsung.com)
* @version 1.0.0
* @history
* 2016.07.05 : Create
*/
#ifndef Exynos_OSAL_PLATFORM
#define Exynos_OSAL_PLATFORM
#include "OMX_Types.h"
#include "OMX_Core.h"
#include "OMX_Index.h"
#include "Exynos_OSAL_SharedMemory.h"
#include "Exynos_OSAL_Android.h"
#include "Exynos_OSAL_ImageConverter.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_ERRORTYPE Exynos_OSAL_GetParameter(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure);
OMX_ERRORTYPE Exynos_OSAL_SetParameter(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure);
OMX_ERRORTYPE Exynos_OSAL_GetConfig(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_INOUT OMX_PTR pComponentConfigStructure);
OMX_ERRORTYPE Exynos_OSAL_SetConfig(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure);
OMX_ERRORTYPE Exynos_OSAL_LockMetaData(OMX_IN OMX_PTR pBuffer,
OMX_IN EXYNOS_OMX_LOCK_RANGE range,
OMX_OUT OMX_U32 *pStride,
OMX_OUT EXYNOS_OMX_MULTIPLANE_BUFFER *pBufferInfo,
OMX_IN EXYNOS_METADATA_TYPE eMetaType);
OMX_ERRORTYPE Exynos_OSAL_UnlockMetaData(OMX_IN OMX_PTR pBuffer,
OMX_IN EXYNOS_METADATA_TYPE eMetaType);
OMX_ERRORTYPE Exynos_OSAL_GetInfoFromMetaData(OMX_IN OMX_PTR pBuffer, OMX_OUT EXYNOS_OMX_MULTIPLANE_BUFFER *pBufferInfo, OMX_IN EXYNOS_METADATA_TYPE eMetaDataType);
OMX_PTR Exynos_OSAL_AllocMetaDataBuffer(OMX_HANDLETYPE hSharedMemory, EXYNOS_METADATA_TYPE eMetaDataType, OMX_U32 nSizeBytes, MEMORY_TYPE eMemoryType);
OMX_ERRORTYPE Exynos_OSAL_FreeMetaDataBuffer(OMX_HANDLETYPE hSharedMemory, EXYNOS_METADATA_TYPE eMetaDataType, OMX_PTR pTempBuffer);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,201 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Queue.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_Mutex.h"
#include "Exynos_OSAL_Queue.h"
OMX_ERRORTYPE Exynos_OSAL_QueueCreate(EXYNOS_QUEUE *queueHandle, int maxNumElem)
{
int i = 0;
EXYNOS_QElem *newqelem = NULL;
EXYNOS_QElem *currentqelem = NULL;
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
OMX_ERRORTYPE ret = OMX_ErrorNone;
if (!queue)
return OMX_ErrorBadParameter;
ret = Exynos_OSAL_MutexCreate(&queue->qMutex);
if (ret != OMX_ErrorNone)
return ret;
queue->first = (EXYNOS_QElem *)Exynos_OSAL_Malloc(sizeof(EXYNOS_QElem));
if (queue->first == NULL)
return OMX_ErrorInsufficientResources;
Exynos_OSAL_Memset(queue->first, 0, sizeof(EXYNOS_QElem));
currentqelem = queue->last = queue->first;
queue->numElem = 0;
queue->maxNumElem = maxNumElem;
for (i = 0; i < (queue->maxNumElem - 2); i++) {
newqelem = (EXYNOS_QElem *)Exynos_OSAL_Malloc(sizeof(EXYNOS_QElem));
if (newqelem == NULL) {
while (queue->first != NULL) {
currentqelem = queue->first->qNext;
Exynos_OSAL_Free((OMX_PTR)queue->first);
queue->first = currentqelem;
}
return OMX_ErrorInsufficientResources;
} else {
Exynos_OSAL_Memset(newqelem, 0, sizeof(EXYNOS_QElem));
currentqelem->qNext = newqelem;
currentqelem = newqelem;
}
}
currentqelem->qNext = queue->first;
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_OSAL_QueueTerminate(EXYNOS_QUEUE *queueHandle)
{
int i = 0;
EXYNOS_QElem *currentqelem = NULL;
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
OMX_ERRORTYPE ret = OMX_ErrorNone;
if (!queue)
return OMX_ErrorBadParameter;
for ( i = 0; i < (queue->maxNumElem - 2); i++) {
if (queue->first == NULL)
goto EXIT;
currentqelem = queue->first->qNext;
Exynos_OSAL_Free(queue->first);
queue->first = currentqelem;
}
if(queue->first) {
Exynos_OSAL_Free(queue->first);
queue->first = NULL;
}
EXIT:
ret = Exynos_OSAL_MutexTerminate(queue->qMutex);
queue->qMutex = NULL;
return ret;
}
int Exynos_OSAL_Queue(EXYNOS_QUEUE *queueHandle, void *data)
{
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
if (queue == NULL)
return -1;
Exynos_OSAL_MutexLock(queue->qMutex);
if ((queue->last == NULL) ||
(queue->last->data != NULL) ||
(queue->numElem >= queue->maxNumElem)) {
Exynos_OSAL_MutexUnlock(queue->qMutex);
return -1;
}
queue->last->data = data;
queue->last = queue->last->qNext;
queue->numElem++;
Exynos_OSAL_MutexUnlock(queue->qMutex);
return 0;
}
void *Exynos_OSAL_Dequeue(EXYNOS_QUEUE *queueHandle)
{
void *data = NULL;
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
if (queue == NULL)
return NULL;
Exynos_OSAL_MutexLock(queue->qMutex);
if ((queue->first->data == NULL) || (queue->numElem <= 0)) {
Exynos_OSAL_MutexUnlock(queue->qMutex);
return NULL;
}
data = queue->first->data;
queue->first->data = NULL;
queue->first = queue->first->qNext;
queue->numElem--;
Exynos_OSAL_MutexUnlock(queue->qMutex);
return data;
}
int Exynos_OSAL_GetElemNum(EXYNOS_QUEUE *queueHandle)
{
int ElemNum = 0;
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
if (queue == NULL)
return -1;
Exynos_OSAL_MutexLock(queue->qMutex);
ElemNum = queue->numElem;
Exynos_OSAL_MutexUnlock(queue->qMutex);
return ElemNum;
}
int Exynos_OSAL_SetElemNum(EXYNOS_QUEUE *queueHandle, int ElemNum)
{
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
if (queue == NULL)
return -1;
Exynos_OSAL_MutexLock(queue->qMutex);
queue->numElem = ElemNum;
Exynos_OSAL_MutexUnlock(queue->qMutex);
return ElemNum;
}
int Exynos_OSAL_ResetQueue(EXYNOS_QUEUE *queueHandle)
{
EXYNOS_QUEUE *queue = (EXYNOS_QUEUE *)queueHandle;
EXYNOS_QElem *currentqelem = NULL;
if (queue == NULL)
return -1;
Exynos_OSAL_MutexLock(queue->qMutex);
queue->first->data = NULL;
currentqelem = queue->first->qNext;
while (currentqelem != queue->first) {
currentqelem->data = NULL;
currentqelem = currentqelem->qNext;
}
queue->last = queue->first;
queue->numElem = 0x00;
Exynos_OSAL_MutexUnlock(queue->qMutex);
return 0;
}

View File

@@ -0,0 +1,68 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Queue.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef EXYNOS_OSAL_QUEUE
#define EXYNOS_OSAL_QUEUE
#include "OMX_Types.h"
#include "OMX_Core.h"
#define QUEUE_ELEMENTS 10
#define MAX_QUEUE_ELEMENTS 40
typedef struct _EXYNOS_QElem
{
void *data;
struct _EXYNOS_QElem *qNext;
} EXYNOS_QElem;
typedef struct _EXYNOS_QUEUE
{
EXYNOS_QElem *first;
EXYNOS_QElem *last;
int numElem;
int maxNumElem;
OMX_HANDLETYPE qMutex;
} EXYNOS_QUEUE;
#ifdef __cplusplus
extern "C" {
#endif
OMX_ERRORTYPE Exynos_OSAL_QueueCreate(EXYNOS_QUEUE *queueHandle, int maxNumElem);
OMX_ERRORTYPE Exynos_OSAL_QueueTerminate(EXYNOS_QUEUE *queueHandle);
int Exynos_OSAL_Queue(EXYNOS_QUEUE *queueHandle, void *data);
void *Exynos_OSAL_Dequeue(EXYNOS_QUEUE *queueHandle);
int Exynos_OSAL_GetElemNum(EXYNOS_QUEUE *queueHandle);
int Exynos_OSAL_SetElemNum(EXYNOS_QUEUE *queueHandle, int ElemNum);
int Exynos_OSAL_ResetQueue(EXYNOS_QUEUE *queueHandle);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,161 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Semaphore.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <semaphore.h>
#include "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_Thread.h"
#include "Exynos_OSAL_Semaphore.h"
#undef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "EXYNOS_LOG_SEMA"
//#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
OMX_ERRORTYPE Exynos_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle)
{
sem_t *sema;
sema = (sem_t *)Exynos_OSAL_Malloc(sizeof(sem_t));
if (!sema)
return OMX_ErrorInsufficientResources;
if (sem_init(sema, 0, 0) != 0) {
Exynos_OSAL_Free(sema);
return OMX_ErrorUndefined;
}
*semaphoreHandle = (OMX_HANDLETYPE)sema;
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_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;
Exynos_OSAL_Free(sema);
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_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 Exynos_OSAL_SemaphoreTryWait(OMX_HANDLETYPE semaphoreHandle)
{
sem_t *sema = (sem_t *)semaphoreHandle;
FunctionIn();
if (sema == NULL)
return OMX_ErrorBadParameter;
if (sem_trywait(sema) != 0)
return OMX_ErrorUndefined;
FunctionOut();
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_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 Exynos_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val)
{
if (semaphoreHandle == NULL)
return OMX_ErrorBadParameter;
while (semaphoreHandle != NULL) {
OMX_S32 cnt = 0;
Exynos_OSAL_Get_SemaphoreCount(semaphoreHandle, &cnt);
if (cnt == val)
break;
else if (cnt > val)
Exynos_OSAL_SemaphoreWait(semaphoreHandle);
else if (cnt < val)
Exynos_OSAL_SemaphorePost(semaphoreHandle);
Exynos_OSAL_SleepMillisec(0);
}
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_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;
}

View File

@@ -0,0 +1,50 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Semaphore.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_SEMAPHORE
#define Exynos_OSAL_SEMAPHORE
#include "OMX_Types.h"
#include "OMX_Core.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_ERRORTYPE Exynos_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle);
OMX_ERRORTYPE Exynos_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle);
OMX_ERRORTYPE Exynos_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle);
OMX_ERRORTYPE Exynos_OSAL_SemaphoreTryWait(OMX_HANDLETYPE semaphoreHandle);
OMX_ERRORTYPE Exynos_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle);
OMX_ERRORTYPE Exynos_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val);
OMX_ERRORTYPE Exynos_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,546 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_SharedMemory.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* Jinsung Yang (jsgood.yang@samsung.com)
* Taehwan Kim (t_h.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <unistd.h>
#ifdef USE_ANDROID
#include <log/log.h>
#include <cutils/atomic.h>
#endif
#include <fcntl.h>
#include <sys/mman.h>
#include <hardware/exynos/ion.h>
#include "Exynos_OSAL_Mutex.h"
#include "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_SharedMemory.h"
#include "Exynos_OSAL_ETC.h"
//#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
static int mem_cnt = 0;
static int map_cnt = 0;
struct EXYNOS_SHAREDMEM_LIST;
typedef struct _EXYNOS_SHAREDMEM_LIST
{
unsigned long IONBuffer;
OMX_PTR mapAddr;
OMX_U32 allocSize;
OMX_BOOL owner;
struct _EXYNOS_SHAREDMEM_LIST *pNextMemory;
} EXYNOS_SHAREDMEM_LIST;
typedef struct _EXYNOS_SHARED_MEMORY
{
unsigned long hIONHandle;
EXYNOS_SHAREDMEM_LIST *pAllocMemory;
OMX_HANDLETYPE hSMMutex;
} EXYNOS_SHARED_MEMORY;
OMX_HANDLETYPE Exynos_OSAL_SharedMemory_Open()
{
EXYNOS_SHARED_MEMORY *pHandle = NULL;
long IONClient = -1;
pHandle = (EXYNOS_SHARED_MEMORY *)Exynos_OSAL_Malloc(sizeof(EXYNOS_SHARED_MEMORY));
if (pHandle == NULL)
goto EXIT;
Exynos_OSAL_Memset(pHandle, 0, sizeof(EXYNOS_SHARED_MEMORY));
IONClient = (long)exynos_ion_open();
if (IONClient < 0) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "ion_open is failed: %d", IONClient);
Exynos_OSAL_Free((void *)pHandle);
pHandle = NULL;
goto EXIT;
}
pHandle->hIONHandle = (unsigned long)IONClient;
if (OMX_ErrorNone != Exynos_OSAL_MutexCreate(&pHandle->hSMMutex)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_MutexCreate", __FUNCTION__);
/* free a ion_client */
exynos_ion_close(pHandle->hIONHandle);
pHandle->hIONHandle = 0;
Exynos_OSAL_Free((void *)pHandle);
pHandle = NULL;
}
EXIT:
return (OMX_HANDLETYPE)pHandle;
}
void Exynos_OSAL_SharedMemory_Close(OMX_HANDLETYPE handle)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
EXYNOS_SHAREDMEM_LIST *pDeleteElement = NULL;
if (pHandle == NULL)
goto EXIT;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pCurrentElement = pSMList = pHandle->pAllocMemory;
while (pCurrentElement != NULL) {
pDeleteElement = pCurrentElement;
pCurrentElement = pCurrentElement->pNextMemory;
/* if mmap was not called, mapAddr is same as IONBuffer */
if (pDeleteElement->mapAddr != (void *)pDeleteElement->IONBuffer) {
if (Exynos_OSAL_Munmap(pDeleteElement->mapAddr, pDeleteElement->allocSize))
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Munmap", __FUNCTION__);
}
pDeleteElement->mapAddr = NULL;
pDeleteElement->allocSize = 0;
if (pDeleteElement->owner) {
/* free a ion_buffer */
close(pDeleteElement->IONBuffer);
mem_cnt--;
}
pDeleteElement->IONBuffer = 0;
Exynos_OSAL_Free(pDeleteElement);
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, mem_cnt);
}
pHandle->pAllocMemory = pSMList = NULL;
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
Exynos_OSAL_MutexTerminate(pHandle->hSMMutex);
pHandle->hSMMutex = NULL;
/* free a ion_client */
exynos_ion_close(pHandle->hIONHandle);
pHandle->hIONHandle = 0;
Exynos_OSAL_Free(pHandle);
EXIT:
return;
}
OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMORY_TYPE memoryType)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pElement = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
long IONBuffer = -1;
OMX_PTR pBuffer = NULL;
unsigned int mask;
unsigned int flag;
if (pHandle == NULL)
goto EXIT;
pElement = (EXYNOS_SHAREDMEM_LIST *)Exynos_OSAL_Malloc(sizeof(EXYNOS_SHAREDMEM_LIST));
if (pElement == NULL)
goto EXIT;
Exynos_OSAL_Memset(pElement, 0, sizeof(EXYNOS_SHAREDMEM_LIST));
pElement->owner = OMX_TRUE;
/* priority is like as EXT > SECURE > CONTIG > CACHED > NORMAL */
switch ((int)memoryType) {
case (EXT_MEMORY | SECURE_MEMORY | CONTIG_MEMORY | CACHED_MEMORY): /* EXTRA */
case (EXT_MEMORY | SECURE_MEMORY | CONTIG_MEMORY):
case (EXT_MEMORY | SECURE_MEMORY | CACHED_MEMORY):
case (EXT_MEMORY | SECURE_MEMORY):
mask = EXYNOS_ION_HEAP_VIDEO_STREAM_MASK;
flag = ION_FLAG_PROTECTED;
break;
case (EXT_MEMORY | CONTIG_MEMORY | CACHED_MEMORY):
case (EXT_MEMORY | CONTIG_MEMORY):
case (EXT_MEMORY | CACHED_MEMORY):
case EXT_MEMORY:
mask = EXYNOS_ION_HEAP_VIDEO_STREAM_MASK;
flag = 0;
break;
case (SECURE_MEMORY | CONTIG_MEMORY | CACHED_MEMORY): /* SECURE */
case (SECURE_MEMORY | CONTIG_MEMORY):
case (SECURE_MEMORY | CACHED_MEMORY):
case SECURE_MEMORY:
mask = EXYNOS_ION_HEAP_VIDEO_STREAM_MASK;
flag = ION_FLAG_PROTECTED;
break;
case (CONTIG_MEMORY | CACHED_MEMORY): /* CONTIG */
case CONTIG_MEMORY:
mask = EXYNOS_ION_HEAP_VIDEO_STREAM_MASK;
flag = 0;
break;
case CACHED_MEMORY: /* CACHED */
mask = EXYNOS_ION_HEAP_SYSTEM_MASK;
flag = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
break;
default: /* NORMAL */
// NOTE: cached?
mask = EXYNOS_ION_HEAP_SYSTEM_MASK;
flag = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
break;
}
if (flag & ION_FLAG_CACHED) /* use improved cache oprs */
flag |= ION_FLAG_CACHED_NEEDS_SYNC;
if ((IONBuffer = exynos_ion_alloc(pHandle->hIONHandle, size, mask, flag)) < 0) {
Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "[%s] Failed to exynos_ion_alloc(mask:%x, flag:%x)", __FUNCTION__, mask, flag);
if (memoryType == CONTIG_MEMORY) {
/* retry at normal area */
flag = 0;
if ((IONBuffer = exynos_ion_alloc(pHandle->hIONHandle, size, mask, flag)) < 0) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] retry: Failed to exynos_ion_alloc(mask:%x, flag:%x)", __FUNCTION__, mask, flag);
Exynos_OSAL_Free((OMX_PTR)pElement);
goto EXIT;
}
}
}
if (flag & ION_FLAG_PROTECTED) {
/* in case of DRM, do not call mmap. so set a fd instead of vaddr */
pBuffer = (OMX_PTR)IONBuffer;
} else {
pBuffer = Exynos_OSAL_Mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, IONBuffer, 0);
if (pBuffer == MAP_FAILED) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Mmap(size:%d)", __FUNCTION__, size);
/* free a ion_buffer */
close(IONBuffer); // NOTE: argument to exynos_ion_close/ion_close() should be allocated by ion_open/exynos_ion_open
Exynos_OSAL_Free((OMX_PTR)pElement);
pBuffer = NULL;
goto EXIT;
}
}
pElement->IONBuffer = (unsigned long)IONBuffer;
pElement->mapAddr = pBuffer;
pElement->allocSize = size;
pElement->pNextMemory = NULL;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pSMList = pHandle->pAllocMemory;
if (pSMList == NULL) {
pHandle->pAllocMemory = pSMList = pElement;
} else {
pCurrentElement = pSMList;
while (pCurrentElement->pNextMemory != NULL) {
pCurrentElement = pCurrentElement->pNextMemory;
}
pCurrentElement->pNextMemory = pElement;
}
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
mem_cnt++;
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, mem_cnt);
EXIT:
return pBuffer;
}
void Exynos_OSAL_SharedMemory_Free(OMX_HANDLETYPE handle, OMX_PTR pBuffer)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
EXYNOS_SHAREDMEM_LIST *pDeleteElement = NULL;
if (pHandle == NULL)
goto EXIT;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pSMList = pHandle->pAllocMemory;
if (pSMList == NULL) {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
goto EXIT;
}
pCurrentElement = pSMList;
if (pSMList->mapAddr == pBuffer) {
pDeleteElement = pSMList;
pHandle->pAllocMemory = pSMList = pSMList->pNextMemory;
} else {
while ((pCurrentElement != NULL) && (((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->mapAddr != pBuffer))
pCurrentElement = pCurrentElement->pNextMemory;
if ((((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->mapAddr == pBuffer)) {
pDeleteElement = pCurrentElement->pNextMemory;
pCurrentElement->pNextMemory = pDeleteElement->pNextMemory;
} else {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] can't find a buffer(%p) in list", __FUNCTION__, pBuffer);
goto EXIT;
}
}
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
if (pDeleteElement->mapAddr != (void *)pDeleteElement->IONBuffer) {
if (Exynos_OSAL_Munmap(pDeleteElement->mapAddr, pDeleteElement->allocSize)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Munmap", __FUNCTION__);
goto EXIT;
}
}
pDeleteElement->mapAddr = NULL;
pDeleteElement->allocSize = 0;
if (pDeleteElement->owner) {
/* free a ion_buffer */
close(pDeleteElement->IONBuffer);
mem_cnt--;
}
pDeleteElement->IONBuffer = 0;
Exynos_OSAL_Free(pDeleteElement);
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, mem_cnt);
EXIT:
return;
}
OMX_PTR Exynos_OSAL_SharedMemory_Map(OMX_HANDLETYPE handle, OMX_U32 size, unsigned long ionfd)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pElement = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
OMX_S32 IONBuffer = 0;
OMX_PTR pBuffer = NULL;
if (pHandle == NULL) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] invalid parameter", __FUNCTION__);
goto EXIT;
}
pElement = (EXYNOS_SHAREDMEM_LIST *)Exynos_OSAL_Malloc(sizeof(EXYNOS_SHAREDMEM_LIST));
if (pElement == NULL) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Malloc()", __FUNCTION__);
goto EXIT;
}
Exynos_OSAL_Memset(pElement, 0, sizeof(EXYNOS_SHAREDMEM_LIST));
IONBuffer = (OMX_S32)ionfd;
if (IONBuffer < 0) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] FD(%u) is wrong", __FUNCTION__, IONBuffer);
Exynos_OSAL_Free((void*)pElement);
goto EXIT;
}
pBuffer = Exynos_OSAL_Mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, IONBuffer, 0);
if (pBuffer == NULL) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Mmap(size:%d)", __FUNCTION__, size);
/* free a ion_buffer */
close(IONBuffer);
Exynos_OSAL_Free((void*)pElement);
goto EXIT;
}
pElement->IONBuffer = IONBuffer;
pElement->mapAddr = pBuffer;
pElement->allocSize = size;
pElement->pNextMemory = NULL;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pSMList = pHandle->pAllocMemory;
if (pSMList == NULL) {
pHandle->pAllocMemory = pSMList = pElement;
} else {
pCurrentElement = pSMList;
while (pCurrentElement->pNextMemory != NULL) {
pCurrentElement = pCurrentElement->pNextMemory;
}
pCurrentElement->pNextMemory = pElement;
}
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
map_cnt++;
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, map_cnt);
EXIT:
return pBuffer;
}
void Exynos_OSAL_SharedMemory_Unmap(OMX_HANDLETYPE handle, unsigned long ionfd)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
EXYNOS_SHAREDMEM_LIST *pDeleteElement = NULL;
if (pHandle == NULL)
goto EXIT;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pSMList = pHandle->pAllocMemory;
if (pSMList == NULL) {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
goto EXIT;
}
pCurrentElement = pSMList;
if (pSMList->IONBuffer == ionfd) {
pDeleteElement = pSMList;
pHandle->pAllocMemory = pSMList = pSMList->pNextMemory;
} else {
while ((pCurrentElement != NULL) && (((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->IONBuffer != ionfd))
pCurrentElement = pCurrentElement->pNextMemory;
if ((((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->IONBuffer == ionfd)) {
pDeleteElement = pCurrentElement->pNextMemory;
pCurrentElement->pNextMemory = pDeleteElement->pNextMemory;
} else {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] can't find a buffer(%u) in list", __FUNCTION__, ionfd);
goto EXIT;
}
}
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
if (Exynos_OSAL_Munmap(pDeleteElement->mapAddr, pDeleteElement->allocSize)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "[%s] Failed to Exynos_OSAL_Munmap", __FUNCTION__);
goto EXIT;
}
pDeleteElement->mapAddr = NULL;
pDeleteElement->allocSize = 0;
pDeleteElement->IONBuffer = 0;
Exynos_OSAL_Free(pDeleteElement);
map_cnt--;
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] count: %d", __FUNCTION__, map_cnt);
EXIT:
return;
}
unsigned long Exynos_OSAL_SharedMemory_VirtToION(OMX_HANDLETYPE handle, OMX_PTR pBuffer)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
EXYNOS_SHAREDMEM_LIST *pFindElement = NULL;
unsigned long ion_addr = 0;
if (pHandle == NULL || pBuffer == NULL)
goto EXIT;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pSMList = pHandle->pAllocMemory;
if (pSMList == NULL) {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
goto EXIT;
}
pCurrentElement = pSMList;
if (pSMList->mapAddr == pBuffer) {
pFindElement = pSMList;
} else {
while ((pCurrentElement != NULL) && (((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->mapAddr != pBuffer))
pCurrentElement = pCurrentElement->pNextMemory;
if ((((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->mapAddr == pBuffer)) {
pFindElement = pCurrentElement->pNextMemory;
} else {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] can't find a buffer(%p) in list", __FUNCTION__, pBuffer);
goto EXIT;
}
}
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
ion_addr = pFindElement->IONBuffer;
EXIT:
return ion_addr;
}
OMX_PTR Exynos_OSAL_SharedMemory_IONToVirt(OMX_HANDLETYPE handle, unsigned long ionfd)
{
EXYNOS_SHARED_MEMORY *pHandle = (EXYNOS_SHARED_MEMORY *)handle;
EXYNOS_SHAREDMEM_LIST *pSMList = NULL;
EXYNOS_SHAREDMEM_LIST *pCurrentElement = NULL;
EXYNOS_SHAREDMEM_LIST *pFindElement = NULL;
OMX_PTR pBuffer = NULL;
if ((pHandle == NULL) || ((long)ionfd < 0))
goto EXIT;
Exynos_OSAL_MutexLock(pHandle->hSMMutex);
pSMList = pHandle->pAllocMemory;
if (pSMList == NULL) {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
goto EXIT;
}
pCurrentElement = pSMList;
if (pSMList->IONBuffer == ionfd) {
pFindElement = pSMList;
} else {
while ((pCurrentElement != NULL) && (((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->IONBuffer != ionfd))
pCurrentElement = pCurrentElement->pNextMemory;
if ((((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory)) != NULL) &&
(((EXYNOS_SHAREDMEM_LIST *)(pCurrentElement->pNextMemory))->IONBuffer == ionfd)) {
pFindElement = pCurrentElement->pNextMemory;
} else {
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "[%s] can't find a buffer(%u) in list", __FUNCTION__, ionfd);
goto EXIT;
}
}
Exynos_OSAL_MutexUnlock(pHandle->hSMMutex);
pBuffer = pFindElement->mapAddr;
EXIT:
return pBuffer;
}

View File

@@ -0,0 +1,61 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_SharedMemory.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* Taehwan Kim (t_h.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef EXYNOS_OSAL_SHAREDMEMORY
#define EXYNOS_OSAL_SHAREDMEMORY
#include "OMX_Types.h"
typedef enum _MEMORY_TYPE
{
NORMAL_MEMORY = 0x00,
CACHED_MEMORY = 0x01, /* cached */
CONTIG_MEMORY = 0x02, /* continuos */
SECURE_MEMORY = 0x04, /* secure */
EXT_MEMORY = 0x08, /* ext area */
} MEMORY_TYPE;
#ifdef __cplusplus
extern "C" {
#endif
OMX_HANDLETYPE Exynos_OSAL_SharedMemory_Open();
void Exynos_OSAL_SharedMemory_Close(OMX_HANDLETYPE handle);
OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMORY_TYPE memoryType);
void Exynos_OSAL_SharedMemory_Free(OMX_HANDLETYPE handle, OMX_PTR pBuffer);
unsigned long Exynos_OSAL_SharedMemory_VirtToION(OMX_HANDLETYPE handle, OMX_PTR pBuffer);
OMX_PTR Exynos_OSAL_SharedMemory_IONToVirt(OMX_HANDLETYPE handle, unsigned long ionfd);
OMX_PTR Exynos_OSAL_SharedMemory_Map(OMX_HANDLETYPE handle, OMX_U32 size, unsigned long ionfd);
void Exynos_OSAL_SharedMemory_Unmap(OMX_HANDLETYPE handle, unsigned long ionfd);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2012 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 Exynos_OSAL_SkypeHD.h
* @brief
* @author Seungbeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2015.04.27 : Create
*/
#ifndef Exynos_OSAL_SKYPEHD
#define Exynos_OSAL_SKYPEHD
#include "OMX_Types.h"
#include "OMX_Core.h"
#include "OMX_Index.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef BUILD_ENC
/* ENCODE_ONLY */
OMX_ERRORTYPE Exynos_H264Enc_GetParameter_SkypeHD(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure);
OMX_ERRORTYPE Exynos_H264Enc_SetParameter_SkypeHD(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentParameterStructure);
OMX_ERRORTYPE Exynos_H264Enc_GetConfig_SkypeHD(OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure);
OMX_ERRORTYPE Exynos_H264Enc_SetConfig_SkypeHD(OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure);
OMX_ERRORTYPE Change_H264Enc_SkypeHDParam(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR pDynamicConfigCMD);
#endif
#ifdef BUILD_DEC
/* DECODE_ONLY */
OMX_ERRORTYPE Exynos_H264Dec_GetParameter_SkypeHD(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure);
OMX_ERRORTYPE Exynos_H264Dec_SetParameter_SkypeHD(OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentParameterStructure);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,184 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Thread.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : 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 "Exynos_OSAL_Memory.h"
#include "Exynos_OSAL_Thread.h"
#undef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "EXYNOS_LOG_THREAD"
//#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
typedef struct _EXYNOS_THREAD_HANDLE_TYPE
{
pthread_t pthread;
pthread_attr_t attr;
struct sched_param schedparam;
int stack_size;
} EXYNOS_THREAD_HANDLE_TYPE;
OMX_ERRORTYPE Exynos_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument)
{
FunctionIn();
int result = 0;
int detach_ret = 0;
EXYNOS_THREAD_HANDLE_TYPE *thread;
OMX_ERRORTYPE ret = OMX_ErrorNone;
thread = Exynos_OSAL_Malloc(sizeof(EXYNOS_THREAD_HANDLE_TYPE));
if (thread == NULL) {
ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
Exynos_OSAL_Memset(thread, 0, sizeof(EXYNOS_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) {
Exynos_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:
Exynos_OSAL_Free(thread);
*threadHandle = NULL;
ret = OMX_ErrorInsufficientResources;
break;
default:
Exynos_OSAL_Free(thread);
*threadHandle = NULL;
ret = OMX_ErrorUndefined;
break;
}
EXIT:
FunctionOut();
return ret;
}
OMX_ERRORTYPE Exynos_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle)
{
FunctionIn();
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_THREAD_HANDLE_TYPE *thread = (EXYNOS_THREAD_HANDLE_TYPE *)threadHandle;
if (!thread) {
ret = OMX_ErrorBadParameter;
goto EXIT;
}
if (pthread_join(thread->pthread, NULL) != 0) {
ret = OMX_ErrorUndefined;
goto EXIT;
}
Exynos_OSAL_Free(thread);
ret = OMX_ErrorNone;
EXIT:
FunctionOut();
return ret;
}
OMX_ERRORTYPE Exynos_OSAL_ThreadDetach(OMX_HANDLETYPE threadHandle)
{
EXYNOS_THREAD_HANDLE_TYPE *thread = (EXYNOS_THREAD_HANDLE_TYPE *)threadHandle;
if (!thread)
return OMX_ErrorBadParameter;
if (pthread_detach(thread->pthread) != 0)
return OMX_ErrorUndefined;
Exynos_OSAL_Free(thread);
return OMX_ErrorNone;
}
OMX_ERRORTYPE Exynos_OSAL_ThreadCancel(OMX_HANDLETYPE threadHandle)
{
EXYNOS_THREAD_HANDLE_TYPE *thread = (EXYNOS_THREAD_HANDLE_TYPE *)threadHandle;
if (!thread)
return OMX_ErrorBadParameter;
/* android doesn't support this function */
//pthread_cancel(thread->pthread);
Exynos_OSAL_Free(thread);
return OMX_ErrorNone;
}
void Exynos_OSAL_ThreadExit(void *value_ptr)
{
pthread_exit(value_ptr);
return;
}
void Exynos_OSAL_SleepMillisec(OMX_U32 ms)
{
if (ms == 0) {
sched_yield();
} else {
struct timespec time;
time.tv_sec = (time_t)(ms / 1000);
time.tv_nsec = (long)(ms % 1000) * 1000000;
nanosleep(&time, NULL);
}
return;
}

View File

@@ -0,0 +1,49 @@
/*
*
* Copyright 2012 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 Exynos_OSAL_Thread.h
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#ifndef Exynos_OSAL_THREAD
#define Exynos_OSAL_THREAD
#include "OMX_Types.h"
#include "OMX_Core.h"
#ifdef __cplusplus
extern "C" {
#endif
OMX_ERRORTYPE Exynos_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument);
OMX_ERRORTYPE Exynos_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle);
OMX_ERRORTYPE Exynos_OSAL_ThreadDetach(OMX_HANDLETYPE threadHandle);
OMX_ERRORTYPE Exynos_OSAL_ThreadCancel(OMX_HANDLETYPE threadHandle);
void Exynos_OSAL_ThreadExit(void *value_ptr);
void Exynos_OSAL_SleepMillisec(OMX_U32 ms);
#ifdef __cplusplus
}
#endif
#endif

190
openmax/osal/NOTICE Normal file
View File

@@ -0,0 +1,190 @@
Copyright (c) 2014, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS