summaryrefslogtreecommitdiffstats
path: root/adf
diff options
context:
space:
mode:
authorMarissa Wall <marissaw@google.com>2016-06-02 12:19:17 -0700
committerMarissa Wall <marissaw@google.com>2017-03-02 17:40:02 +0000
commit9dcd750d8139b93272c9a49533b3bbde138ab6aa (patch)
tree9ab006b5bb6128cb64576c9c3af2547eaf7ed672 /adf
parent056eca201b093a8b3436f8020a49b1161d7c1f4c (diff)
downloadcore-9dcd750d8139b93272c9a49533b3bbde138ab6aa.tar.gz
core-9dcd750d8139b93272c9a49533b3bbde138ab6aa.tar.bz2
core-9dcd750d8139b93272c9a49533b3bbde138ab6aa.zip
libadfhwc: support hwc2 display attributes
adf_getDisplayAttributes_hwc2 gets the display attributes using the updated enums from HWC2 Test: run gtests located in frameworks/native/services/surfaceflinger/tests/hwc2 Change-Id: I31325c764ccaf65c6d970727b56327d24c7b16d8
Diffstat (limited to 'adf')
-rw-r--r--adf/libadfhwc/adfhwc.cpp51
-rw-r--r--adf/libadfhwc/include/adfhwc/adfhwc.h9
2 files changed, 60 insertions, 0 deletions
diff --git a/adf/libadfhwc/adfhwc.cpp b/adf/libadfhwc/adfhwc.cpp
index a97862a14..df2300ee4 100644
--- a/adf/libadfhwc/adfhwc.cpp
+++ b/adf/libadfhwc/adfhwc.cpp
@@ -166,6 +166,57 @@ int adf_getDisplayAttributes(struct adf_hwc_helper *dev, int disp,
return 0;
}
+static int32_t adf_display_attribute_hwc2(const adf_interface_data &data,
+ const drm_mode_modeinfo &mode, const uint32_t attribute)
+{
+ switch (attribute) {
+ case HWC2_ATTRIBUTE_VSYNC_PERIOD:
+ if (mode.vrefresh)
+ return 1000000000 / mode.vrefresh;
+ return 0;
+
+ case HWC2_ATTRIBUTE_WIDTH:
+ return mode.hdisplay;
+
+ case HWC2_ATTRIBUTE_HEIGHT:
+ return mode.vdisplay;
+
+ case HWC2_ATTRIBUTE_DPI_X:
+ return dpi(mode.hdisplay, data.width_mm);
+
+ case HWC2_ATTRIBUTE_DPI_Y:
+ return dpi(mode.vdisplay, data.height_mm);
+
+ default:
+ ALOGE("unknown display attribute %u", attribute);
+ return -EINVAL;
+ }
+}
+
+int adf_getDisplayAttributes_hwc2(struct adf_hwc_helper *dev, int disp,
+ uint32_t config, const uint32_t *attributes, int32_t *values)
+{
+ if ((size_t)disp >= dev->intf_fds.size())
+ return -EINVAL;
+
+ if (config >= dev->display_configs.size())
+ return -EINVAL;
+
+ adf_interface_data data;
+ int err = adf_get_interface_data(dev->intf_fds[disp], &data);
+ if (err < 0) {
+ ALOGE("failed to get ADF interface data: %s", strerror(err));
+ return err;
+ }
+
+ for (int i = 0; attributes[i] != HWC2_ATTRIBUTE_INVALID; i++)
+ values[i] = adf_display_attribute_hwc2(data,
+ dev->display_configs[config], attributes[i]);
+
+ adf_free_interface_data(&data);
+ return 0;
+}
+
static void handle_adf_event(struct adf_hwc_helper *dev, int disp)
{
adf_event *event;
diff --git a/adf/libadfhwc/include/adfhwc/adfhwc.h b/adf/libadfhwc/include/adfhwc/adfhwc.h
index 71e76246c..bd8e7d479 100644
--- a/adf/libadfhwc/include/adfhwc/adfhwc.h
+++ b/adf/libadfhwc/include/adfhwc/adfhwc.h
@@ -23,6 +23,7 @@
#include <video/adf.h>
#include <hardware/hwcomposer.h>
+#include <hardware/hwcomposer2.h>
struct adf_hwc_helper;
@@ -123,6 +124,14 @@ int adf_getDisplayConfigs(struct adf_hwc_helper *dev, int disp,
uint32_t *configs, size_t *numConfigs);
int adf_getDisplayAttributes(struct adf_hwc_helper *dev, int disp,
uint32_t config, const uint32_t *attributes, int32_t *values);
+/**
+ * Generic implementation of common HWC2 functions.
+ *
+ * The HWC2 should not return these functions directly through getFunction.
+ * Instead, the HWC2 should return stub functions which call these helpers.
+ */
+int adf_getDisplayAttributes_hwc2(struct adf_hwc_helper *dev, int disp,
+ uint32_t config, const uint32_t *attributes, int32_t *values);
__END_DECLS