summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarissa Wall <marissaw@google.com>2016-09-01 14:50:04 -0700
committerMarissa Wall <marissaw@google.com>2017-03-02 12:35:06 -0800
commit21321ec1c513c337001f129cecf14e6434b67b26 (patch)
tree36b7b8fefef8770e63c30a36119282c1ebd5e20d
parent718ac72f524eec735b995d614bcb355b893397ce (diff)
downloadflounder-21321ec1c513c337001f129cecf14e6434b67b26.tar.gz
hwc2: get display configs and attributes
Allow the client to query display configs and attributes Test: Add "TARGET_USES_HWC2 := true" to BoardConfig.mk. Recompile. Run testcases: https://android-review.googlesource.com/#/q/project: platform/frameworks/native+branch:master+topic:test-hwc2 Change-Id: I302c7ca4bdcc34bbed464083c7a9622eb836b401
-rw-r--r--hwc2/hwc2.cpp17
-rw-r--r--hwc2/hwc2.h15
-rw-r--r--hwc2/hwc2_config.cpp19
-rw-r--r--hwc2/hwc2_dev.cpp25
-rw-r--r--hwc2/hwc2_display.cpp32
5 files changed, 98 insertions, 10 deletions
diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp
index fde75d7..4e0f76e 100644
--- a/hwc2/hwc2.cpp
+++ b/hwc2/hwc2.cpp
@@ -121,18 +121,19 @@ hwc2_error_t get_color_modes(hwc2_device_t* /*device*/,
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*/)
+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_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev;
+ return dev->get_display_attribute(display, config, attribute, out_value);
}
-hwc2_error_t get_display_configs(hwc2_device_t* /*device*/,
- hwc2_display_t /*display*/, uint32_t* /*out_num_configs*/,
- hwc2_config_t* /*out_configs*/)
+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_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev;
+ return dev->get_display_configs(display, out_num_configs, out_configs);
}
hwc2_error_t get_display_name(hwc2_device_t* /*device*/,
diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h
index 9c105e1..4848433 100644
--- a/hwc2/hwc2.h
+++ b/hwc2/hwc2.h
@@ -31,6 +31,7 @@ public:
hwc2_config();
int set_attribute(hwc2_attribute_t attribute, int32_t value);
+ int32_t get_attribute(hwc2_attribute_t attribute) const;
private:
/* Dimensions in pixels */
@@ -103,7 +104,12 @@ public:
hwc2_error_t set_connection(hwc2_connection_t connection);
- int retrieve_display_configs(struct adf_hwc_helper *adf_helper);
+ /* Config functions */
+ int retrieve_display_configs(struct adf_hwc_helper *adf_helper);
+ hwc2_error_t get_display_attribute(hwc2_config_t config,
+ 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;
/* Set layer functions */
hwc2_error_t create_layer(hwc2_layer_t *out_layer);
@@ -151,6 +157,13 @@ public:
hwc2_error_t get_display_type(hwc2_display_t dpy_id,
hwc2_display_type_t *out_type) const;
+ /* Config functions */
+ hwc2_error_t get_display_attribute(hwc2_display_t dpy_id,
+ hwc2_config_t config, hwc2_attribute_t attribute,
+ 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;
+
/* Layer functions */
hwc2_error_t create_layer(hwc2_display_t dpy_id, hwc2_layer_t *out_layer);
hwc2_error_t destroy_layer(hwc2_display_t dpy_id, hwc2_layer_t lyr_id);
diff --git a/hwc2/hwc2_config.cpp b/hwc2/hwc2_config.cpp
index 4741d6a..3801a62 100644
--- a/hwc2/hwc2_config.cpp
+++ b/hwc2/hwc2_config.cpp
@@ -50,3 +50,22 @@ int hwc2_config::set_attribute(hwc2_attribute_t attribute, int32_t value)
return 0;
}
+
+int32_t hwc2_config::get_attribute(hwc2_attribute_t attribute) const
+{
+ switch (attribute) {
+ case HWC2_ATTRIBUTE_WIDTH:
+ return width;
+ case HWC2_ATTRIBUTE_HEIGHT:
+ return height;
+ case HWC2_ATTRIBUTE_VSYNC_PERIOD:
+ return vsync_period;
+ case HWC2_ATTRIBUTE_DPI_X:
+ return dpi_x;
+ case HWC2_ATTRIBUTE_DPI_Y:
+ return dpi_y;
+ default:
+ ALOGW("unknown attribute %u", attribute);
+ return -1;
+ }
+}
diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp
index 15280e3..bfb8363 100644
--- a/hwc2/hwc2_dev.cpp
+++ b/hwc2/hwc2_dev.cpp
@@ -72,6 +72,31 @@ hwc2_error_t hwc2_dev::get_display_type(hwc2_display_t dpy_id,
return HWC2_ERROR_NONE;
}
+hwc2_error_t hwc2_dev::get_display_attribute(hwc2_display_t dpy_id,
+ hwc2_config_t config, hwc2_attribute_t attribute, int32_t *out_value)
+ 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_display_attribute(config, attribute, out_value);
+}
+
+hwc2_error_t hwc2_dev::get_display_configs(hwc2_display_t dpy_id,
+ uint32_t *out_num_configs, hwc2_config_t *out_configs) 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_display_configs(out_num_configs, out_configs);
+}
+
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 a178abf..4ebcb44 100644
--- a/hwc2/hwc2_display.cpp
+++ b/hwc2/hwc2_display.cpp
@@ -86,7 +86,7 @@ int hwc2_display::retrieve_display_configs(struct adf_hwc_helper *adf_helper)
std::array<int32_t, 5> values;
for (auto config_handle: config_handles) {
- ret = adf_getDisplayAttributes_v2(adf_helper, id, config_handle,
+ ret = adf_getDisplayAttributes_hwc2(adf_helper, id, config_handle,
attributes.data(), values.data());
if (ret < 0) {
ALOGW("dpy %" PRIu64 ": failed to get display attributes for config"
@@ -108,6 +108,36 @@ int hwc2_display::retrieve_display_configs(struct adf_hwc_helper *adf_helper)
return ret;
}
+hwc2_error_t hwc2_display::get_display_attribute(hwc2_config_t config,
+ hwc2_attribute_t attribute, int32_t *out_value) const
+{
+ auto it = configs.find(config);
+ if (it == configs.end()) {
+ ALOGE("dpy %" PRIu64 ": bad config", id);
+ return HWC2_ERROR_BAD_CONFIG;
+ }
+
+ *out_value = it->second.get_attribute(attribute);
+ return HWC2_ERROR_NONE;
+}
+
+hwc2_error_t hwc2_display::get_display_configs(uint32_t *out_num_configs,
+ hwc2_config_t *out_configs) const
+{
+ if (!out_configs) {
+ *out_num_configs = configs.size();
+ return HWC2_ERROR_NONE;
+ }
+
+ size_t idx = 0;
+ for (auto it = configs.begin(); it != configs.end()
+ && idx < *out_num_configs; it++, idx++)
+ out_configs[idx] = it->first;
+
+ *out_num_configs = idx;
+ 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();