diff options
author | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-05-20 12:00:36 +0200 |
---|---|---|
committer | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-05-20 12:00:36 +0200 |
commit | 62f02ba4f4b7b561aa15408ebd9951600bdd71aa (patch) | |
tree | ac05dc645945a58edbc26e96df1a78ac16f27706 /exynos4/hal/libfimg3x | |
parent | e54debb12ecdf92d12acab00a261c0c5a6ef1d64 (diff) | |
download | android_hardware_samsung-62f02ba4f4b7b561aa15408ebd9951600bdd71aa.tar.gz android_hardware_samsung-62f02ba4f4b7b561aa15408ebd9951600bdd71aa.tar.bz2 android_hardware_samsung-62f02ba4f4b7b561aa15408ebd9951600bdd71aa.zip |
exynos: reorganized and updated from insignal
Changes needed on exynos4210 devices:
libcsc -> libseccscapi
libswconverter -> remove
TARGET_HAL_PATH := hardware/samsung/exynos4/hal
TARGET_OMX_PATH := hardware/samsung/exynos/multimedia/openmax
$(call inherit-product, hardware/samsung/exynos4210.mk)
Change-Id: Ic59ef95b85ef37b3f38fb36cf6a364a5414685ee
Diffstat (limited to 'exynos4/hal/libfimg3x')
-rw-r--r-- | exynos4/hal/libfimg3x/Android.mk | 22 | ||||
-rw-r--r-- | exynos4/hal/libfimg3x/FimgApi.cpp | 245 | ||||
-rw-r--r-- | exynos4/hal/libfimg3x/FimgApi.h | 186 | ||||
-rw-r--r-- | exynos4/hal/libfimg3x/FimgC210.cpp | 478 | ||||
-rw-r--r-- | exynos4/hal/libfimg3x/FimgC210.h | 197 |
5 files changed, 1128 insertions, 0 deletions
diff --git a/exynos4/hal/libfimg3x/Android.mk b/exynos4/hal/libfimg3x/Android.mk new file mode 100644 index 0000000..c60274d --- /dev/null +++ b/exynos4/hal/libfimg3x/Android.mk @@ -0,0 +1,22 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +ifeq ($(BOARD_USES_FIMGAPI),true) + +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES:= \ + FimgApi.cpp \ + FimgC210.cpp + +LOCAL_SHARED_LIBRARIES:= liblog libutils libbinder + +LOCAL_MODULE:= libfimg + +LOCAL_PRELINK_MODULE := false + +include $(BUILD_SHARED_LIBRARY) + +endif diff --git a/exynos4/hal/libfimg3x/FimgApi.cpp b/exynos4/hal/libfimg3x/FimgApi.cpp new file mode 100644 index 0000000..b4c5890 --- /dev/null +++ b/exynos4/hal/libfimg3x/FimgApi.cpp @@ -0,0 +1,245 @@ +/* +** +** Copyright 2009 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. +** +** +*/ + +/////////////////////////////////////////////////// +// include +/////////////////////////////////////////////////// +#define LOG_NDEBUG 0 +#define LOG_TAG "FimgApi" +#include <utils/Log.h> + +#include "FimgApi.h" + +//---------------------------------------------------------------------------// +// Global Function +//---------------------------------------------------------------------------// +#ifndef REAL_DEBUG + void VOID_FUNC(const char* format, ...) + {} +#endif + +//---------------------------------------------------------------------------// +// FimgApi +//---------------------------------------------------------------------------// + +//---------------------------------------------------------------------------// +// Method Function Implementation +//---------------------------------------------------------------------------// + +FimgApi::FimgApi() +{ + m_flagCreate = false; +} + +FimgApi::~FimgApi() +{ + if(m_flagCreate == true) + PRINT("%s::this is not Destroyed fail \n", __func__); +} + +bool FimgApi::Create(void) +{ + bool ret = false; + + if(t_Lock() == false) { + PRINT("%s::t_Lock() fail \n", __func__); + goto CREATE_DONE; + } + + if(m_flagCreate == true) { + PRINT("%s::Already Created fail \n", __func__); + goto CREATE_DONE; + } + + if(t_Create() == false) { + PRINT("%s::t_Create() fail \n", __func__); + goto CREATE_DONE; + } + + m_flagCreate = true; + + ret = true; + +CREATE_DONE : + + t_UnLock(); + + return ret; +} + +bool FimgApi::Destroy(void) +{ + bool ret = false; + + if(t_Lock() == false) { + PRINT("%s::t_Lock() fail \n", __func__); + goto DESTROY_DONE; + } + + if(m_flagCreate == false) { + PRINT("%s::Already Destroyed fail \n", __func__); + goto DESTROY_DONE; + } + + if(t_Destroy() == false) { + PRINT("%s::t_Destroy() fail \n", __func__); + goto DESTROY_DONE; + } + + m_flagCreate = false; + + ret = true; + +DESTROY_DONE : + + t_UnLock(); + + return ret; +} + +bool FimgApi::Stretch(FimgRect * src, FimgRect * dst, FimgClip *clip, FimgFlag * flag) +{ + bool ret = false; + + if(t_Lock() == false) { + PRINT("%s::t_Lock() fail \n", __func__); + goto STRETCH_DONE; + } + + if(m_flagCreate == false) { + PRINT("%s::This is not Created fail \n", __func__); + goto STRETCH_DONE; + } + + if(t_Stretch(src, dst, clip, flag) == false) { + goto STRETCH_DONE; + } + + ret = true; + +STRETCH_DONE : + + t_UnLock(); + + return ret; +} + +bool FimgApi::Sync(void) +{ + bool ret = false; + + if(m_flagCreate == false) { + PRINT("%s::This is not Created fail \n", __func__); + goto SYNC_DONE; + } + + if(t_Sync() == false) { + goto SYNC_DONE; + } + + ret = true; + +SYNC_DONE : + + return ret; +} + +bool FimgApi::t_Create(void) +{ + PRINT("%s::This is empty virtual function fail\n", __func__); + return false; +} + +bool FimgApi::t_Destroy(void) +{ + PRINT("%s::This is empty virtual function fail\n", __func__); + return false; +} + +bool FimgApi::t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag) +{ + PRINT("%s::This is empty virtual function fail\n", __func__); + return false; +} + +bool FimgApi::t_Sync(void) +{ + PRINT("%s::This is empty virtual function fail\n", __func__); + return false; +} + +bool FimgApi::t_Lock(void) +{ + PRINT("%s::This is empty virtual function fail\n", __func__); + return false; +} + +bool FimgApi::t_UnLock(void) +{ + PRINT("%s::This is empty virtual function fail\n", __func__); + return false; +} + + +//---------------------------------------------------------------------------// +// extern function +//---------------------------------------------------------------------------// +extern "C" int stretchFimgApi(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag) +{ + FimgApi * fimgApi = createFimgApi(); + + if(fimgApi == NULL) { + PRINT("%s::createFimgApi() fail \n", __func__); + return -1; + } + + if(fimgApi->Stretch(src, dst, clip, flag) == false) { + if(fimgApi != NULL) + destroyFimgApi(fimgApi); + + return -1; + } + + if(fimgApi != NULL) + destroyFimgApi(fimgApi); + + return 0; +} + +extern "C" int SyncFimgApi(void) +{ + FimgApi * fimgApi = createFimgApi(); + if(fimgApi == NULL) { + PRINT("%s::createFimgApi() fail \n", __func__); + return -1; + } + + if(fimgApi->Sync() == false) { + if(fimgApi != NULL) + destroyFimgApi(fimgApi); + + return -1; + } + + if(fimgApi != NULL) + destroyFimgApi(fimgApi); + + return 0; +} + diff --git a/exynos4/hal/libfimg3x/FimgApi.h b/exynos4/hal/libfimg3x/FimgApi.h new file mode 100644 index 0000000..3daac3d --- /dev/null +++ b/exynos4/hal/libfimg3x/FimgApi.h @@ -0,0 +1,186 @@ +/* +** +** Copyright 2009 Samsung Electronics Co, Ltd. +** Copyright 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. +** +** +*/ + +#ifndef FIMG_API_H +#define FIMG_API_H + +#include <utils/Log.h> + +#include "../include/sec_g2d.h" +//#include <sec_g2d.h> +#define REAL_DEBUG +#define ANDROID_LOG + +#if defined(REAL_DEBUG) +#ifdef ANDROID_LOG + #define PRINT LOGE + #define PRINTD LOGD +#else + #define PRINT printf + #define PRINTD printf +#endif +#else + void VOID_FUNC(const char* format, ...); + + #define PRINT VOID_FUNC + #define PRINTD VOID_FUNC +#endif + +typedef g2d_rect FimgRect; +typedef g2d_flag FimgFlag; +typedef g2d_clip FimgClip; + +#ifdef __cplusplus +class FimgApi +{ +public: +#endif + enum COLOR_FORMAT { + COLOR_FORMAT_BASE = 0, + + COLOR_FORMAT_RGB_565 = G2D_RGB_565, + + COLOR_FORMAT_RGBA_8888 = G2D_RGBA_8888, + COLOR_FORMAT_ARGB_8888 = G2D_ARGB_8888, + COLOR_FORMAT_BGRA_8888 = G2D_BGRA_8888, + COLOR_FORMAT_ABGR_8888 = G2D_ABGR_8888, + + COLOR_FORMAT_RGBX_8888 = G2D_RGBX_8888, + COLOR_FORMAT_XRGB_8888 = G2D_XRGB_8888, + COLOR_FORMAT_BGRX_8888 = G2D_BGRX_8888, + COLOR_FORMAT_XBGR_8888 = G2D_XBGR_8888, + + COLOR_FORMAT_RGBA_5551 = G2D_RGBA_5551, + COLOR_FORMAT_ARGB_1555 = G2D_ARGB_1555, + COLOR_FORMAT_BGRA_5551 = G2D_BGRA_5551, + COLOR_FORMAT_ABGR_1555 = G2D_ABGR_1555, + + COLOR_FORMAT_RGBX_5551 = G2D_RGBX_5551, + COLOR_FORMAT_XRGB_1555 = G2D_XRGB_1555, + COLOR_FORMAT_BGRX_5551 = G2D_BGRX_5551, + COLOR_FORMAT_XBGR_1555 = G2D_XBGR_1555, + + COLOR_FORMAT_RGBA_4444 = G2D_RGBA_4444, + COLOR_FORMAT_ARGB_4444 = G2D_ARGB_4444, + COLOR_FORMAT_BGRA_4444 = G2D_BGRA_4444, + COLOR_FORMAT_ABGR_4444 = G2D_ABGR_4444, + + COLOR_FORMAT_RGBX_4444 = G2D_RGBX_4444, + COLOR_FORMAT_XRGB_4444 = G2D_XRGB_4444, + COLOR_FORMAT_BGRX_4444 = G2D_BGRX_4444, + COLOR_FORMAT_XBGR_4444 = G2D_XBGR_4444, + + COLOR_FORMAT_PACKED_RGB_888 = G2D_PACKED_RGB_888, + COLOR_FORMAT_PACKED_BGR_888 = G2D_PACKED_BGR_888, + COLOR_FORMAT_YUV_420SP, + COLOR_FORMAT_YUV_420P, + COLOR_FORMAT_YUV_420I, + COLOR_FORMAT_YUV_422SP, + COLOR_FORMAT_YUV_422P, + COLOR_FORMAT_YUV_422I, + COLOR_FORMAT_YUYV, + + COLOR_FORMAT_MAX, + }; + + enum ROTATE { + ROTATE_BASE = 0, + ROTATE_0 = G2D_ROT_0, + ROTATE_90 = G2D_ROT_90, + ROTATE_180 = G2D_ROT_180, + ROTATE_270 = G2D_ROT_270, + ROTATE_X_FLIP = G2D_ROT_X_FLIP, + ROTATE_Y_FLIP = G2D_ROT_Y_FLIP, + ROTATE_MAX, + }; + + enum ALPHA_VALUE { + ALPHA_MIN = G2D_ALPHA_BLENDING_MIN, // wholly transparent + ALPHA_MAX = G2D_ALPHA_BLENDING_MAX, // 255 + ALPHA_OPAQUE = G2D_ALPHA_BLENDING_OPAQUE, // opaque + }; + + enum DITHER { + DITHER_BASE = 0, + DITHER_OFF = 0, + DITHER_ON = 1, + DITHER_MAX, + }; +#ifdef __cplusplus +private : + bool m_flagCreate; + +protected : + FimgApi(); + FimgApi(const FimgApi& rhs) {} + virtual ~FimgApi(); + +public: + bool Create(void); + bool Destroy(void); + inline bool FlagCreate(void) { return m_flagCreate; } + bool Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag); + bool Sync(void); + +protected: + virtual bool t_Create(void); + virtual bool t_Destroy(void); + virtual bool t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag); + virtual bool t_Sync(void); + virtual bool t_Lock(void); + virtual bool t_UnLock(void); + +}; +#endif + +/*--------------------------------------------------------------------------- + * user api extern function + *--------------------------------------------------------------------------- + * usage 1 + * FimgApi * p = createFimgApi(); + * p->Stretch() + * destroyFimgApi(p); + * + * usage 2 + * stretchFimgApi(src, dst, clip, flag); + *-------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +#endif +struct FimgApi * createFimgApi(); + +#ifdef __cplusplus +extern "C" +#endif +void destroyFimgApi(FimgApi * ptrFimgApi); + +#ifdef __cplusplus +extern "C" +#endif +int stretchFimgApi(FimgRect * src, + FimgRect * dst, + FimgClip * clip, + FimgFlag * flag); +#ifdef __cplusplus +extern "C" +#endif +int SyncFimgApi(void); + +#endif //FIMG_API_H diff --git a/exynos4/hal/libfimg3x/FimgC210.cpp b/exynos4/hal/libfimg3x/FimgC210.cpp new file mode 100644 index 0000000..129acae --- /dev/null +++ b/exynos4/hal/libfimg3x/FimgC210.cpp @@ -0,0 +1,478 @@ +/* +** +** Copyright 2009 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. +** +** +*/ + +/////////////////////////////////////////////////// +// include +/////////////////////////////////////////////////// +#define LOG_NDEBUG 0 +#define LOG_TAG "FimgC210" +#include <utils/Log.h> + +#include "FimgC210.h" + +namespace android +{ + +//---------------------------------------------------------------------------// +// FimgC210 +//---------------------------------------------------------------------------// + +Mutex FimgC210::m_instanceLock; +int FimgC210::m_curFimgC210Index = 0; +int FimgC210::m_numOfInstance = 0; +FimgApi * FimgC210::m_ptrFimgApiList[NUMBER_FIMG_LIST] = {NULL, }; + +//---------------------------------------------------------------------------// + +FimgC210::FimgC210() + : m_g2dFd(0), + m_g2dVirtAddr(NULL), + m_g2dSize(0), + m_g2dSrcVirtAddr(NULL), + m_g2dSrcSize(0), + m_g2dDstVirtAddr(NULL), + m_g2dDstSize(0) +{ + m_lock = new Mutex(Mutex::SHARED, "FimgC210"); +} + +FimgC210::~FimgC210() +{ + delete m_lock; +} + +FimgApi * FimgC210::CreateInstance() +{ + Mutex::Autolock autolock(m_instanceLock); + + FimgApi * ptrFimg = NULL; + + // Using List like RingBuffer... + for(int i = m_curFimgC210Index; i < NUMBER_FIMG_LIST; i++) { + if(m_ptrFimgApiList[i] == NULL) + m_ptrFimgApiList[i] = new FimgC210; + + if(m_ptrFimgApiList[i]->FlagCreate() == false) { + if(m_ptrFimgApiList[i]->Create() == false) { + PRINT("%s::Create(%d) fail\n", __func__, i); + goto CreateInstance_End; + } + else + m_numOfInstance++; + } + + if(i < NUMBER_FIMG_LIST - 1) + m_curFimgC210Index = i + 1; + else + m_curFimgC210Index = 0; + + ptrFimg = m_ptrFimgApiList[i]; + goto CreateInstance_End; + } + +CreateInstance_End : + + return ptrFimg; +} + +void FimgC210::DestroyInstance(FimgApi * ptrFimgApi) +{ + Mutex::Autolock autolock(m_instanceLock); + + for(int i = 0; i < NUMBER_FIMG_LIST; i++) { + if(m_ptrFimgApiList[i] != NULL + && m_ptrFimgApiList[i] == ptrFimgApi) { + if(m_ptrFimgApiList[i]->FlagCreate() == true + && m_ptrFimgApiList[i]->Destroy() == false) { + PRINT("%s::Destroy() fail\n", __func__); + } else { + FimgC210 * tempFimgC210 = (FimgC210 *)m_ptrFimgApiList[i]; + delete tempFimgC210; + m_ptrFimgApiList[i] = NULL; + + m_numOfInstance--; + } + + break; + } + } +} + +void FimgC210::DestroyAllInstance(void) +{ + Mutex::Autolock autolock(m_instanceLock); + + for(int i = 0; i < NUMBER_FIMG_LIST; i++) { + if(m_ptrFimgApiList[i] != NULL) { + if(m_ptrFimgApiList[i]->FlagCreate() == true + && m_ptrFimgApiList[i]->Destroy() == false) { + PRINT("%s::Destroy() fail\n", __func__); + } else { + FimgC210 * tempFimgC210 = (FimgC210 *)m_ptrFimgApiList[i]; + delete tempFimgC210; + m_ptrFimgApiList[i] = NULL; + } + } + } +} + + +bool FimgC210::t_Create(void) +{ + bool ret = true; + + if(m_CreateG2D() == false) { + PRINT("%s::m_CreateG2D() fail \n", __func__); + + if(m_DestroyG2D() == false) + PRINT("%s::m_DestroyG2D() fail \n", __func__); + + ret = false; + } + + return ret; +} + +bool FimgC210::t_Destroy(void) +{ + bool ret = true; + + if(m_DestroyG2D() == false) { + PRINT("%s::m_DestroyG2D() fail \n", __func__); + ret = false; + } + + return ret; +} + +bool FimgC210::t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag) +{ + #ifdef CHECK_FIMGC210_PERFORMANCE + #define NUM_OF_STEP (10) + StopWatch stopWatch("CHECK_FIMGC210_PERFORMANCE"); + const char * stopWatchName[NUM_OF_STEP]; + nsecs_t stopWatchTime[NUM_OF_STEP]; + int stopWatchIndex = 0; + #endif // CHECK_FIMGC210_PERFORMANCE + + if(m_DoG2D(src, dst, clip, flag) == false) { + goto STRETCH_FAIL; + } + +#ifdef G2D_NONE_BLOCKING_MODE + if(m_PollG2D(&m_g2dPoll) == false) + { + PRINT("%s::m_PollG2D() fail\n", __func__); + goto STRETCH_FAIL; + } +#endif + + #ifdef CHECK_FIMGC210_PERFORMANCE + m_PrintFimgC210Performance(src, dst, stopWatchIndex, stopWatchName, stopWatchTime); + #endif // CHECK_FIMGC210_PERFORMANCE + + return true; + +STRETCH_FAIL: + return false; + +} + +bool FimgC210::t_Sync(void) +{ +#if 0 + if(ioctl(m_g2dFd, G2D_SYNC) < 0) { + PRINT("%s::G2D_Sync fail\n", __func__); + goto SYNC_FAIL; + } +#else + if(m_PollG2D(&m_g2dPoll) == false) + { + PRINT("%s::m_PollG2D() fail\n", __func__); + goto SYNC_FAIL; + } +#endif + return true; + +SYNC_FAIL: + return false; + +} + +bool FimgC210::t_Lock(void) +{ + m_lock->lock(); + return true; +} + +bool FimgC210::t_UnLock(void) +{ + m_lock->unlock(); + return true; +} + +bool FimgC210::m_CreateG2D(void) +{ + void * mmap_base; + + if(m_g2dFd != 0) { + PRINT("%s::m_g2dFd(%d) is not 0 fail\n", __func__, m_g2dFd); + return false; + } + +#ifdef G2D_NONE_BLOCKING_MODE + m_g2dFd = open(SEC_G2D_DEV_NAME, O_RDWR | O_NONBLOCK); +#else + m_g2dFd = open(SEC_G2D_DEV_NAME, O_RDWR); +#endif + if(m_g2dFd < 0) { + PRINT("%s::open(%s) fail(%s)\n", __func__, SEC_G2D_DEV_NAME, strerror(errno)); + m_g2dFd = 0; + return false; + } + + memset(&m_g2dPoll, 0, sizeof(m_g2dPoll)); + m_g2dPoll.fd = m_g2dFd; + m_g2dPoll.events = POLLOUT | POLLERR; + + return true; +} + +bool FimgC210::m_DestroyG2D(void) +{ + if(m_g2dVirtAddr != NULL) { + munmap(m_g2dVirtAddr, m_g2dSize); + m_g2dVirtAddr = NULL; + m_g2dSize = 0; + } + + if(0 < m_g2dFd) { + close(m_g2dFd); + } + m_g2dFd = 0; + + return true; +} + +//bool FimgC210::m_DoG2D(FimgRect * src, FimgRect * dst, int rotateValue, int alphaValue, int colorKey) +bool FimgC210::m_DoG2D(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag) +{ + g2d_params params; + + memcpy(¶ms.src_rect, src, sizeof(FimgRect)); + memcpy(¶ms.dst_rect, dst, sizeof(FimgRect)); + memcpy(¶ms.clip, clip, sizeof(FimgClip)); + memcpy(¶ms.flag, flag, sizeof(FimgFlag)); + + if(ioctl(m_g2dFd, G2D_BLIT, ¶ms) < 0) { + #if 0 + { + PRINT("---------------------------------------\n"); + PRINT("src.color_format : %d \n", src->color_format); + PRINT("src.full_w : %d \n", src->full_w); + PRINT("src.full_h : %d \n", src->full_h); + PRINT("src.x : %d \n", src->x); + PRINT("src.y : %d \n", src->y); + PRINT("src.w : %d \n", src->w); + PRINT("src.h : %d \n", src->h); + + PRINT("dst.color_format : %d \n", dst->color_format); + PRINT("dst.full_w : %d \n", dst->full_w); + PRINT("dst.full_h : %d \n", dst->full_h); + PRINT("dst.x : %d \n", dst->x); + PRINT("dst.y : %d \n", dst->y); + PRINT("dst.w : %d \n", dst->w); + PRINT("dst.h : %d \n", dst->h); + + PRINT("flag.rotate_val : %d \n", flag->rotate_val); + PRINT("flag.alpha_val : %d(%d) \n", flag->alpha_val); + PRINT("flag.color_key_mode : %d(%d) \n", flag->color_key_mode, flag->color_key_val); + PRINT("---------------------------------------\n"); + } + #endif + + return false; + } + + return true; +} + +inline bool FimgC210::m_PollG2D(struct pollfd * events) +{ + #define G2D_POLL_TIME (1000) + + int ret; + + ret = poll(events, 1, G2D_POLL_TIME); + + if (ret < 0) { + if(ioctl(m_g2dFd, G2D_RESET) < 0) { + PRINT("%s::G2D_RESET fail\n", __func__); + } + PRINT("%s::poll fail \n", __func__); + return false; + } + else if (ret == 0) { + if(ioctl(m_g2dFd, G2D_RESET) < 0) { + PRINT("%s::G2D_RESET fail\n", __func__); + } + PRINT("%s::No data in %d milli secs..\n", __func__, G2D_POLL_TIME); + return false; + } + + return true; +} + +inline bool FimgC210::m_CleanG2D(unsigned int virtAddr, unsigned int size) +{ + g2d_dma_info dma_info = { virtAddr, size }; + + if(ioctl(m_g2dFd, G2D_DMA_CACHE_CLEAN, &dma_info) < 0) { + PRINT("%s::G2D_DMA_CACHE_CLEAN(%d, %d) fail\n", __func__, virtAddr, size); + return false; + } + return true; +} + +inline bool FimgC210::m_FlushG2D (unsigned int virtAddr, unsigned int size) +{ + g2d_dma_info dma_info = { virtAddr, size }; + + if(ioctl(m_g2dFd, G2D_DMA_CACHE_FLUSH, &dma_info) < 0) { + PRINT("%s::G2D_DMA_CACHE_FLUSH(%d, %d) fail\n", __func__, virtAddr, size); + return false; + } + return true; +} + +inline int FimgC210::m_RotateValueFimgApi2FimgHw(int rotateValue) +{ + switch (rotateValue) { + case ROTATE_0: return G2D_ROT_0; + case ROTATE_90: return G2D_ROT_90; + case ROTATE_180: return G2D_ROT_180; + case ROTATE_270: return G2D_ROT_270; + case ROTATE_X_FLIP: return G2D_ROT_X_FLIP; + case ROTATE_Y_FLIP: return G2D_ROT_Y_FLIP; + } + + return -1; +} + + +#ifdef CHECK_FIMGC210_PERFORMANCE +void FimgC210::m_PrintFimgC210Performance(FimgRect * src, + FimgRect * dst, + int stopWatchIndex, + const char * stopWatchName[], + nsecs_t stopWatchTime[]) +{ + char * srcColorFormat = "UNKNOW_COLOR_FORMAT"; + char * dstColorFormat = "UNKNOW_COLOR_FORMAT"; + + switch(src->color_format) + { + case COLOR_FORMAT_RGB_565 : + srcColorFormat = "RGB_565"; + break; + case COLOR_FORMAT_RGBA_8888 : + srcColorFormat = "RGBA_8888"; + break; + case COLOR_FORMAT_RGBX_8888 : + srcColorFormat = "RGBX_8888"; + break; + default : + srcColorFormat = "UNKNOW_COLOR_FORMAT"; + break; + } + + switch(dst->color_format) + { + case COLOR_FORMAT_RGB_565 : + dstColorFormat = "RGB_565"; + break; + case COLOR_FORMAT_RGBA_8888 : + dstColorFormat = "RGBA_8888"; + break; + case COLOR_FORMAT_RGBX_8888 : + dstColorFormat = "RGBX_8888"; + break; + default : + dstColorFormat = "UNKNOW_COLOR_FORMAT"; + break; + } + + +#ifdef CHECK_FIMGC210_CRITICAL_PERFORMANCE +#else + PRINT("===============================================\n"); + PRINT("src[%3d, %3d | %10s] -> dst[%3d, %3d | %10s]\n", + src->w, src->h, srcColorFormat, + dst->w, dst->h, dstColorFormat); +#endif + + nsecs_t totalTime = stopWatchTime[stopWatchIndex - 1]; + + for(int i = 0 ; i < stopWatchIndex; i++) { + nsecs_t sectionTime; + + if(i != 0) + sectionTime = stopWatchTime[i] - stopWatchTime[i-1]; + else + sectionTime = stopWatchTime[i]; + +#ifdef CHECK_FIMGC210_CRITICAL_PERFORMANCE + if(1500 < (sectionTime / 1000)) // check 1.5 mille second.. +#endif + { + PRINT("===============================================\n"); + PRINT("src[%3d, %3d | %10s] -> dst[%3d, %3d | %10s]\n", + src->w, src->h, srcColorFormat, + dst->w, dst->h, dstColorFormat); + + PRINT("%20s : %5lld msec(%5.2f %%)\n", + stopWatchName[i], + sectionTime / 1000, + ((float)sectionTime / (float)totalTime) * 100.0f); + } + } + +} +#endif // CHECK_FIMGC210_PERFORMANCE + +//---------------------------------------------------------------------------// +// extern function +//---------------------------------------------------------------------------// +extern "C" struct FimgApi * createFimgApi() +{ + if (fimgApiAutoFreeThread == 0) + fimgApiAutoFreeThread = new FimgApiAutoFreeThread(); + else + fimgApiAutoFreeThread->SetOneMoreSleep(); + + return FimgC210::CreateInstance(); +} + +extern "C" void destroyFimgApi(FimgApi * ptrFimgApi) +{ + // Dont' call DestrotInstance.. + // return FimgC210::DestroyInstance(ptrFimgApi); +} + +}; // namespace android diff --git a/exynos4/hal/libfimg3x/FimgC210.h b/exynos4/hal/libfimg3x/FimgC210.h new file mode 100644 index 0000000..7aa9a9a --- /dev/null +++ b/exynos4/hal/libfimg3x/FimgC210.h @@ -0,0 +1,197 @@ +/* +** +** Copyright 2008, The Android Open Source Project +** Copyright 2009 Samsung Electronics Co, Ltd. All Rights Reserved. +** +** 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. +** +** +*/ + +#ifndef FIMG_C210_H +#define FIMG_C210_H + + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <signal.h> +#include <sys/mman.h> +#include <sys/time.h> +#include <sys/ioctl.h> +#include <sys/poll.h> +#include <sys/stat.h> + +#include <linux/android_pmem.h> +#include <utils/threads.h> +#include <utils/StopWatch.h> + +#include "FimgApi.h" +//#include "FimgMem.h" + +#include "sec_g2d.h" + +//-----------------------------------------------------------------// + +namespace android +{ + +//#define CHECK_FIMGC210_PERFORMANCE +//#define CHECK_FIMGC210_CRITICAL_PERFORMANCE +#define NUMBER_FIMG_LIST (1) // kcoolsw : because of pmem +//#define G2D_NONE_BLOCKING_MODE // Not supported yet. because of sysMMU Page fault +#define GET_RECT_SIZE(rect) ((rect->full_w) * (rect->h) * (rect->bytes_per_pixel)) +#define GET_REAL_SIZE(rect) ((rect->full_w) * (rect->h) * (rect->bytes_per_pixel)) +#define GET_START_ADDR(rect) (rect->virt_addr + ((rect->y * rect->full_w) * rect->bytes_per_pixel)) + + +//---------------------------------------------------------------------------// +// class FimgC210 : public FimgBase +//---------------------------------------------------------------------------// +class FimgC210 : public FimgApi +{ +private : + int m_g2dFd; + + unsigned char * m_g2dVirtAddr; + unsigned int m_g2dSize; + unsigned char * m_g2dSrcVirtAddr; + unsigned int m_g2dSrcSize; + unsigned char * m_g2dDstVirtAddr; + unsigned int m_g2dDstSize; + struct pollfd m_g2dPoll; + + Mutex * m_lock; + + static Mutex m_instanceLock; + static int m_curFimgC210Index; + static int m_numOfInstance; + + static FimgApi * m_ptrFimgApiList[NUMBER_FIMG_LIST]; + + +protected : + FimgC210(); + virtual ~FimgC210(); + +public: + static FimgApi * CreateInstance(); + static void DestroyInstance(FimgApi * ptrFimgApi); + static void DestroyAllInstance(void); + +protected: + virtual bool t_Create(void); + virtual bool t_Destroy(void); + virtual bool t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag); + virtual bool t_Sync(void); + virtual bool t_Lock(void); + virtual bool t_UnLock(void); + +private: + bool m_CreateG2D(void); + bool m_DestroyG2D(void); + bool SetClipRectl(FimgRect * dst, FimgClip * clip, FimgClip * clipTempMidRect); + + bool m_DoG2D(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag); + + inline bool m_PollG2D(struct pollfd * events); + + inline bool m_CleanG2D (unsigned int addr, unsigned int size); + inline bool m_FlushG2D (unsigned int addr, unsigned int size); + + inline int m_ColorFormatFimgApi2FimgHw(int colorFormat); + inline int m_RotateValueFimgApi2FimgHw(int rotateValue); + + #ifdef CHECK_FIMGC210_PERFORMANCE + void m_PrintFimgC210Performance(FimgRect * src, + FimgRect * dst, + int stopWatchIndex, + const char * stopWatchName[], + nsecs_t stopWatchTime[]); + #endif // CHECK_FIMGC210_PERFORMANCE +}; + +//---------------------------------------------------------------------------// +// class FimgApiAutoFreeThread : public Thread +//---------------------------------------------------------------------------// +class FimgApiAutoFreeThread; + +static sp<FimgApiAutoFreeThread> fimgApiAutoFreeThread = 0; + +class FimgApiAutoFreeThread : public Thread +{ + private: + bool mOneMoreSleep; + bool mDestroyed; + + public: + FimgApiAutoFreeThread(void): + //Thread(true), + Thread(false), + mOneMoreSleep(true), + mDestroyed(false) + { } + ~FimgApiAutoFreeThread(void) + { + if(mDestroyed == false) + { + FimgC210::DestroyAllInstance(); + mDestroyed = true; + } + } + + virtual void onFirstRef() + { + run("FimgApiAutoFreeThread", PRIORITY_BACKGROUND); + } + + virtual bool threadLoop() + { + //#define SLEEP_TIME (10000000) // 10 sec + #define SLEEP_TIME (3000000) // 3 sec + //#define SLEEP_TIME (1000000) // 1 sec + + if(mOneMoreSleep == true) + { + mOneMoreSleep = false; + usleep(SLEEP_TIME); + + return true; + } + else + { + if(mDestroyed == false) + { + FimgC210::DestroyAllInstance(); + mDestroyed = true; + } + + fimgApiAutoFreeThread = 0; + + return false; + } + } + + void SetOneMoreSleep(void) + { + mOneMoreSleep = true; + } +}; + +}; // namespace android + +#endif // FIMG_C210_H |