From c3e0af6f8857ca153c96d976dc58d1eab3001cec Mon Sep 17 00:00:00 2001 From: Jiho Chang Date: Thu, 26 Apr 2012 13:52:52 -0700 Subject: [PATCH] hardware: exynos5: update libexynosutils dir Change-Id: I1ea6d1cac561b026b8597f918290d1f13b86a419 Signed-off-by: Dima Zavin --- libexynosutils/Android.mk | 3 +- libexynosutils/ExynosMutex.cpp | 109 +++++++++++++++++---------- libexynosutils/ExynosMutex.h | 42 ++++------- libexynosutils/Exynos_log.c | 50 ++++++++++++ libexynosutils/Exynos_log.h | 48 ++++++++++++ libexynosutils/exynos5_format_v4l2.c | 2 +- 6 files changed, 183 insertions(+), 71 deletions(-) create mode 100644 libexynosutils/Exynos_log.c create mode 100644 libexynosutils/Exynos_log.h diff --git a/libexynosutils/Android.mk b/libexynosutils/Android.mk index aa973a7..627e823 100644 --- a/libexynosutils/Android.mk +++ b/libexynosutils/Android.mk @@ -24,7 +24,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include LOCAL_C_INCLUDES += framework/base/include -LOCAL_SRC_FILES := ExynosMutex.cpp +LOCAL_SRC_FILES := ExynosMutex.cpp \ + Exynos_log.c LOCAL_MODULE_TAGS := eng LOCAL_MODULE := libexynosutils diff --git a/libexynosutils/ExynosMutex.cpp b/libexynosutils/ExynosMutex.cpp index c3b3aa9..c0020ed 100644 --- a/libexynosutils/ExynosMutex.cpp +++ b/libexynosutils/ExynosMutex.cpp @@ -42,12 +42,28 @@ using namespace android; //#define EXYNOS_MUTEX_DEBUG -ExynosMutex::ExynosMutex( - int type, - char* name) +ExynosMutex::ExynosMutex() { - int androidMutexType = 0; m_mutex = NULL; + m_flagCreate = false; + m_type = TYPE_BASE; +} + +ExynosMutex::~ExynosMutex() +{ + if (m_flagCreate == true) + this->destroy(); +} + +bool ExynosMutex::create(int type, char* name) +{ + if (m_flagCreate == true) { + ALOGE("%s::Already created", __func__); + return false; + } + + int androidMutexType = 0; + m_type = TYPE_BASE; switch (type) { @@ -59,37 +75,53 @@ ExynosMutex::ExynosMutex( break; default: ALOGE("%s::unmatched type(%d) fail", __func__, type); - break; + return false; } m_mutex = new Mutex(androidMutexType, name); if (m_mutex == NULL) { ALOGE("%s::Mutex create fail", __func__); + return false; } m_type = type; strcpy(m_name, name); + + m_flagCreate = true; + + return true; } -ExynosMutex::~ExynosMutex() +void ExynosMutex::destroy(void) { + if (m_flagCreate == false) { + ALOGE("%s::Not yet created", __func__); + return; + } + if (m_mutex) delete ((Mutex *)m_mutex); m_mutex = NULL; + + m_flagCreate = false; } -bool ExynosMutex::lock( - void) +bool ExynosMutex::getCreatedStatus(void) { -#ifdef EXYNOS_MUTEX_DEBUG - ALOGD("%s::%s'lock() start", __func__, m_name); -#endif + return m_flagCreate; +} - if (m_mutex == NULL) { - ALOGE("%s::Mutex create fail", __func__); +bool ExynosMutex::lock(void) +{ + if (m_flagCreate == false) { + ALOGE("%s::Not yet created", __func__); return false; } +#ifdef EXYNOS_MUTEX_DEBUG + ALOGD("%s::%s'lock() start", __func__, m_name); +#endif + if (((Mutex *)m_mutex)->lock() != 0) { ALOGE("%s::m_core->lock() fail", __func__); return false; @@ -102,18 +134,17 @@ bool ExynosMutex::lock( return true; } -bool ExynosMutex::unLock( - void) +bool ExynosMutex::unLock(void) { + if (m_flagCreate == false) { + ALOGE("%s::Not yet created", __func__); + return false; + } + #ifdef EXYNOS_MUTEX_DEBUG ALOGD("%s::%s'unlock() start", __func__, m_name); #endif - if (m_mutex == NULL) { - ALOGE("%s::Mutex create fail", __func__); - return false; - } - ((Mutex *)m_mutex)->unlock(); #ifdef EXYNOS_MUTEX_DEBUG @@ -123,20 +154,19 @@ bool ExynosMutex::unLock( return true; } -bool ExynosMutex::tryLock( - void) +bool ExynosMutex::tryLock(void) { + if (m_flagCreate == false) { + ALOGE("%s::Not yet created", __func__); + return false; + } + int ret = 0; #ifdef EXYNOS_MUTEX_DEBUG ALOGD("%s::%s'trylock() start", __func__, m_name); #endif - if (m_mutex == NULL) { - ALOGE("%s::Mutex create fail", __func__); - return false; - } - ret = ((Mutex *)m_mutex)->tryLock(); #ifdef EXYNOS_MUTEX_DEBUG @@ -146,26 +176,22 @@ bool ExynosMutex::tryLock( return (ret == 0) ? true : false; } -int ExynosMutex::getType( - void) +int ExynosMutex::getType(void) { return m_type; } -int ExynosMutex::getCreatedStatus( - void) -{ - if (m_mutex == NULL) - return STATUS_NOT_CREATED; - else - return STATUS_CREATED; -} - void *exynos_mutex_create( int type, char *name) { - ExynosMutex *mutex = new ExynosMutex(type, name); + ExynosMutex *mutex = new ExynosMutex(); + + if (mutex->create(type, name) == false) { + ALOGE("%s::mutex->create() fail", __func__); + delete mutex; + mutex = NULL; + } return (void*)mutex; } @@ -178,6 +204,9 @@ bool exynos_mutex_destroy( return false; } + if (((ExynosMutex *)handle)->getCreatedStatus() == true) + ((ExynosMutex *)handle)->destroy(); + delete (ExynosMutex *)handle; return true; @@ -230,7 +259,7 @@ int exynos_mutex_get_type( return ((ExynosMutex *)handle)->getType(); } -int exynos_mutex_get_created_status( +bool exynos_mutex_get_created_status( void *handle) { if (handle == NULL) { diff --git a/libexynosutils/ExynosMutex.h b/libexynosutils/ExynosMutex.h index d2f346e..6ce7a2a 100644 --- a/libexynosutils/ExynosMutex.h +++ b/libexynosutils/ExynosMutex.h @@ -26,19 +26,6 @@ * */ -/** - * @page ExynosMutex - * - * @section Introduction - * ExynosMutex is for locking and making thread-safe operation - * - * @section Copyright - * Copyright (c) 2008-2011 Samsung Electronics Co., Ltd.All rights reserved. \n - * Proprietary and Confidential - * - * @image html samsung.png - */ - #ifndef __EXYNOS_MUTEX_H__ #define __EXYNOS_MUTEX_H__ @@ -58,18 +45,22 @@ public: TYPE_MAX, }; - enum STATUS { - STATUS_NOT_CREATED = 0, - STATUS_CREATED - }; - public: - //! Constructor - ExynosMutex(int type, char* name); + //! Constructor. + ExynosMutex(); //! Destructor virtual ~ExynosMutex(); + //! Create Mutex + bool create(int type, char* name); + + //! Destroy Mutex + void destroy(void); + + //! Get Mutex created status + bool getCreatedStatus(void); + //! Lock Mutex bool lock(void); @@ -82,11 +73,9 @@ public: //! Get Mutex type int getType(void); - //! Get Mutex created status - int getCreatedStatus(void); - private: void *m_mutex; + bool m_flagCreate; int m_type; char m_name[128]; @@ -121,11 +110,6 @@ enum EXYNOS_MUTEX_TYPE { EXYNOS_MUTEX_TYPE_MAX, }; -enum EXYNOS_MUTEX_STATUS { - EXYNOS_MUTEX_STATUS_NOT_CREATED = 0, - EXYNOS_MUTEX_STATUS_CREATED -}; - void *exynos_mutex_create( int type, char *name); @@ -145,7 +129,7 @@ bool exynos_mutex_trylock( int exynos_mutex_type( void *handle); -int exynos_mutex_get_created_status( +bool exynos_mutex_get_created_status( void *handle); #ifdef __cplusplus diff --git a/libexynosutils/Exynos_log.c b/libexynosutils/Exynos_log.c new file mode 100644 index 0000000..a8c96c0 --- /dev/null +++ b/libexynosutils/Exynos_log.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 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. + * 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. + */ + +/* + * + * @author Yongbae, Song(yb.song@samsung.com) + * + * @date 2012-04-02 + * + */ + +#include + +#include "Exynos_log.h" + +void Exynos_Log(EXYNOS_DEV_LOG_LEVEL logLevel, const char *tag, const char *msg, ...) +{ + va_list argptr; + + va_start(argptr, msg); + + switch (logLevel) { + case EXYNOS_DEV_LOG_DEBUG: + __android_log_vprint(ANDROID_LOG_DEBUG, tag, msg, argptr); + break; + case EXYNOS_DEV_LOG_WARNING: + __android_log_vprint(ANDROID_LOG_WARN, tag, msg, argptr); + break; + case EXYNOS_DEV_LOG_ERROR: + __android_log_vprint(ANDROID_LOG_ERROR, tag, msg, argptr); + break; + default: + __android_log_vprint(ANDROID_LOG_VERBOSE, tag, msg, argptr); + } + + va_end(argptr); +} diff --git a/libexynosutils/Exynos_log.h b/libexynosutils/Exynos_log.h new file mode 100644 index 0000000..8e90219 --- /dev/null +++ b/libexynosutils/Exynos_log.h @@ -0,0 +1,48 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * @file Exynos_log.h + * @brief + * @author Yongbae, Song(yb.songsamsung.com) + * @version 1.0.0 + * @history + * 2012.4.02 : Create + */ + +#ifndef EXYNOS_LOG +#define EXYNOS_LOG + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + EXYNOS_DEV_LOG_DEBUG, + EXYNOS_DEV_LOG_INFO, + EXYNOS_DEV_LOG_WARNING, + EXYNOS_DEV_LOG_ERROR +} EXYNOS_DEV_LOG_LEVEL; + +void Exynos_Log(EXYNOS_DEV_LOG_LEVEL logLevel, const char *tag, const char *msg, ...); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libexynosutils/exynos5_format_v4l2.c b/libexynosutils/exynos5_format_v4l2.c index 0dd08c5..6f869dd 100644 --- a/libexynosutils/exynos5_format_v4l2.c +++ b/libexynosutils/exynos5_format_v4l2.c @@ -42,7 +42,7 @@ #include "s5p_fimc_v4l2.h" #include #include "videodev2.h" -#include "videodev2_exynos.h" +#include "videodev2_exynos_media.h" int HAL_PIXEL_FORMAT_2_V4L2_PIX( int hal_pixel_format) -- 2.20.1