summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarissa Wall <marissaw@google.com>2017-03-02 22:08:17 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-02 22:08:17 +0000
commite754968b56fadfa23889e4849a315e589fda67df (patch)
treed2eabba0d6fd9cdfe170c341fa6755d4ff8115c8
parent20def2f16da87c6cba99efd26b8b306bb6310e0c (diff)
parent09b2a0f5d99053b97c3e7ae56c02f40534ae9e63 (diff)
downloadflounder-e754968b56fadfa23889e4849a315e589fda67df.tar.gz
hwc2: open and close hwc2 device
am: 09b2a0f5d9 Change-Id: I19a7c7bb6e8b047718f753013a93824df6f7b0e9
-rw-r--r--device.mk3
-rw-r--r--hwc2/Android.mk51
-rw-r--r--hwc2/CleanSpec.mk52
-rw-r--r--hwc2/README9
-rw-r--r--hwc2/hwc2.cpp422
-rw-r--r--hwc2/hwc2.h26
6 files changed, 562 insertions, 1 deletions
diff --git a/device.mk b/device.mk
index a11859e..10ffe3c 100644
--- a/device.mk
+++ b/device.mk
@@ -207,7 +207,8 @@ PRODUCT_PACKAGES += \
power.flounder \
lights.flounder \
sensors.flounder \
- thermal.flounder
+ thermal.flounder \
+ hwcomposer.flounder
# Filesystem management tools
PRODUCT_PACKAGES += \
diff --git a/hwc2/Android.mk b/hwc2/Android.mk
new file mode 100644
index 0000000..c784b66
--- /dev/null
+++ b/hwc2/Android.mk
@@ -0,0 +1,51 @@
+# Copyright (C) 2016 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.
+
+
+# This hardware composer implements version 2.0. It is to be used as a reference
+# guide for writing HWC 2.0 implementations. To enable, add
+# "TARGET_USES_HWC2 := true" to flounder's BoardConfig.mk.
+# It is a 2D HAL (no GL acceleration). Enabling it will degrade performance.
+# To disable, remove "TARGET_USES_HWC2 := true" and run "make installclean"
+ifeq ($(TARGET_USES_HWC2),true)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# HAL module implemenation, not prelinked and stored in
+# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
+LOCAL_MODULE_RELATIVE_PATH := hw
+
+LOCAL_MODULE := hwcomposer.$(TARGET_BOOTLOADER_BOARD_NAME)
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog
+
+LOCAL_SRC_FILES := hwc2.cpp
+
+LOCAL_MODLE_TAGS := optional
+
+LOCAL_CFLAGS += -DLOG_TAG=\"hwcomposer\"
+
+# The liboemcrypto.a prebuilt was built before we introduced the workaround for
+# -Bsymbolic, so it was built without -fPIC. Work around this by using
+# -Bsymbolic for projects that depend on it.
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif # TARGET_USES_HWC2
diff --git a/hwc2/CleanSpec.mk b/hwc2/CleanSpec.mk
new file mode 100644
index 0000000..e895bf4
--- /dev/null
+++ b/hwc2/CleanSpec.mk
@@ -0,0 +1,52 @@
+# Copyright (C) 2016 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj_arm/SHARED_LIBRARIES/hwcomposer.flounder_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/hwcomposer.flounder_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib64/hw/hwcomposer.flounder.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/hw/hwcomposer.flounder.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj_arm/lib/hwcomposer.flounder.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/hwcomposer.flounder.so)
diff --git a/hwc2/README b/hwc2/README
new file mode 100644
index 0000000..14cfcd8
--- /dev/null
+++ b/hwc2/README
@@ -0,0 +1,9 @@
+This hardware composer implements version 2.0. It is to be used as a reference
+guide for writing HWC 2.0 implementations. It is a 2D HAL (no GL acceleration).
+Enabling it will degrade performance. The NVIDIA hardware composer is still the
+supported hwcomposer for flounder.
+
+Future hardware composers should be written using drm_hwcomposer.
+
+To enable, add "TARGET_USES_HWC2 := true" to flounder's BoardConfig.mk.
+To disable, remove "TARGET_USES_HWC2 := true" and run "make installclean"
diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp
new file mode 100644
index 0000000..e9b7e2b
--- /dev/null
+++ b/hwc2/hwc2.cpp
@@ -0,0 +1,422 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <cutils/log.h>
+
+#include <inttypes.h>
+#include <cstdlib>
+#include <new>
+#include <array>
+
+#include "hwc2.h"
+
+static int hwc2_device_open(const struct hw_module_t *module, const char *name,
+ struct hw_device_t **device);
+
+static int32_t hwc2_device_close(struct hw_device_t *device);
+
+static struct hw_module_methods_t hwc2_module_methods = {
+ .open = hwc2_device_open
+};
+
+hw_module_t HAL_MODULE_INFO_SYM = {
+ .tag = HARDWARE_MODULE_TAG,
+ .id = HWC_HARDWARE_MODULE_ID,
+ .name = "NVIDIA Tegra hwcomposer module",
+ .author = "AOSP",
+ .methods = &hwc2_module_methods,
+};
+
+
+hwc2_error_t create_virtual_display(hwc2_device_t* /*device*/,
+ uint32_t /*width*/, uint32_t /*height*/,
+ android_pixel_format_t* /*format*/,
+ hwc2_display_t* /*out_display*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t destroy_virtual_display(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+void dump(hwc2_device_t* /*device*/, uint32_t* /*out_size*/,
+ char* /*out_buffer*/)
+{
+ return;
+}
+
+uint32_t get_max_virtual_display_count(hwc2_device_t* /*device*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t register_callback(hwc2_device_t* /*device*/,
+ hwc2_callback_descriptor_t /*descriptor*/,
+ hwc2_callback_data_t /*callback_data*/,
+ hwc2_function_pointer_t /*pointer*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t accept_display_changes(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t create_layer(hwc2_device_t* /*device*/, hwc2_display_t /*display*/,
+ hwc2_layer_t* /*out_layer*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t destroy_layer(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_active_config(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_config_t* /*out_config*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_changed_composition_types(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_num_elements*/,
+ hwc2_layer_t* /*out_layers*/, hwc2_composition_t* /*out_types*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_client_target_support(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t /*width*/, uint32_t /*height*/,
+ android_pixel_format_t /*format*/, android_dataspace_t /*dataspace*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_color_modes(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_num_modes*/,
+ android_color_mode_t* /*out_modes*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_display_attribute(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_config_t /*config*/,
+ hwc2_attribute_t /*attribute*/, int32_t* /*out_value*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_display_configs(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_num_configs*/,
+ hwc2_config_t* /*out_configs*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_display_name(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_size*/, char* /*out_name*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_display_requests(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/,
+ hwc2_display_request_t* /*out_display_requests*/,
+ uint32_t* /*out_num_elements*/, hwc2_layer_t* /*out_layers*/,
+ hwc2_layer_request_t* /*out_layer_requests*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_display_type(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_display_type_t* /*out_type*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_doze_support(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, int32_t* /*out_support*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_hdr_capabilities(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_num_types*/,
+ android_hdr_t* /*out_types*/, float* /*out_max_luminance*/,
+ float* /*out_max_average_luminance*/, float* /*out_min_luminance*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t get_release_fences(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_num_elements*/,
+ hwc2_layer_t* /*out_layers*/, int32_t* /*out_fences*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t present_display(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, int32_t* /*out_present_fence*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_active_config(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_config_t /*config*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_client_target(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, buffer_handle_t /*target*/,
+ int32_t /*acquire_fence*/, android_dataspace_t /*dataspace*/,
+ hwc_region_t /*damage*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_color_mode(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, android_color_mode_t /*mode*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_color_transform(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, const float* /*matrix*/,
+ android_color_transform_t /*hint*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_output_buffer(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, buffer_handle_t /*buffer*/,
+ int32_t /*release_fence*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_power_mode(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_power_mode_t /*mode*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_vsync_enabled(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_vsync_t /*enabled*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t validate_display(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, uint32_t* /*out_num_types*/,
+ uint32_t* /*out_num_requests*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_cursor_position(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/, int32_t /*x*/,
+ int32_t /*y*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_buffer(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ buffer_handle_t /*buffer*/, int32_t /*acquire_fence*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_surface_damage(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc_region_t /*damage*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_blend_mode(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc2_blend_mode_t /*mode*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_color(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc_color_t /*color*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_composition_type(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc2_composition_t /*type*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_dataspace(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ android_dataspace_t /*dataspace*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_display_frame(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc_rect_t /*frame*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_plane_alpha(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/, float /*alpha*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_source_crop(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc_frect_t /*crop*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_transform(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc_transform_t /*transform*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_visible_region(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/,
+ hwc_region_t /*visible*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t set_layer_z_order(hwc2_device_t* /*device*/,
+ hwc2_display_t /*display*/, hwc2_layer_t /*layer*/, uint32_t /*z*/)
+{
+ return HWC2_ERROR_NONE;
+}
+
+/* Indexed using the hwc2_function_descriptor_t enum to find the corresponding
+ * function */
+static const std::array<hwc2_function_pointer_t, 44> hwc2_func_ptrs = {{
+ /* Index 0 corresponds to HWC2_FUNCTION_INVALID */
+ (hwc2_function_pointer_t) nullptr,
+ (hwc2_function_pointer_t) accept_display_changes,
+ (hwc2_function_pointer_t) create_layer,
+ (hwc2_function_pointer_t) create_virtual_display,
+ (hwc2_function_pointer_t) destroy_layer,
+ (hwc2_function_pointer_t) destroy_virtual_display,
+ (hwc2_function_pointer_t) dump,
+ (hwc2_function_pointer_t) get_active_config,
+ (hwc2_function_pointer_t) get_changed_composition_types,
+ (hwc2_function_pointer_t) get_client_target_support,
+ (hwc2_function_pointer_t) get_color_modes,
+ (hwc2_function_pointer_t) get_display_attribute,
+ (hwc2_function_pointer_t) get_display_configs,
+ (hwc2_function_pointer_t) get_display_name,
+ (hwc2_function_pointer_t) get_display_requests,
+ (hwc2_function_pointer_t) get_display_type,
+ (hwc2_function_pointer_t) get_doze_support,
+ (hwc2_function_pointer_t) get_hdr_capabilities,
+ (hwc2_function_pointer_t) get_max_virtual_display_count,
+ (hwc2_function_pointer_t) get_release_fences,
+ (hwc2_function_pointer_t) present_display,
+ (hwc2_function_pointer_t) register_callback,
+ (hwc2_function_pointer_t) set_active_config,
+ (hwc2_function_pointer_t) set_client_target,
+ (hwc2_function_pointer_t) set_color_mode,
+ (hwc2_function_pointer_t) set_color_transform,
+ (hwc2_function_pointer_t) set_cursor_position,
+ (hwc2_function_pointer_t) set_layer_blend_mode,
+ (hwc2_function_pointer_t) set_layer_buffer,
+ (hwc2_function_pointer_t) set_layer_color,
+ (hwc2_function_pointer_t) set_layer_composition_type,
+ (hwc2_function_pointer_t) set_layer_dataspace,
+ (hwc2_function_pointer_t) set_layer_display_frame,
+ (hwc2_function_pointer_t) set_layer_plane_alpha,
+ (hwc2_function_pointer_t) nullptr, /*set_layer_sideband_stream unsupported*/
+ (hwc2_function_pointer_t) set_layer_source_crop,
+ (hwc2_function_pointer_t) set_layer_surface_damage,
+ (hwc2_function_pointer_t) set_layer_transform,
+ (hwc2_function_pointer_t) set_layer_visible_region,
+ (hwc2_function_pointer_t) set_layer_z_order,
+ (hwc2_function_pointer_t) set_output_buffer,
+ (hwc2_function_pointer_t) set_power_mode,
+ (hwc2_function_pointer_t) set_vsync_enabled,
+ (hwc2_function_pointer_t) validate_display,
+}};
+
+hwc2_function_pointer_t get_function(struct hwc2_device* /*device*/,
+ /*hwc2_function_descriptor_t*/ int32_t descriptor)
+{
+ if (descriptor == HWC2_FUNCTION_INVALID ||
+ static_cast<size_t>(descriptor) >= hwc2_func_ptrs.size()) {
+ ALOGW("invalid descriptor");
+ return nullptr;
+ }
+ return hwc2_func_ptrs[descriptor];
+}
+
+void get_capabilities(struct hwc2_device* /*device*/, uint32_t *out_count,
+ /*hwc2_capability_t*/ int32_t* /*outCapabilities*/)
+{
+ *out_count = 0;
+}
+
+static int32_t hwc2_device_close(struct hw_device_t *device)
+{
+ hwc2_context *ctx = reinterpret_cast<hwc2_context *>(device);
+ delete ctx;
+ return 0;
+}
+
+static int hwc2_device_open(const struct hw_module_t *module, const char *name,
+ struct hw_device_t **hw_device)
+{
+ if (strcmp(name, HWC_HARDWARE_COMPOSER))
+ return -EINVAL;
+
+ hwc2_context *ctx = new hwc2_context();
+ if (!ctx) {
+ ALOGE("failed to allocate hwc2_context");
+ return -ENOMEM;
+ }
+
+ ctx->hwc2_device.common.tag = HARDWARE_DEVICE_TAG;
+ ctx->hwc2_device.common.version = HWC_DEVICE_API_VERSION_2_0;
+ ctx->hwc2_device.common.module = const_cast<hw_module_t *>(module);
+ ctx->hwc2_device.common.close = hwc2_device_close;
+ ctx->hwc2_device.getFunction = get_function;
+ ctx->hwc2_device.getCapabilities = get_capabilities;
+
+ *hw_device = &ctx->hwc2_device.common;
+
+ return 0;
+}
diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h
new file mode 100644
index 0000000..ea040be
--- /dev/null
+++ b/hwc2/hwc2.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016 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 _HWC2_H
+#define _HWC2_H
+
+#include <hardware/hwcomposer2.h>
+
+struct hwc2_context {
+ hwc2_device_t hwc2_device; /* must be first member in struct */
+};
+
+#endif /* ifndef _HWC2_H */