diff options
author | Marissa Wall <marissaw@google.com> | 2017-03-02 22:08:57 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-02 22:08:57 +0000 |
commit | 7534f7f3398d643ed8a755a231878aad9667185c (patch) | |
tree | 30049a6e6a28c4fbb364351cd86ca3da276b2025 | |
parent | 511114390a7d2f7d817ce4c734d817d0aa505070 (diff) | |
parent | 7384507cad45dc3c1deb4b4f9d41a69362f664dc (diff) | |
download | flounder-7534f7f3398d643ed8a755a231878aad9667185c.tar.gz |
hwc2: register callback functions
am: 7384507cad
Change-Id: I3d2c4a5a611d940399bd16a392f45a81d31ab246
-rw-r--r-- | hwc2/Android.mk | 3 | ||||
-rw-r--r-- | hwc2/hwc2.cpp | 10 | ||||
-rw-r--r-- | hwc2/hwc2.h | 27 | ||||
-rw-r--r-- | hwc2/hwc2_callback.cpp | 52 | ||||
-rw-r--r-- | hwc2/hwc2_dev.cpp | 15 |
5 files changed, 100 insertions, 7 deletions
diff --git a/hwc2/Android.mk b/hwc2/Android.mk index cee7a8d..1e4456f 100644 --- a/hwc2/Android.mk +++ b/hwc2/Android.mk @@ -42,7 +42,8 @@ LOCAL_SRC_FILES := \ hwc2.cpp \ hwc2_dev.cpp \ hwc2_display.cpp \ - hwc2_config.cpp + hwc2_config.cpp \ + hwc2_callback.cpp LOCAL_MODLE_TAGS := optional diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp index 8d9d24a..bd00e2e 100644 --- a/hwc2/hwc2.cpp +++ b/hwc2/hwc2.cpp @@ -66,12 +66,12 @@ 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*/) +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_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->register_callback(descriptor, callback_data, pointer); } hwc2_error_t accept_display_changes(hwc2_device_t* /*device*/, diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h index be4658c..6bb500c 100644 --- a/hwc2/hwc2.h +++ b/hwc2/hwc2.h @@ -43,6 +43,26 @@ private: int32_t dpi_y; }; +class hwc2_callback { +public: + hwc2_callback(); + + hwc2_error_t register_callback(hwc2_callback_descriptor_t descriptor, + hwc2_callback_data_t callback_data, + hwc2_function_pointer_t pointer); + +private: + /* All of the client callback functions and their data */ + hwc2_callback_data_t hotplug_data; + HWC2_PFN_HOTPLUG hotplug; + + hwc2_callback_data_t refresh_data; + HWC2_PFN_REFRESH refresh; + + hwc2_callback_data_t vsync_data; + HWC2_PFN_VSYNC vsync; +}; + class hwc2_display { public: hwc2_display(hwc2_display_t id, int adf_intf_fd, @@ -83,9 +103,16 @@ public: hwc2_dev(); ~hwc2_dev(); + hwc2_error_t register_callback(hwc2_callback_descriptor_t descriptor, + hwc2_callback_data_t callback_data, + hwc2_function_pointer_t pointer); + int open_adf_device(); private: + /* General callback functions for all displays */ + hwc2_callback callback_handler; + /* The physical and virtual displays associated with this device */ std::unordered_map<hwc2_display_t, hwc2_display> displays; diff --git a/hwc2/hwc2_callback.cpp b/hwc2/hwc2_callback.cpp new file mode 100644 index 0000000..1900b1e --- /dev/null +++ b/hwc2/hwc2_callback.cpp @@ -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. + */ + +#include <cutils/log.h> + +#include "hwc2.h" + +hwc2_callback::hwc2_callback() + : hotplug_data(nullptr), + hotplug(nullptr), + refresh_data(nullptr), + refresh(nullptr), + vsync_data(nullptr), + vsync(nullptr) { } + +hwc2_error_t hwc2_callback::register_callback( + hwc2_callback_descriptor_t descriptor, + hwc2_callback_data_t callback_data, hwc2_function_pointer_t pointer) +{ + switch (descriptor) { + case HWC2_CALLBACK_HOTPLUG: + hotplug = (HWC2_PFN_HOTPLUG) pointer; + hotplug_data = callback_data; + break; + case HWC2_CALLBACK_REFRESH: + refresh = (HWC2_PFN_REFRESH) pointer; + refresh_data = callback_data; + break; + case HWC2_CALLBACK_VSYNC: + vsync = (HWC2_PFN_VSYNC) pointer; + vsync_data = callback_data; + break; + default: + ALOGE("unknown callback descriptor %u", descriptor); + return HWC2_ERROR_BAD_PARAMETER; + } + + return HWC2_ERROR_NONE; +} diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp index 2f69763..6754087 100644 --- a/hwc2/hwc2_dev.cpp +++ b/hwc2/hwc2_dev.cpp @@ -45,7 +45,8 @@ const struct adf_hwc_event_callbacks hwc2_adfhwc_callbacks = { }; hwc2_dev::hwc2_dev() - : displays(), + : callback_handler(), + displays(), adf_helper(nullptr) { } hwc2_dev::~hwc2_dev() @@ -55,6 +56,18 @@ hwc2_dev::~hwc2_dev() hwc2_display::reset_ids(); } +hwc2_error_t hwc2_dev::register_callback(hwc2_callback_descriptor_t descriptor, + hwc2_callback_data_t callback_data, hwc2_function_pointer_t pointer) +{ + if (descriptor == HWC2_CALLBACK_INVALID) { + ALOGE("invalid callback descriptor %u", descriptor); + return HWC2_ERROR_BAD_PARAMETER; + } + + return callback_handler.register_callback(descriptor, callback_data, + pointer); +} + int hwc2_dev::open_adf_device() { adf_id_t *dev_ids = nullptr; |