diff options
author | Marissa Wall <marissaw@google.com> | 2017-03-02 22:09:22 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-02 22:09:22 +0000 |
commit | 01248d3348255d8bfebf6513af9f890ef73d1396 (patch) | |
tree | 904092baaa9ef2d764aa380a1d98b8ae804fe58c | |
parent | 04f064b1b00b444aa430471f1145c2b9ba372ea1 (diff) | |
parent | 48bb1029d52b66640023d03f71b3f438a9882c8d (diff) | |
download | flounder-01248d3348255d8bfebf6513af9f890ef73d1396.tar.gz |
hwc2: get display name
am: 48bb1029d5
Change-Id: Iec68040527b5a8e5f0a4e4c05502b4e6b8fadff5
-rw-r--r-- | hwc2/hwc2.cpp | 7 | ||||
-rw-r--r-- | hwc2/hwc2.h | 16 | ||||
-rw-r--r-- | hwc2/hwc2_dev.cpp | 12 | ||||
-rw-r--r-- | hwc2/hwc2_display.cpp | 30 |
4 files changed, 58 insertions, 7 deletions
diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp index 285603b..3ddd1f5 100644 --- a/hwc2/hwc2.cpp +++ b/hwc2/hwc2.cpp @@ -137,10 +137,11 @@ hwc2_error_t get_display_configs(hwc2_device_t *device, hwc2_display_t display, return dev->get_display_configs(display, out_num_configs, out_configs); } -hwc2_error_t get_display_name(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, uint32_t* /*out_size*/, char* /*out_name*/) +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_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->get_display_name(display, out_size, out_name); } hwc2_error_t get_display_requests(hwc2_device_t* /*device*/, diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h index 4acda2a..56cdc69 100644 --- a/hwc2/hwc2.h +++ b/hwc2/hwc2.h @@ -22,6 +22,7 @@ #include <unordered_map> #include <queue> #include <mutex> +#include <string> #include <adf/adf.h> #include <adfhwc/adfhwc.h> @@ -99,10 +100,13 @@ public: hwc2_display_type_t type, hwc2_power_mode_t power_mode); ~hwc2_display(); - hwc2_display_t get_id() const { return id; } + /* Display functions */ + hwc2_display_t get_id() const { return id; } hwc2_display_type_t get_type() const { return type; } - hwc2_connection_t get_connection() const { return connection; } - hwc2_vsync_t get_vsync_enabled() const { return vsync_enabled; } + hwc2_connection_t get_connection() const { return connection; } + hwc2_vsync_t get_vsync_enabled() const { return vsync_enabled; } + hwc2_error_t get_name(uint32_t *out_size, char *out_name) const; + void init_name(); hwc2_error_t set_connection(hwc2_connection_t connection); hwc2_error_t set_vsync_enabled(hwc2_vsync_t enabled); @@ -133,6 +137,9 @@ private: /* Identifies the display to the client */ hwc2_display_t id; + /* A human readable version of the display's name */ + std::string name; + /* The display is connected to an output */ hwc2_connection_t connection; @@ -170,6 +177,9 @@ public: hwc2_dev(); ~hwc2_dev(); + /* Display functions */ + hwc2_error_t get_display_name(hwc2_display_t dpy_id, uint32_t *out_size, + char *out_name) const; hwc2_error_t get_display_type(hwc2_display_t dpy_id, hwc2_display_type_t *out_type) const; diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp index 09ae5a4..dd168f3 100644 --- a/hwc2/hwc2_dev.cpp +++ b/hwc2/hwc2_dev.cpp @@ -60,6 +60,18 @@ hwc2_dev::~hwc2_dev() hwc2_display::reset_ids(); } +hwc2_error_t hwc2_dev::get_display_name(hwc2_display_t dpy_id, uint32_t *out_size, + char *out_name) 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_name(out_size, out_name); +} + hwc2_error_t hwc2_dev::get_display_type(hwc2_display_t dpy_id, hwc2_display_type_t *out_type) const { diff --git a/hwc2/hwc2_display.cpp b/hwc2/hwc2_display.cpp index 35dacbd..08e21ea 100644 --- a/hwc2/hwc2_display.cpp +++ b/hwc2/hwc2_display.cpp @@ -28,6 +28,7 @@ hwc2_display::hwc2_display(hwc2_display_t id, int adf_intf_fd, const struct adf_device &adf_dev, hwc2_connection_t connection, hwc2_display_type_t type, hwc2_power_mode_t power_mode) : id(id), + name(), connection(connection), type(type), layers(), @@ -36,7 +37,10 @@ hwc2_display::hwc2_display(hwc2_display_t id, int adf_intf_fd, active_config(0), power_mode(power_mode), adf_intf_fd(adf_intf_fd), - adf_dev(adf_dev) { } + adf_dev(adf_dev) +{ + init_name(); +} hwc2_display::~hwc2_display() { @@ -55,6 +59,30 @@ hwc2_error_t hwc2_display::set_connection(hwc2_connection_t connection) return HWC2_ERROR_NONE; } +hwc2_error_t hwc2_display::get_name(uint32_t *out_size, char *out_name) const +{ + if (!out_name) { + *out_size = name.size(); + return HWC2_ERROR_NONE; + } + + /* out_name does not require a NULL terminator so strncpy can truncate + * the output safely */ + strncpy(out_name, name.c_str(), *out_size); + *out_size = (*out_size < name.size())? *out_size: name.size(); + return HWC2_ERROR_NONE; +} + +void hwc2_display::init_name() +{ + name.append("dpy-"); + if (HWC2_DISPLAY_TYPE_PHYSICAL) + name.append("phys-"); + else + name.append("virt-"); + name.append(std::to_string(id)); +} + hwc2_error_t hwc2_display::set_power_mode(hwc2_power_mode_t mode) { int drm_mode; |