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
diff --git a/exynos5/hal/libfimg4x/Android.mk b/exynos5/hal/libfimg4x/Android.mk
new file mode 100644
index 0000000..d5d18e9
--- /dev/null
+++ b/exynos5/hal/libfimg4x/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_C_INCLUDES += external/skia/include/core
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES:= \
+ FimgApi.cpp \
+ FimgExynos5.cpp
+
+LOCAL_SHARED_LIBRARIES:= liblog libutils libbinder
+
+LOCAL_MODULE:= libfimg
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif
diff --git a/exynos5/hal/libfimg4x/FimgApi.cpp b/exynos5/hal/libfimg4x/FimgApi.cpp
new file mode 100644
index 0000000..ff11b8d
--- /dev/null
+++ b/exynos5/hal/libfimg4x/FimgApi.cpp
@@ -0,0 +1,376 @@
+/*
+**
+** 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.
+**
+**
+*/
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "SKIA"
+#include <utils/Log.h>
+
+#include "FimgApi.h"
+
+struct blit_op_table optbl[] = {
+ { (int)BLIT_OP_SOLID_FILL, "FILL" },
+ { (int)BLIT_OP_CLR, "CLR" },
+ { (int)BLIT_OP_SRC, "SRC" },
+ { (int)BLIT_OP_DST, "DST" },
+ { (int)BLIT_OP_SRC_OVER, "SRC_OVER" },
+ { (int)BLIT_OP_DST_OVER, "DST_OVER" },
+ { (int)BLIT_OP_SRC_IN, "SRC_IN" },
+ { (int)BLIT_OP_DST_IN, "DST_IN" },
+ { (int)BLIT_OP_SRC_OUT, "SRC_OUT" },
+ { (int)BLIT_OP_DST_OUT, "DST_OUT" },
+ { (int)BLIT_OP_SRC_ATOP, "SRC_ATOP" },
+ { (int)BLIT_OP_DST_ATOP, "DST_ATOP" },
+ { (int)BLIT_OP_XOR, "XOR" },
+ { (int)BLIT_OP_ADD, "ADD" },
+ { (int)BLIT_OP_MULTIPLY, "MULTIPLY" },
+ { (int)BLIT_OP_SCREEN, "SCREEN" },
+ { (int)BLIT_OP_DARKEN, "DARKEN" },
+ { (int)BLIT_OP_LIGHTEN, "LIGHTEN" },
+ { (int)BLIT_OP_DISJ_SRC_OVER, "DISJ_SRC_OVER" },
+ { (int)BLIT_OP_DISJ_DST_OVER, "DISJ_DST_OVER" },
+ { (int)BLIT_OP_DISJ_SRC_IN, "DISJ_SRC_IN" },
+ { (int)BLIT_OP_DISJ_DST_IN, "DISJ_DST_IN" },
+ { (int)BLIT_OP_DISJ_SRC_OUT, "DISJ_SRC_OUT" },
+ { (int)BLIT_OP_DISJ_DST_OUT, "DISJ_DST_OUT" },
+ { (int)BLIT_OP_DISJ_SRC_ATOP, "DISJ_SRC_ATOP" },
+ { (int)BLIT_OP_DISJ_DST_ATOP, "DISJ_DST_ATOP" },
+ { (int)BLIT_OP_DISJ_XOR, "DISJ_XOR" },
+ { (int)BLIT_OP_CONJ_SRC_OVER, "CONJ_SRC_OVER" },
+ { (int)BLIT_OP_CONJ_DST_OVER, "CONJ_DST_OVER" },
+ { (int)BLIT_OP_CONJ_SRC_IN, "CONJ_SRC_IN" },
+ { (int)BLIT_OP_CONJ_DST_IN, "CONJ_DST_IN" },
+ { (int)BLIT_OP_CONJ_SRC_OUT, "CONJ_SRC_OUT" },
+ { (int)BLIT_OP_CONJ_DST_OUT, "CONJ_DST_OUT" },
+ { (int)BLIT_OP_CONJ_SRC_ATOP, "CONJ_SRC_ATOP" },
+ { (int)BLIT_OP_CONJ_DST_ATOP, "CONJ_DST_ATOP" },
+ { (int)BLIT_OP_CONJ_XOR, "CONJ_XOR" },
+ { (int)BLIT_OP_USER_COEFF, "USER_COEFF" },
+ { (int)BLIT_OP_END, "" },
+};
+
+#ifndef REAL_DEBUG
+ void VOID_FUNC(const char *format, ...)
+ {}
+#endif
+
+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(struct fimg2d_blit *cmd)
+{
+ 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(cmd) == 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(struct fimg2d_blit *cmd)
+{
+ 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(struct fimg2d_blit *cmd)
+{
+ FimgApi * fimgApi = createFimgApi();
+
+ if (fimgApi == NULL) {
+ PRINT("%s::createFimgApi() fail\n", __func__);
+ return -1;
+ }
+
+ if (fimgApi->Stretch(cmd) == 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;
+}
+
+void printDataBlit(char *title, struct fimg2d_blit *cmd)
+{
+ LOGI("%s\n", title);
+
+ LOGI(" sequence_no. = %u\n", cmd->seq_no);
+ LOGI(" blit_op = %d(%s)\n", cmd->op, optbl[cmd->op].str);
+ LOGI(" fill_color = %X\n", cmd->solid_color);
+ LOGI(" global_alpha = %u\n", (unsigned int)cmd->g_alpha);
+ LOGI(" PREMULT = %s\n", cmd->premult == PREMULTIPLIED ? "PREMULTIPLIED" : "NON-PREMULTIPLIED");
+ LOGI(" do_dither = %s\n", cmd->dither == true ? "dither" : "no-dither");
+
+ printDataBlitRotate(cmd->rotate);
+
+ printDataBlitScale(cmd->scaling);
+
+ printDataBlitImage("SRC", cmd->src);
+ printDataBlitImage("DST", cmd->dst);
+ printDataBlitImage("MSK", cmd->msk);
+
+ printDataBlitRect("SRC", cmd->src_rect);
+ printDataBlitRect("DST", cmd->dst_rect);
+ printDataBlitRect("MSK", cmd->msk_rect);
+
+ printDataBlitClip(cmd->clipping);
+}
+
+void printDataBlitImage(char *title, struct fimg2d_image *image)
+{
+ if (NULL != image) {
+ LOGI(" Image_%s\n", title);
+ LOGI(" addr = %X\n", image->addr.start);
+ LOGI(" size = %u\n", image->addr.size);
+ LOGI(" (width, height) = (%d, %d)\n", image->width, image->height);
+ LOGI(" format = %d\n", image->fmt);
+ } else
+ LOGI(" Image_%s : NULL\n", title);
+}
+
+void printDataBlitRect(char *title, struct fimg2d_rect *rect)
+{
+ if (NULL != rect) {
+ LOGI(" RECT_%s\n", title);
+ LOGI(" (x1, y1) = (%d, %d)\n", rect->x1, rect->y1);
+ LOGI(" (x2, y2) = (%d, %d)\n", rect->x2, rect->y2);
+ LOGI(" (width, height) = (%d, %d)\n", rect->x2 - rect->x1, rect->y2 - rect->y1);
+ } else
+ LOGI(" RECT_%s : NULL\n", title);
+}
+
+void printDataBlitRotate(enum rotation rotate)
+{
+ LOGI(" ROTATE : %d\n", rotate);
+}
+
+void printDataBlitClip(struct fimg2d_clip *clip)
+{
+ if (NULL != clip) {
+ LOGI(" CLIP\n");
+ LOGI(" clip %s\n", clip->enable == true ? "enabled" : "disabled");
+ LOGI(" (x1, y1) = (%d, %d)\n", clip->x1, clip->y1);
+ LOGI(" (x2, y2) = (%d, %d)\n", clip->x2, clip->y2);
+ LOGI(" (width, hight) = (%d, %d)\n", clip->x2 - clip->x1, clip->y2 - clip->y1);
+ } else
+ LOGI(" CLIP : NULL\n");
+}
+
+void printDataBlitScale(struct fimg2d_scale *scaling)
+{
+ if (NULL != scaling) {
+ LOGI(" SCALING\n");
+ LOGI(" scale_mode : %s\n", scaling->mode == 0 ?
+ "NO_SCALING" :
+ (scaling->mode == 1 ? "SCALING_NEAREST" : "SCALING_BILINEAR"));
+ LOGI(" scaling_factor_unit : %s\n", scaling->factor == 0 ? "PERCENT" : "PIXEL");
+
+ if (scaling->factor == 0)
+ LOGI(" scaling_factor : (scale_w, scale_y) = (%d, %d)\n", scaling->scale_w, scaling->scale_h);
+ else {
+ LOGI(" src : (src_w, src_h) = (%d, %d)\n", scaling->src_w, scaling->src_h);
+ LOGI(" dst : (dst_w, dst_h) = (%d, %d)\n", scaling->dst_w, scaling->dst_h);
+ LOGI(" scaling_factor : (scale_w, scale_y) = (%3.2f, %3.2f)\n", (double)scaling->dst_w / scaling->src_w, (double)scaling->dst_h / scaling->src_h);
+ }
+ } else
+ LOGI(" SCALING : NULL(NO SCALE MODE)\n");
+
+}
+
+void printDataMatrix(int matrixType)
+{
+ LOGI(" MATRIX\n");
+
+ if (matrixType & SkMatrix::kIdentity_Mask)
+ LOGI(" Matrix_type : Identity_Mask\n");
+
+ if (matrixType & SkMatrix::kTranslate_Mask)
+ LOGI(" Matrix_type : Translate_Mask(the matrix has translation)\n");
+
+ if (matrixType & SkMatrix::kScale_Mask)
+ LOGI(" Matrix_type : Scale_Mask(the matrix has X or Y scale)\n");
+
+ if (matrixType & SkMatrix::kAffine_Mask)
+ LOGI(" Matrix_type : Affine_Mask(the matrix skews or rotates)\n");
+
+ if (matrixType & SkMatrix::kPerspective_Mask)
+ LOGI(" Matrix_type : Perspective_Mask(the matrix is in perspective)\n");
+}
diff --git a/exynos5/hal/libfimg4x/FimgApi.h b/exynos5/hal/libfimg4x/FimgApi.h
new file mode 100644
index 0000000..a2c9eac
--- /dev/null
+++ b/exynos5/hal/libfimg4x/FimgApi.h
@@ -0,0 +1,114 @@
+/*
+**
+** 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 "SkMatrix.h"
+#include "sec_g2d_4x.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
+
+#ifdef __cplusplus
+
+struct blit_op_table {
+ int op;
+ const char *str;
+};
+
+extern struct blit_op_table optbl[];
+
+class FimgApi
+{
+public:
+#endif
+
+#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(struct fimg2d_blit *cmd);
+ bool Sync(void);
+
+protected:
+ virtual bool t_Create(void);
+ virtual bool t_Destroy(void);
+ virtual bool t_Stretch(struct fimg2d_blit *cmd);
+ virtual bool t_Sync(void);
+ virtual bool t_Lock(void);
+ virtual bool t_UnLock(void);
+
+};
+#endif
+
+#ifdef __cplusplus
+extern "C"
+#endif
+struct FimgApi *createFimgApi();
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void destroyFimgApi(FimgApi *ptrFimgApi);
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int stretchFimgApi(struct fimg2d_blit *cmd);
+#ifdef __cplusplus
+extern "C"
+#endif
+int SyncFimgApi(void);
+
+void printDataBlit(char *title, struct fimg2d_blit *cmd);
+void printDataBlitRotate(enum rotation rotate);
+void printDataBlitImage(char *title, struct fimg2d_image *image);
+void printDataBlitRect(char *title, struct fimg2d_rect *rect);
+void printDataBlitClip(struct fimg2d_clip *clip);
+void printDataBlitScale(struct fimg2d_scale *scaling);
+void printDataMatrix(int matrixType);
+
+#endif //FIMG_API_H
diff --git a/exynos5/hal/libfimg4x/FimgExynos5.cpp b/exynos5/hal/libfimg4x/FimgExynos5.cpp
new file mode 100644
index 0000000..87c8527
--- /dev/null
+++ b/exynos5/hal/libfimg4x/FimgExynos5.cpp
@@ -0,0 +1,301 @@
+/*
+**
+** 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.
+**
+**
+*/
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "FimgExynos5"
+#include <utils/Log.h>
+
+#include "FimgExynos5.h"
+
+namespace android
+{
+Mutex FimgV4x::m_instanceLock;
+int FimgV4x::m_curFimgV4xIndex = 0;
+int FimgV4x::m_numOfInstance = 0;
+FimgApi * FimgV4x::m_ptrFimgApiList[NUMBER_FIMG_LIST] = {NULL, };
+
+//---------------------------------------------------------------------------//
+
+FimgV4x::FimgV4x()
+ : 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, "FimgV4x");
+}
+
+FimgV4x::~FimgV4x()
+{
+ delete m_lock;
+}
+
+FimgApi *FimgV4x::CreateInstance()
+{
+ Mutex::Autolock autolock(m_instanceLock);
+
+ FimgApi *ptrFimg = NULL;
+
+ for(int i = m_curFimgV4xIndex; i < NUMBER_FIMG_LIST; i++) {
+ if (m_ptrFimgApiList[i] == NULL)
+ m_ptrFimgApiList[i] = new FimgV4x;
+
+ 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_curFimgV4xIndex = i + 1;
+ else
+ m_curFimgV4xIndex = 0;
+
+ ptrFimg = m_ptrFimgApiList[i];
+ goto CreateInstance_End;
+ }
+
+CreateInstance_End :
+
+ return ptrFimg;
+}
+
+void FimgV4x::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 {
+ FimgV4x * tempFimgV4x = (FimgV4x *)m_ptrFimgApiList[i];
+ delete tempFimgV4x;
+ m_ptrFimgApiList[i] = NULL;
+
+ m_numOfInstance--;
+ }
+
+ break;
+ }
+ }
+}
+
+void FimgV4x::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 {
+ FimgV4x * tempFimgV4x = (FimgV4x *)m_ptrFimgApiList[i];
+ delete tempFimgV4x;
+ m_ptrFimgApiList[i] = NULL;
+ }
+ }
+ }
+}
+
+bool FimgV4x::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 FimgV4x::t_Destroy(void)
+{
+ bool ret = true;
+
+ if (m_DestroyG2D() == false) {
+ PRINT("%s::m_DestroyG2D() fail \n", __func__);
+ ret = false;
+ }
+
+ return ret;
+}
+
+bool FimgV4x::t_Stretch(struct fimg2d_blit *cmd)
+{
+#ifdef CHECK_FIMGV4x_PERFORMANCE
+#define NUM_OF_STEP (10)
+ StopWatch stopWatch("CHECK_FIMGV4x_PERFORMANCE");
+ const char *stopWatchName[NUM_OF_STEP];
+ nsecs_t stopWatchTime[NUM_OF_STEP];
+ int stopWatchIndex = 0;
+#endif // CHECK_FIMGV4x_PERFORMANCE
+
+ if (m_DoG2D(cmd) == 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_FIMGV4x_PERFORMANCE
+ m_PrintFimgV4xPerformance(src, dst, stopWatchIndex, stopWatchName, stopWatchTime);
+ #endif // CHECK_FIMGV4x_PERFORMANCE
+
+ return true;
+
+STRETCH_FAIL:
+ return false;
+
+}
+
+bool FimgV4x::t_Sync(void)
+{
+ if (m_PollG2D(&m_g2dPoll) == false)
+ {
+ PRINT("%s::m_PollG2D() fail\n", __func__);
+ goto SYNC_FAIL;
+ }
+ return true;
+
+SYNC_FAIL:
+ return false;
+
+}
+
+bool FimgV4x::t_Lock(void)
+{
+ m_lock->lock();
+ return true;
+}
+
+bool FimgV4x::t_UnLock(void)
+{
+ m_lock->unlock();
+ return true;
+}
+
+bool FimgV4x::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 FimgV4x::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 FimgV4x::m_DoG2D(struct fimg2d_blit *cmd)
+{
+
+ if (ioctl(m_g2dFd, FIMG2D_BITBLT_BLIT, cmd) < 0)
+ return false;
+
+ return true;
+}
+
+inline bool FimgV4x::m_PollG2D(struct pollfd * events)
+{
+#define G2D_POLL_TIME (1000)
+
+ int ret;
+
+ ret = poll(events, 1, G2D_POLL_TIME);
+
+ if (ret < 0) {
+ PRINT("%s::poll fail \n", __func__);
+ return false;
+ }
+ else if (ret == 0) {
+ PRINT("%s::No data in %d milli secs..\n", __func__, G2D_POLL_TIME);
+ return false;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------------------------//
+// extern function
+//---------------------------------------------------------------------------//
+extern "C" struct FimgApi * createFimgApi()
+{
+ if (fimgApiAutoFreeThread == 0)
+ fimgApiAutoFreeThread = new FimgApiAutoFreeThread();
+ else
+ fimgApiAutoFreeThread->SetOneMoreSleep();
+
+ return FimgV4x::CreateInstance();
+}
+
+extern "C" void destroyFimgApi(FimgApi * ptrFimgApi)
+{
+ // Dont' call DestroyInstance.
+}
+
+}; // namespace android
diff --git a/exynos5/hal/libfimg4x/FimgExynos5.h b/exynos5/hal/libfimg4x/FimgExynos5.h
new file mode 100644
index 0000000..71295a6
--- /dev/null
+++ b/exynos5/hal/libfimg4x/FimgExynos5.h
@@ -0,0 +1,169 @@
+/*
+**
+** 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_EXYNOS5_H
+#define FIMG_EXYNOS5_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 "sec_g2d_4x.h"
+
+namespace android
+{
+
+#define NUMBER_FIMG_LIST (1) // kcoolsw : because of pmem
+#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))
+#define SLEEP_TIME (3000000) // 3 sec
+
+//---------------------------------------------------------------------------//
+// class FimgV4x : public FimgBase
+//---------------------------------------------------------------------------//
+class FimgV4x : 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_curFimgV4xIndex;
+ static int m_numOfInstance;
+
+ static FimgApi *m_ptrFimgApiList[NUMBER_FIMG_LIST];
+
+protected :
+ FimgV4x();
+ virtual ~FimgV4x();
+
+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(struct fimg2d_blit *cmd);
+ 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 m_DoG2D(struct fimg2d_blit *cmd);
+
+ inline bool m_PollG2D(struct pollfd *events);
+
+ inline int m_ColorFormatFimgApi2FimgHw(int colorFormat);
+};
+
+class FimgApiAutoFreeThread;
+
+static sp<FimgApiAutoFreeThread> fimgApiAutoFreeThread = 0;
+
+class FimgApiAutoFreeThread : public Thread
+{
+private:
+ bool mOneMoreSleep;
+ bool mDestroyed;
+
+public:
+ FimgApiAutoFreeThread(void):
+ Thread(false),
+ mOneMoreSleep(true),
+ mDestroyed(false)
+ { }
+ ~FimgApiAutoFreeThread(void)
+ {
+ if (mDestroyed == false)
+ {
+ FimgV4x::DestroyAllInstance();
+ mDestroyed = true;
+ }
+ }
+
+ virtual void onFirstRef()
+ {
+ run("FimgApiAutoFreeThread", PRIORITY_BACKGROUND);
+ }
+
+ virtual bool threadLoop()
+ {
+
+ if (mOneMoreSleep == true)
+ {
+ mOneMoreSleep = false;
+ usleep(SLEEP_TIME);
+
+ return true;
+ }
+ else
+ {
+ if (mDestroyed == false)
+ {
+ FimgV4x::DestroyAllInstance();
+ mDestroyed = true;
+ }
+
+ fimgApiAutoFreeThread = 0;
+
+ return false;
+ }
+ }
+
+ void SetOneMoreSleep(void)
+ {
+ mOneMoreSleep = true;
+ }
+};
+
+}; // namespace android
+
+#endif // FIMG_EXYNOS5_H
diff --git a/exynos5/hal/libfimg4x/sec_g2d_4x.h b/exynos5/hal/libfimg4x/sec_g2d_4x.h
new file mode 100644
index 0000000..b9ddbb2
--- /dev/null
+++ b/exynos5/hal/libfimg4x/sec_g2d_4x.h
@@ -0,0 +1,326 @@
+/*
+ * Copyright 2011, 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.
+ */
+#ifndef __SEC_G2D_4X_H
+#define __SEC_G2D_4X_H __FILE__
+
+#define SEC_G2D_DEV_NAME "/dev/fimg2d"
+
+/* ioctl commands */
+#define FIMG2D_IOCTL_MAGIC 'F'
+#define FIMG2D_BITBLT_BLIT _IOWR(FIMG2D_IOCTL_MAGIC, 0, struct fimg2d_blit)
+#define FIMG2D_BITBLT_SYNC _IO(FIMG2D_IOCTL_MAGIC, 1)
+#define FIMG2D_BITBLT_VERSION _IOR(FIMG2D_IOCTL_MAGIC, 2, struct fimg2d_version)
+
+#define G2D_ALPHA_VALUE_MAX (255)
+
+enum addr_space {
+ ADDR_UNKNOWN,
+ ADDR_PHYS,
+ ADDR_KERN,
+ ADDR_USER,
+ ADDR_DEVICE,
+};
+
+/**
+ * DO NOT CHANGE THIS ORDER
+ */
+enum pixel_order {
+ AX_RGB = 0,
+ RGB_AX,
+ AX_BGR,
+ BGR_AX,
+ ARGB_ORDER_END,
+
+ P1_CRY1CBY0,
+ P1_CBY1CRY0,
+ P1_Y1CRY0CB,
+ P1_Y1CBY0CR,
+ P1_ORDER_END,
+
+ P2_CRCB,
+ P2_CBCR,
+ P2_ORDER_END,
+};
+
+/**
+ * DO NOT CHANGE THIS ORDER
+ */
+enum color_format {
+ CF_XRGB_8888 = 0,
+ CF_ARGB_8888,
+ CF_RGB_565,
+ CF_XRGB_1555,
+ CF_ARGB_1555,
+ CF_XRGB_4444,
+ CF_ARGB_4444,
+ CF_RGB_888,
+ CF_YCBCR_444,
+ CF_YCBCR_422,
+ CF_YCBCR_420,
+ CF_A8,
+ CF_L8,
+ SRC_DST_FORMAT_END,
+
+ CF_MSK_1BIT,
+ CF_MSK_4BIT,
+ CF_MSK_8BIT,
+ CF_MSK_16BIT_565,
+ CF_MSK_16BIT_1555,
+ CF_MSK_16BIT_4444,
+ CF_MSK_32BIT_8888,
+ MSK_FORMAT_END,
+};
+
+enum rotation {
+ ORIGIN,
+ ROT_90, /* clockwise */
+ ROT_180,
+ ROT_270,
+ XFLIP, /* x-axis flip */
+ YFLIP, /* y-axis flip */
+};
+
+/**
+ * @NO_REPEAT: no effect
+ * @REPEAT_NORMAL: repeat horizontally and vertically
+ * @REPEAT_PAD: pad with pad color
+ * @REPEAT_REFLECT: reflect horizontally and vertically
+ * @REPEAT_CLAMP: pad with edge color of original image
+ *
+ * DO NOT CHANGE THIS ORDER
+ */
+enum repeat {
+ NO_REPEAT = 0,
+ REPEAT_NORMAL, /* default setting */
+ REPEAT_PAD,
+ REPEAT_REFLECT, REPEAT_MIRROR = REPEAT_REFLECT,
+ REPEAT_CLAMP,
+};
+
+enum scaling {
+ NO_SCALING,
+ SCALING_NEAREST,
+ SCALING_BILINEAR,
+};
+
+/**
+ * @SCALING_PERCENTAGE: percentage of width, height
+ * @SCALING_PIXELS: coordinate of src, dest
+ */
+enum scaling_factor {
+ SCALING_PERCENTAGE,
+ SCALING_PIXELS,
+};
+
+/**
+ * premultiplied alpha
+ */
+enum premultiplied {
+ PREMULTIPLIED,
+ NON_PREMULTIPLIED,
+};
+
+/**
+ * @TRANSP: discard bluescreen color
+ * @BLUSCR: replace bluescreen color with background color
+ */
+enum bluescreen {
+ OPAQUE,
+ TRANSP,
+ BLUSCR,
+};
+
+/**
+ * DO NOT CHANGE THIS ORDER
+ */
+enum blit_op {
+ BLIT_OP_SOLID_FILL = 0,
+
+ BLIT_OP_CLR,
+ BLIT_OP_SRC, BLIT_OP_SRC_COPY = BLIT_OP_SRC,
+ BLIT_OP_DST,
+ BLIT_OP_SRC_OVER,
+ BLIT_OP_DST_OVER, BLIT_OP_OVER_REV = BLIT_OP_DST_OVER,
+ BLIT_OP_SRC_IN,
+ BLIT_OP_DST_IN, BLIT_OP_IN_REV = BLIT_OP_DST_IN,
+ BLIT_OP_SRC_OUT,
+ BLIT_OP_DST_OUT, BLIT_OP_OUT_REV = BLIT_OP_DST_OUT,
+ BLIT_OP_SRC_ATOP,
+ BLIT_OP_DST_ATOP, BLIT_OP_ATOP_REV = BLIT_OP_DST_ATOP,
+ BLIT_OP_XOR,
+
+ BLIT_OP_ADD,
+ BLIT_OP_MULTIPLY,
+ BLIT_OP_SCREEN,
+ BLIT_OP_DARKEN,
+ BLIT_OP_LIGHTEN,
+
+ BLIT_OP_DISJ_SRC_OVER,
+ BLIT_OP_DISJ_DST_OVER, BLIT_OP_SATURATE = BLIT_OP_DISJ_DST_OVER,
+ BLIT_OP_DISJ_SRC_IN,
+ BLIT_OP_DISJ_DST_IN, BLIT_OP_DISJ_IN_REV = BLIT_OP_DISJ_DST_IN,
+ BLIT_OP_DISJ_SRC_OUT,
+ BLIT_OP_DISJ_DST_OUT, BLIT_OP_DISJ_OUT_REV = BLIT_OP_DISJ_DST_OUT,
+ BLIT_OP_DISJ_SRC_ATOP,
+ BLIT_OP_DISJ_DST_ATOP, BLIT_OP_DISJ_ATOP_REV = BLIT_OP_DISJ_DST_ATOP,
+ BLIT_OP_DISJ_XOR,
+
+ BLIT_OP_CONJ_SRC_OVER,
+ BLIT_OP_CONJ_DST_OVER, BLIT_OP_CONJ_OVER_REV = BLIT_OP_CONJ_DST_OVER,
+ BLIT_OP_CONJ_SRC_IN,
+ BLIT_OP_CONJ_DST_IN, BLIT_OP_CONJ_IN_REV = BLIT_OP_CONJ_DST_IN,
+ BLIT_OP_CONJ_SRC_OUT,
+ BLIT_OP_CONJ_DST_OUT, BLIT_OP_CONJ_OUT_REV = BLIT_OP_CONJ_DST_OUT,
+ BLIT_OP_CONJ_SRC_ATOP,
+ BLIT_OP_CONJ_DST_ATOP, BLIT_OP_CONJ_ATOP_REV = BLIT_OP_CONJ_DST_ATOP,
+ BLIT_OP_CONJ_XOR,
+
+ /* Add new operation type here */
+
+ /* user select coefficient manually */
+ BLIT_OP_USER_COEFF,
+
+ /* end of blit operation */
+ BLIT_OP_END,
+
+ /* driver not supporting format */
+ BLIT_OP_NOT_SUPPORTED
+};
+
+#define MAX_FIMG2D_BLIT_OP (int)BLIT_OP_END
+
+struct fimg2d_version {
+ unsigned int hw;
+ unsigned int sw;
+};
+
+/**
+ * @start: start address or unique id of image
+ * @size: whole length of allocated image
+ * @cacheable: memory is cacheable
+ * @pinnable: memory is pinnable. currently not supported.
+ */
+struct fimg2d_addr {
+ enum addr_space type;
+ unsigned long start;
+ size_t size;
+ int cacheable;
+ int pinnable;
+};
+
+struct fimg2d_rect {
+ int x1;
+ int y1;
+ int x2; /* x1 + width */
+ int y2; /* y1 + height */
+};
+
+/**
+ * if factor is percentage, scale_w and scale_h are valid
+ * if factor is pixels, src_w, src_h, dst_w, dst_h are valid
+ */
+struct fimg2d_scale {
+ enum scaling mode;
+ enum scaling_factor factor;
+
+ /* percentage */
+ int scale_w;
+ int scale_h;
+
+ /* pixels */
+ int src_w, src_h;
+ int dst_w, dst_h;
+};
+
+/**
+ * coordinate from start address(0,0) of image
+ */
+struct fimg2d_clip {
+ bool enable;
+ int x1;
+ int y1;
+ int x2; /* x1 + width */
+ int y2; /* y1 + height */
+};
+
+struct fimg2d_repeat {
+ enum repeat mode;
+ unsigned long pad_color;
+};
+
+/**
+ * @bg_color: bg_color is valid only if bluescreen mode is BLUSCR.
+ */
+struct fimg2d_bluscr {
+ enum bluescreen mode;
+ unsigned long bs_color;
+ unsigned long bg_color;
+};
+
+/**
+ * @plane2: address info for CbCr in YCbCr 2plane mode
+ */
+struct fimg2d_image {
+ struct fimg2d_addr addr;
+ struct fimg2d_addr plane2;
+ int width;
+ int height;
+ int stride;
+ enum pixel_order order;
+ enum color_format fmt;
+};
+
+struct fimg2d_param {
+ enum blit_op op;
+ unsigned long fillcolor;
+ unsigned char g_alpha;
+ enum premultiplied premult;
+ bool dither;
+ enum rotation rotate;
+ struct fimg2d_scale *scaling;
+ struct fimg2d_repeat *repeat;
+ struct fimg2d_bluscr *bluscr;
+ struct fimg2d_clip *clipping;
+};
+
+/**
+ * @g_alpha: 0xff is opaque, 0x0 is transparnet
+ * @seq_no: used for debugging
+ */
+struct fimg2d_blit {
+ enum blit_op op;
+
+ enum premultiplied premult;
+ unsigned char g_alpha;
+ bool dither;
+ enum rotation rotate;
+ struct fimg2d_scale *scaling;
+ struct fimg2d_repeat *repeat;
+ struct fimg2d_bluscr *bluscr;
+ struct fimg2d_clip *clipping;
+
+ unsigned long solid_color;
+ struct fimg2d_image *src;
+ struct fimg2d_image *dst;
+ struct fimg2d_image *msk;
+
+ struct fimg2d_rect *src_rect;
+ struct fimg2d_rect *dst_rect;
+ struct fimg2d_rect *msk_rect;
+
+ unsigned int seq_no;
+};
+#endif /* __SEC_G2D_4X_H__ */