libexynosutils has moved from hardware/samsung_slsi/exynos5
authorYunji Kim <yunji.kim@samsung.com>
Fri, 12 Oct 2012 10:23:40 +0000 (10:23 +0000)
committerHuisung Kang <hs1218.kang@samsung.com>
Sun, 28 Oct 2012 22:42:22 +0000 (07:42 +0900)
Change-Id: Ifc16d02e2d68a705fba9b105080e210157ffde08
Signed-off-by: Yunji Kim <yunji.kim@samsung.com>
Android.mk
libexynosutils/Android.mk [new file with mode: 0644]
libexynosutils/ExynosMutex.cpp [new file with mode: 0644]
libexynosutils/ExynosMutex.h [new file with mode: 0644]
libexynosutils/Exynos_log.c [new file with mode: 0644]
libexynosutils/Exynos_log.h [new file with mode: 0644]
libexynosutils/exynos5_format_v4l2.c [new file with mode: 0644]

index 34cf63d9cd91df9f0f7ea5a854b0a39679e3d224..c25647522ca231e0d3cf61c06f8952aede7521fc 100644 (file)
@@ -16,6 +16,7 @@
 
 common_exynos_dirs := \
        libcsc \
-       libv4l2
+       libv4l2 \
+       libexynosutils
 
 include $(call all-named-subdir-makefiles,$(common_exynos_dirs))
diff --git a/libexynosutils/Android.mk b/libexynosutils/Android.mk
new file mode 100644 (file)
index 0000000..627e823
--- /dev/null
@@ -0,0 +1,39 @@
+# Copyright (C) 2008 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_SHARED_LIBRARIES := liblog libutils libcutils
+
+LOCAL_CFLAGS += -DEXYNOS_PLATFORM_ON_ANDROID
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
+LOCAL_C_INCLUDES += framework/base/include
+
+LOCAL_SRC_FILES := ExynosMutex.cpp \
+                  Exynos_log.c
+
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := libexynosutils
+
+ifeq ($(TARGET_BOARD_PLATFORM), exynos5)
+LOCAL_SRC_FILES += exynos5_format_v4l2.c
+LOCAL_C_INCLUDES += \
+       $(LOCAL_PATH)/../include
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libexynosutils/ExynosMutex.cpp b/libexynosutils/ExynosMutex.cpp
new file mode 100644 (file)
index 0000000..c0020ed
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * Copyright@ Samsung Electronics 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      ExynosMutex.cpp
+ * \brief     source file for ExynosMutex
+ * \author    Sangwoo, Park(sw5771.park@samsung.com)
+ * \date      2011/06/15
+ *
+ * <b>Revision History: </b>
+ * - 2010/06/15 : Sangwoo, Park(sw5771.park@samsung.com) \n
+ *   Initial version
+ *
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "ExynosMutex"
+#include <utils/Log.h>
+
+#include <utils/threads.h>
+using namespace android;
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ExynosMutex.h"
+
+//#define EXYNOS_MUTEX_DEBUG
+
+ExynosMutex::ExynosMutex()
+{
+    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) {
+    case TYPE_PRIVATE:
+        androidMutexType = Mutex::PRIVATE;
+        break;
+    case TYPE_SHARED:
+        androidMutexType = Mutex::SHARED;
+        break;
+    default:
+        ALOGE("%s::unmatched type(%d) fail", __func__, type);
+        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;
+}
+
+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::getCreatedStatus(void)
+{
+    return m_flagCreate;
+}
+
+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;
+    }
+
+#ifdef EXYNOS_MUTEX_DEBUG
+    ALOGD("%s::%s'lock() end", __func__, m_name);
+#endif
+
+    return true;
+}
+
+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
+
+    ((Mutex *)m_mutex)->unlock();
+
+#ifdef EXYNOS_MUTEX_DEBUG
+    ALOGD("%s::%s'unlock() end", __func__, m_name);
+#endif
+
+    return true;
+}
+
+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
+
+    ret = ((Mutex *)m_mutex)->tryLock();
+
+#ifdef EXYNOS_MUTEX_DEBUG
+    ALOGD("%s::%s'trylock() end", __func__, m_name);
+#endif
+
+    return (ret == 0) ? true : false;
+}
+
+int ExynosMutex::getType(void)
+{
+    return m_type;
+}
+
+void *exynos_mutex_create(
+    int type,
+    char *name)
+{
+    ExynosMutex *mutex = new ExynosMutex();
+
+    if (mutex->create(type, name) == false) {
+        ALOGE("%s::mutex->create() fail", __func__);
+        delete mutex;
+        mutex = NULL;
+    }
+
+    return (void*)mutex;
+}
+
+bool exynos_mutex_destroy(
+    void *handle)
+{
+    if (handle == NULL) {
+        ALOGE("%s::handle is null", __func__);
+        return false;
+    }
+
+    if (((ExynosMutex *)handle)->getCreatedStatus() == true)
+        ((ExynosMutex *)handle)->destroy();
+
+    delete (ExynosMutex *)handle;
+
+    return true;
+}
+
+bool exynos_mutex_lock(
+    void *handle)
+{
+    if (handle == NULL) {
+        ALOGE("%s::handle is null", __func__);
+        return false;
+    }
+
+    return ((ExynosMutex *)handle)->lock();
+
+}
+
+bool exynos_mutex_unlock(
+    void *handle)
+{
+    if (handle == NULL) {
+        ALOGE("%s::handle is null", __func__);
+        return false;
+    }
+
+    return ((ExynosMutex *)handle)->unLock();
+
+}
+
+bool exynos_mutex_trylock(
+    void *handle)
+{
+    if (handle == NULL) {
+        ALOGE("%s::handle is null", __func__);
+        return false;
+    }
+
+    return ((ExynosMutex *)handle)->tryLock();
+
+}
+
+int exynos_mutex_get_type(
+    void *handle)
+{
+    if (handle == NULL) {
+        ALOGE("%s::handle is null", __func__);
+        return false;
+    }
+
+    return ((ExynosMutex *)handle)->getType();
+}
+
+bool exynos_mutex_get_created_status(
+    void *handle)
+{
+    if (handle == NULL) {
+        ALOGE("%s::handle is null", __func__);
+        return false;
+    }
+
+    return ((ExynosMutex *)handle)->getCreatedStatus();
+}
+
diff --git a/libexynosutils/ExynosMutex.h b/libexynosutils/ExynosMutex.h
new file mode 100644 (file)
index 0000000..6ce7a2a
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright@ Samsung Electronics 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      ExynosMutex.h
+ * \brief     header file for ExynosMutex
+ * \author    Sangwoo, Park(sw5771.park@samsung.com)
+ * \date      2011/06/15
+ *
+ * <b>Revision History: </b>
+ * - 2010/06/15 : Sangwoo, Park(sw5771.park@samsung.com) \n
+ *   Initial version
+ *
+ */
+
+#ifndef __EXYNOS_MUTEX_H__
+#define __EXYNOS_MUTEX_H__
+
+#ifdef __cplusplus
+
+//! ExynosMutex
+/*!
+ * \ingroup Exynos
+ */
+class ExynosMutex
+{
+public:
+    enum TYPE {
+        TYPE_BASE = 0,
+        TYPE_PRIVATE,  //!< within this process
+        TYPE_SHARED,   //!< within whole system
+        TYPE_MAX,
+    };
+
+public:
+    //! 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);
+
+    //! Unlock Mutex
+    bool unLock(void);
+
+    //! trylock Mutex
+    bool tryLock(void);
+
+    //! Get Mutex type
+    int getType(void);
+
+private:
+    void *m_mutex;
+    bool  m_flagCreate;
+
+    int   m_type;
+    char  m_name[128];
+
+public:
+    //! Autolock
+    /*!
+     * \ingroup ExynosMutex
+     */
+    class Autolock {
+    public:
+        //! Lock on constructor
+        inline Autolock(ExynosMutex& mutex) : mLock(mutex)  { mLock.lock(); }
+
+        //! Lock on constructor
+        inline Autolock(ExynosMutex* mutex) : mLock(*mutex) { mLock.lock(); }
+
+        //! Unlock on destructor
+        inline ~Autolock() { mLock.unLock(); }
+    private:
+        ExynosMutex& mLock;
+    };
+};
+
+extern "C" {
+#endif
+
+enum EXYNOS_MUTEX_TYPE {
+    EXYNOS_MUTEX_TYPE_BASE = 0,
+    EXYNOS_MUTEX_TYPE_PRIVATE,  //!< within this process
+    EXYNOS_MUTEX_TYPE_SHARED,   //!< within whole system
+    EXYNOS_MUTEX_TYPE_MAX,
+};
+
+void *exynos_mutex_create(
+    int   type,
+    char *name);
+
+bool exynos_mutex_destroy(
+    void *handle);
+
+bool exynos_mutex_lock(
+    void *handle);
+
+bool exynos_mutex_unlock(
+    void *handle);
+
+bool exynos_mutex_trylock(
+    void *handle);
+
+int exynos_mutex_type(
+    void *handle);
+
+bool exynos_mutex_get_created_status(
+    void *handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__EXYNOS_MUTEX_H__
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
diff --git a/libexynosutils/exynos5_format_v4l2.c b/libexynosutils/exynos5_format_v4l2.c
new file mode 100644 (file)
index 0000000..8b05717
--- /dev/null
@@ -0,0 +1,432 @@
+/*
+ * Copyright@ Samsung Electronics 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 exynos5_format_v4l2.c
+ * author Sangwoo, Park(sw5771.park@samsung.com)
+ * date 2011/06/02
+ *
+ * Revision History:
+ * - 2010/06/03 : Sangwoo, Park(sw5771.park@samsung.com)
+ * Initial version
+ *
+ * - 2011/12/07 : Hyeonmyeong Choi( hyeon.choi@samsung.com)
+ * Add V4L2_PIX_FMT_YVU420M
+ *
+ * - 2012/03/06 : shinwon lee(shinwon.lee@samsung.com)
+ * Merge to libexynosutils
+ *
+ */
+
+#ifndef __EXYNOS5_FORMAT_V4L2_H__
+#define __EXYNOS5_FORMAT_V4L2_H__
+
+//---------------------------------------------------------//
+// Include
+//---------------------------------------------------------//
+#include <hardware/hardware.h>
+#include "exynos_format.h"
+#include "s5p_fimc_v4l2.h"
+#include <utils/Log.h>
+#include "videodev2.h"
+#include "videodev2_exynos_media.h"
+
+int HAL_PIXEL_FORMAT_2_V4L2_PIX(
+    int hal_pixel_format)
+{
+    int v4l2_pixel_format = -1;
+
+    switch (hal_pixel_format) {
+    case HAL_PIXEL_FORMAT_RGBA_8888:
+    case HAL_PIXEL_FORMAT_RGBX_8888:
+        v4l2_pixel_format = V4L2_PIX_FMT_RGB32;
+        break;
+
+    case HAL_PIXEL_FORMAT_RGB_888:
+        v4l2_pixel_format = V4L2_PIX_FMT_RGB24;
+        break;
+
+    case HAL_PIXEL_FORMAT_RGB_565:
+        v4l2_pixel_format = V4L2_PIX_FMT_RGB565;
+        break;
+
+    case HAL_PIXEL_FORMAT_BGRA_8888:
+        v4l2_pixel_format = V4L2_PIX_FMT_BGR32;
+        break;
+
+    case HAL_PIXEL_FORMAT_RGBA_5551:
+        v4l2_pixel_format = V4L2_PIX_FMT_RGB555X;
+        break;
+
+    case HAL_PIXEL_FORMAT_RGBA_4444:
+        v4l2_pixel_format = V4L2_PIX_FMT_RGB444;
+        break;
+
+    case HAL_PIXEL_FORMAT_EXYNOS_YV12:
+        v4l2_pixel_format = V4L2_PIX_FMT_YVU420M;
+        break;
+
+    case HAL_PIXEL_FORMAT_YCbCr_420_P:
+        v4l2_pixel_format = V4L2_PIX_FMT_YUV420M;
+        break;
+
+    case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+        v4l2_pixel_format = V4L2_PIX_FMT_NV61;
+        break;
+
+    case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+        v4l2_pixel_format = V4L2_PIX_FMT_NV12M;
+        break;
+
+    case HAL_PIXEL_FORMAT_YCbCr_422_I:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+        v4l2_pixel_format = V4L2_PIX_FMT_YUYV;
+        break;
+
+    case HAL_PIXEL_FORMAT_YCbCr_422_P:
+        v4l2_pixel_format = V4L2_PIX_FMT_YUV422P;
+        break;
+
+    case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+    case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+        v4l2_pixel_format = V4L2_PIX_FMT_UYVY;
+        break;
+
+    case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+        v4l2_pixel_format = V4L2_PIX_FMT_NV16;
+        break;
+
+    case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+        v4l2_pixel_format = V4L2_PIX_FMT_NV21M;
+        break;
+
+   case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
+        v4l2_pixel_format = V4L2_PIX_FMT_NV12MT_16X16;
+        break;
+
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+        v4l2_pixel_format = V4L2_PIX_FMT_NV12MT_16X16;
+        break;
+
+   case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+        v4l2_pixel_format = V4L2_PIX_FMT_YVYU;
+        break;
+
+   case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+        v4l2_pixel_format = V4L2_PIX_FMT_VYUY;
+        break;
+
+    default:
+        ALOGE("%s::unmatched HAL_PIXEL_FORMAT color_space(0x%x)\n",
+                __func__, hal_pixel_format);
+        break;
+    }
+
+    return v4l2_pixel_format;
+}
+
+int V4L2_PIX_2_HAL_PIXEL_FORMAT(
+    int v4l2_pixel_format)
+{
+    int hal_pixel_format = -1;
+
+    switch (v4l2_pixel_format) {
+    case V4L2_PIX_FMT_RGB32:
+        hal_pixel_format = HAL_PIXEL_FORMAT_RGBA_8888;
+        break;
+
+    case V4L2_PIX_FMT_RGB24:
+        hal_pixel_format = HAL_PIXEL_FORMAT_RGB_888;
+        break;
+
+    case V4L2_PIX_FMT_RGB565:
+        hal_pixel_format = HAL_PIXEL_FORMAT_RGB_565;
+        break;
+
+    case V4L2_PIX_FMT_BGR32:
+        hal_pixel_format = HAL_PIXEL_FORMAT_BGRA_8888;
+        break;
+
+    case V4L2_PIX_FMT_RGB555X:
+        hal_pixel_format = HAL_PIXEL_FORMAT_RGBA_5551;
+        break;
+
+    case V4L2_PIX_FMT_RGB444:
+        hal_pixel_format = HAL_PIXEL_FORMAT_RGBA_4444;
+        break;
+
+    case V4L2_PIX_FMT_YUV420:
+    case V4L2_PIX_FMT_YUV420M:
+        hal_pixel_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
+        break;
+
+    case V4L2_PIX_FMT_YVU420:
+    case V4L2_PIX_FMT_YVU420M:
+         hal_pixel_format = HAL_PIXEL_FORMAT_EXYNOS_YV12;
+         break;
+
+    case V4L2_PIX_FMT_NV16:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP;
+        break;
+
+    case V4L2_PIX_FMT_NV12:
+        hal_pixel_format = HAL_PIXEL_FORMAT_YCbCr_420_SP;
+        break;
+
+    case V4L2_PIX_FMT_NV12M:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP;
+        break;
+
+    case V4L2_PIX_FMT_YUYV:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I;
+        break;
+
+    case V4L2_PIX_FMT_YUV422P:
+        hal_pixel_format = HAL_PIXEL_FORMAT_YCbCr_422_P;
+        break;
+
+    case V4L2_PIX_FMT_UYVY:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I;
+        break;
+
+    case V4L2_PIX_FMT_NV21:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP;
+        break;
+    case V4L2_PIX_FMT_NV12MT_16X16:
+
+        hal_pixel_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
+        break;
+
+    case V4L2_PIX_FMT_NV61:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP;
+        break;
+
+    case V4L2_PIX_FMT_YVYU:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I;
+        break;
+
+    case V4L2_PIX_FMT_VYUY:
+        hal_pixel_format = HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I;
+        break;
+
+    default:
+        ALOGE("%s::unmatched V4L2_PIX color_space(%d)\n",
+                __func__, v4l2_pixel_format);
+        break;
+    }
+
+    return hal_pixel_format;
+}
+
+int NUM_PLANES(int hal_pixel_format)
+{
+    switch(hal_pixel_format) {
+    case HAL_PIXEL_FORMAT_EXYNOS_YV12:
+    case HAL_PIXEL_FORMAT_YCbCr_420_P:
+       return 3;
+    case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP:
+    case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+       return 2;
+       break;
+    case HAL_PIXEL_FORMAT_YCbCr_420_I:
+    case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+       return 1;
+    default:
+       return 1;
+    }
+}
+
+unsigned int FRAME_SIZE(
+    int hal_pixel_format,
+    int width,
+    int height)
+{
+    unsigned int frame_size = 0;
+    unsigned int size       = 0;
+
+    switch (hal_pixel_format) {
+    // 16bpp
+    case HAL_PIXEL_FORMAT_RGB_565:
+    case HAL_PIXEL_FORMAT_RGBA_5551:
+    case HAL_PIXEL_FORMAT_RGBA_4444:
+        frame_size = GET_16BPP_FRAME_SIZE(width, height);
+        break;
+
+    // 24bpp
+    case HAL_PIXEL_FORMAT_RGB_888:
+        frame_size = GET_24BPP_FRAME_SIZE(width, height);
+        break;
+
+    // 32bpp
+    case HAL_PIXEL_FORMAT_RGBA_8888:
+    case HAL_PIXEL_FORMAT_BGRA_8888:
+    case HAL_PIXEL_FORMAT_RGBX_8888:
+        frame_size = GET_32BPP_FRAME_SIZE(width, height);
+        break;
+
+    // 12bpp
+    case HAL_PIXEL_FORMAT_EXYNOS_YV12:
+    case HAL_PIXEL_FORMAT_YCbCr_420_P:
+    case HAL_PIXEL_FORMAT_YCbCr_420_I:
+    case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+        size = ALIGN(width, 16) * ALIGN(height, 16);
+        frame_size = size + 2 * ALIGN(width >> 1, 8) * ALIGN(height >> 1, 8);
+        break;
+
+    case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP:
+    case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+        size = ALIGN(ALIGN(width, 16) * ALIGN(height, 16), 2048);
+        frame_size = size + ALIGN(ALIGN(width, 16) * ALIGN(height >> 1, 8), 2048);
+        break;
+
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+        frame_size =   ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))
+                     + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height >> 1));
+        break;
+
+    // 16bpp
+    case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+    case HAL_PIXEL_FORMAT_YCbCr_422_I:
+    case HAL_PIXEL_FORMAT_YCbCr_422_P:
+    case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+    case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+    case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+    case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+        frame_size = GET_16BPP_FRAME_SIZE(width, height);
+        break;
+
+    default:
+        ALOGD("%s::no matching source colorformat(0x%x), width(%d), h(%d) fail\n",
+                __func__, hal_pixel_format, width, height);
+        break;
+    }
+
+    return frame_size;
+}
+
+int PLANAR_FRAME_SIZE(int hal_pixel_format, int width, int height,
+                     unsigned int *luma_size, unsigned int *chroma_size)
+{
+    unsigned int size       = 0;
+
+    switch(hal_pixel_format) {
+    case HAL_PIXEL_FORMAT_EXYNOS_YV12:
+    case HAL_PIXEL_FORMAT_YCbCr_420_P:
+        size = width * height;
+       *luma_size = size;
+       *chroma_size = size >> 2;
+    case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP:
+    case HAL_PIXEL_FORMAT_YCbCr_420_I:
+    case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+    case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+    case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+        size = width * height;
+       *luma_size = size;
+       *chroma_size = (size >> 2) << 1;
+        break;
+    case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+        *luma_size = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height));
+       *chroma_size = ALIGN_TO_8KB(ALIGN_TO_128B(width) * 
+                                   ALIGN_TO_32B(height >> 1));
+       break;
+    default:
+       *luma_size = FRAME_SIZE(hal_pixel_format, width, height);
+    }
+    return 0;
+}
+
+
+int V4L2_PIX_2_YUV_INFO(unsigned int v4l2_pixel_format, unsigned int * bpp, unsigned int * planes)
+{
+    switch (v4l2_pixel_format) {
+    case V4L2_PIX_FMT_NV12:
+        *bpp    = 12;
+        *planes = 1;
+        break;
+    case V4L2_PIX_FMT_NV21:
+    case V4L2_PIX_FMT_NV21X:
+    case V4L2_PIX_FMT_NV12M:
+    case V4L2_PIX_FMT_NV21M:
+    case V4L2_PIX_FMT_NV12MT_16X16:
+        *bpp    = 12;
+        *planes = 2;
+        break;
+    case V4L2_PIX_FMT_YUV420:
+    case V4L2_PIX_FMT_YUV420M:
+    case V4L2_PIX_FMT_YVU420M:
+        *bpp    = 12;
+        *planes = 3;
+        break;
+    case V4L2_PIX_FMT_YUYV:
+    case V4L2_PIX_FMT_YVYU:
+    case V4L2_PIX_FMT_UYVY:
+    case V4L2_PIX_FMT_VYUY:
+        *bpp    = 16;
+        *planes = 1;
+        break;
+    case V4L2_PIX_FMT_NV16:
+    case V4L2_PIX_FMT_NV61:
+    case V4L2_PIX_FMT_NV16X:
+    case V4L2_PIX_FMT_NV61X:
+        *bpp    = 16;
+        *planes = 2;
+        break;
+    case V4L2_PIX_FMT_YUV422P:
+        *bpp    = 16;
+        *planes = 3;
+        break;
+    default:
+        return -1;
+        break;
+    }
+
+    return 0;
+}
+
+unsigned int get_yuv_bpp(unsigned int v4l2_pixel_format)
+{
+    unsigned int bpp, planes;
+
+    if (V4L2_PIX_2_YUV_INFO(v4l2_pixel_format, &bpp, &planes) < 0)
+        bpp = -1;
+
+    return bpp;
+}
+
+unsigned int get_yuv_planes(unsigned int v4l2_pixel_format)
+{
+    unsigned int bpp, planes;
+
+    if (V4L2_PIX_2_YUV_INFO(v4l2_pixel_format, &bpp, &planes) < 0)
+        planes = -1;
+
+    return planes;
+}
+#endif