summaryrefslogtreecommitdiff
authorLawrence Mok <lawrence.mok@amlogic.com>2011-11-19 00:25:01 (GMT)
committer Lawrence Mok <lawrence.mok@amlogic.com>2011-11-19 00:25:01 (GMT)
commit838ea4f47a9c7374ca632987b36c18c8765212eb (patch)
tree63da17669255f8257ee1937294e6d5eb2958eba7
downloadhwcomposer-838ea4f47a9c7374ca632987b36c18c8765212eb.zip
hwcomposer-838ea4f47a9c7374ca632987b36c18c8765212eb.tar.gz
hwcomposer-838ea4f47a9c7374ca632987b36c18c8765212eb.tar.bz2
Initial commit
Diffstat
-rw-r--r--Android.mk16
-rw-r--r--hwcomposer.cpp149
2 files changed, 165 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..ca49683
--- a/dev/null
+++ b/Android.mk
@@ -0,0 +1,16 @@
+# Copyright (C) 2011 Amlogic
+#
+#
+
+LOCAL_PATH := $(call my-dir)
+
+# HAL module implemenation, not prelinked and stored in
+# /system/lib/hw/hwcomposer.amlogic.so
+include $(CLEAR_VARS)
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_SHARED_LIBRARIES := liblog libEGL
+LOCAL_SRC_FILES := hwcomposer.cpp
+LOCAL_MODULE := hwcomposer.amlogic
+LOCAL_CFLAGS:= -DLOG_TAG=\"hwcomposer\"
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hwcomposer.cpp b/hwcomposer.cpp
new file mode 100644
index 0000000..7585ee7
--- a/dev/null
+++ b/hwcomposer.cpp
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "hwcomposer"
+#include <hardware/hardware.h>
+
+#include <fcntl.h>
+#include <errno.h>
+
+#include <cutils/log.h>
+#include <cutils/atomic.h>
+
+#include <hardware/hwcomposer.h>
+
+#include <EGL/egl.h>
+
+// for private_handle_t and PRIV_FLAGS_VIDEO_HOLE
+#include "../../libhardware/modules/gralloc/gralloc_priv.h"
+
+/*****************************************************************************/
+
+struct hwc_context_t {
+ hwc_composer_device_t device;
+ /* our private state goes below here */
+};
+
+static int hwc_device_open(const struct hw_module_t* module, const char* name,
+ struct hw_device_t** device);
+
+static struct hw_module_methods_t hwc_module_methods = {
+ open: hwc_device_open
+};
+
+hwc_module_t HAL_MODULE_INFO_SYM = {
+ common: {
+ tag: HARDWARE_MODULE_TAG,
+ version_major: 1,
+ version_minor: 0,
+ id: HWC_HARDWARE_MODULE_ID,
+ name: "hwcomposer module",
+ author: "Amlogic",
+ methods: &hwc_module_methods,
+ dso : NULL,
+ reserved : {0},
+ }
+};
+
+/*****************************************************************************/
+
+static void dump_layer(hwc_layer_t const* l) {
+ LOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}",
+ l->compositionType, l->flags, l->handle, l->transform, l->blending,
+ l->sourceCrop.left,
+ l->sourceCrop.top,
+ l->sourceCrop.right,
+ l->sourceCrop.bottom,
+ l->displayFrame.left,
+ l->displayFrame.top,
+ l->displayFrame.right,
+ l->displayFrame.bottom);
+}
+
+static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) {
+ if (list && (list->flags & HWC_GEOMETRY_CHANGED)) {
+ for (size_t i=0 ; i<list->numHwLayers ; i++) {
+ hwc_layer_t* l = &list->hwLayers[i];
+ //dump_layer(l);
+
+ if (l->handle) {
+ private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(l->handle);
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_VIDEO_HOLE) {
+ l->hints |= HWC_HINT_CLEAR_FB;
+ l->compositionType = HWC_OVERLAY;
+ //LOGD("hnd=%#x flags=%d l->hints |= HWC_HINT_CLEAR_FB", hnd, hnd->flags);
+ return 0;
+ }
+ }
+ l->compositionType = HWC_FRAMEBUFFER;
+ }
+ }
+ return 0;
+}
+
+static int hwc_set(hwc_composer_device_t *dev,
+ hwc_display_t dpy,
+ hwc_surface_t sur,
+ hwc_layer_list_t* list)
+{
+ //for (size_t i=0 ; i<list->numHwLayers ; i++) {
+ // dump_layer(&list->hwLayers[i]);
+ //}
+
+ EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur);
+ if (!sucess) {
+ return HWC_EGL_ERROR;
+ }
+ return 0;
+}
+
+static int hwc_device_close(struct hw_device_t *dev)
+{
+ struct hwc_context_t* ctx = (struct hwc_context_t*)dev;
+ if (ctx) {
+ free(ctx);
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+
+static int hwc_device_open(const struct hw_module_t* module, const char* name,
+ struct hw_device_t** device)
+{
+ int status = -EINVAL;
+ if (!strcmp(name, HWC_HARDWARE_COMPOSER)) {
+ struct hwc_context_t *dev;
+ dev = (hwc_context_t*)malloc(sizeof(*dev));
+
+ /* initialize our state here */
+ memset(dev, 0, sizeof(*dev));
+
+ /* initialize the procs */
+ dev->device.common.tag = HARDWARE_DEVICE_TAG;
+ dev->device.common.version = 0;
+ dev->device.common.module = const_cast<hw_module_t*>(module);
+ dev->device.common.close = hwc_device_close;
+
+ dev->device.prepare = hwc_prepare;
+ dev->device.set = hwc_set;
+
+ *device = &dev->device.common;
+ status = 0;
+ }
+ return status;
+}