hardware: exynos5: update libexynosutils dir
authorJiho Chang <jiho04.chang@samsung.com>
Thu, 26 Apr 2012 20:52:52 +0000 (13:52 -0700)
committerDima Zavin <dima@android.com>
Fri, 27 Apr 2012 06:21:05 +0000 (23:21 -0700)
Change-Id: I1ea6d1cac561b026b8597f918290d1f13b86a419
Signed-off-by: Dima Zavin <dima@android.com>
libexynosutils/Android.mk
libexynosutils/ExynosMutex.cpp
libexynosutils/ExynosMutex.h
libexynosutils/Exynos_log.c [new file with mode: 0644]
libexynosutils/Exynos_log.h [new file with mode: 0644]
libexynosutils/exynos5_format_v4l2.c

index aa973a7ee68fbd2707e64c0b5b1c51d688247027..627e823b198b903d9d0a45df73de26eb10691615 100644 (file)
@@ -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
index c3b3aa983e5accc218afa05b4a1cd4e194ca5934..c0020ed8a09ace575bd9cec4d042f3c7de169d11 100644 (file)
@@ -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) {
index d2f346e364fe7ec8f101c2df666be3771ff0da50..6ce7a2a418e5b87082d9b428568693e118366bbf 100644 (file)
  *
  */
 
-/**
- * @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 (file)
index 0000000..a8c96c0
--- /dev/null
@@ -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 <utils/Log.h>
+
+#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 (file)
index 0000000..8e90219
--- /dev/null
@@ -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
index 0dd08c53cdb8b147554422aa82747a837cffcebb..6f869dde74b90dbb09a99792d2425c3cf36b4081 100644 (file)
@@ -42,7 +42,7 @@
 #include "s5p_fimc_v4l2.h"
 #include <utils/Log.h>
 #include "videodev2.h"
-#include "videodev2_exynos.h"
+#include "videodev2_exynos_media.h"
 
 int HAL_PIXEL_FORMAT_2_V4L2_PIX(
     int hal_pixel_format)