diff options
author | Marissa Wall <marissaw@google.com> | 2017-03-02 22:09:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-02 22:09:13 +0000 |
commit | 59fce5233778739310ebf83da4225d7f21a72c09 (patch) | |
tree | d668849b1a0a11dc6c6e5428b347e3ab33e3918f | |
parent | 4f2d810073f6c724ceafc7de2fb7ed58f7fe7a7b (diff) | |
parent | 481d68a52ac82bd164686c828daec54752612736 (diff) | |
download | flounder-59fce5233778739310ebf83da4225d7f21a72c09.tar.gz |
hwc2: get and set active config
am: 481d68a52a
Change-Id: I74565a3f73c35508854758a1a12982677daa6a58
-rw-r--r-- | hwc2/hwc2.cpp | 14 | ||||
-rw-r--r-- | hwc2/hwc2.h | 6 | ||||
-rw-r--r-- | hwc2/hwc2_dev.cpp | 24 | ||||
-rw-r--r-- | hwc2/hwc2_display.cpp | 31 |
4 files changed, 69 insertions, 6 deletions
diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp index 4e0f76e..1693132 100644 --- a/hwc2/hwc2.cpp +++ b/hwc2/hwc2.cpp @@ -94,10 +94,11 @@ hwc2_error_t destroy_layer(hwc2_device_t *device, hwc2_display_t display, return dev->destroy_layer(display, layer); } -hwc2_error_t get_active_config(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, hwc2_config_t* /*out_config*/) +hwc2_error_t get_active_config(hwc2_device_t *device, hwc2_display_t display, + hwc2_config_t *out_config) { - return HWC2_ERROR_NONE; + hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->get_active_config(display, out_config); } hwc2_error_t get_changed_composition_types(hwc2_device_t* /*device*/, @@ -185,10 +186,11 @@ hwc2_error_t present_display(hwc2_device_t* /*device*/, return HWC2_ERROR_NONE; } -hwc2_error_t set_active_config(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, hwc2_config_t /*config*/) +hwc2_error_t set_active_config(hwc2_device_t *device, hwc2_display_t display, + hwc2_config_t config) { - return HWC2_ERROR_NONE; + hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->set_active_config(display, config); } hwc2_error_t set_client_target(hwc2_device_t* /*device*/, diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h index 4848433..70c6f61 100644 --- a/hwc2/hwc2.h +++ b/hwc2/hwc2.h @@ -110,6 +110,9 @@ public: hwc2_attribute_t attribute, int32_t *out_value) const; hwc2_error_t get_display_configs(uint32_t *out_num_configs, hwc2_config_t *out_configs) const; + hwc2_error_t get_active_config(hwc2_config_t *out_config) const; + hwc2_error_t set_active_config(struct adf_hwc_helper *adf_helper, + hwc2_config_t config); /* Set layer functions */ hwc2_error_t create_layer(hwc2_layer_t *out_layer); @@ -163,6 +166,9 @@ public: int32_t *out_value) const; hwc2_error_t get_display_configs(hwc2_display_t dpy_id, uint32_t *out_num_configs, hwc2_config_t *out_configs) const; + hwc2_error_t get_active_config(hwc2_display_t dpy_id, + hwc2_config_t *out_config) const; + hwc2_error_t set_active_config(hwc2_display_t dpy_id, hwc2_config_t config); /* Layer functions */ hwc2_error_t create_layer(hwc2_display_t dpy_id, hwc2_layer_t *out_layer); diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp index bfb8363..156fc13 100644 --- a/hwc2/hwc2_dev.cpp +++ b/hwc2/hwc2_dev.cpp @@ -97,6 +97,30 @@ hwc2_error_t hwc2_dev::get_display_configs(hwc2_display_t dpy_id, return it->second.get_display_configs(out_num_configs, out_configs); } +hwc2_error_t hwc2_dev::get_active_config(hwc2_display_t dpy_id, + hwc2_config_t *out_config) const +{ + auto it = displays.find(dpy_id); + if (it == displays.end()) { + ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id); + return HWC2_ERROR_BAD_DISPLAY; + } + + return it->second.get_active_config(out_config); +} + +hwc2_error_t hwc2_dev::set_active_config(hwc2_display_t dpy_id, + hwc2_config_t config) +{ + auto it = displays.find(dpy_id); + if (it == displays.end()) { + ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id); + return HWC2_ERROR_BAD_DISPLAY; + } + + return it->second.set_active_config(adf_helper, config); +} + hwc2_error_t hwc2_dev::create_layer(hwc2_display_t dpy_id, hwc2_layer_t *out_layer) { auto it = displays.find(dpy_id); diff --git a/hwc2/hwc2_display.cpp b/hwc2/hwc2_display.cpp index 4ebcb44..137e08a 100644 --- a/hwc2/hwc2_display.cpp +++ b/hwc2/hwc2_display.cpp @@ -138,6 +138,37 @@ hwc2_error_t hwc2_display::get_display_configs(uint32_t *out_num_configs, return HWC2_ERROR_NONE; } +hwc2_error_t hwc2_display::get_active_config(hwc2_config_t *out_config) const +{ + if (!configs.size()) { + ALOGE("dpy %" PRIu64 ": no active config", id); + return HWC2_ERROR_BAD_CONFIG; + } + + *out_config = active_config; + + return HWC2_ERROR_NONE; +} + +hwc2_error_t hwc2_display::set_active_config( + struct adf_hwc_helper *adf_helper, hwc2_config_t config) +{ + if (config >= configs.size()) { + ALOGE("dpy %" PRIu64 ": bad config", id); + return HWC2_ERROR_BAD_CONFIG; + } + + int ret = adf_set_active_config_hwc2(adf_helper, id, config); + if (ret < 0) { + ALOGE("dpy %" PRIu64 ": failed to set mode: %s", id, strerror(ret)); + return HWC2_ERROR_BAD_CONFIG; + } + + active_config = config; + + return HWC2_ERROR_NONE; +} + hwc2_error_t hwc2_display::create_layer(hwc2_layer_t *out_layer) { hwc2_layer_t lyr_id = hwc2_layer::get_next_id(); |