diff options
author | Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> | 2019-11-04 17:43:40 +0200 |
---|---|---|
committer | Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> | 2019-11-21 23:18:07 +0000 |
commit | df88299409b08cceb88885f02f64ddc9e492c210 (patch) | |
tree | 9b96e12058a52aee37641103f22fae2eaf51e67e | |
parent | afb36897c9ecc76921f4d69c9de30e924b286893 (diff) |
drm_hwcomposer: Add DrmConnector::name function
Connectors usually are referred by names, but libdrm stores type and
id only as a numbers so for more convenience conversion function from
integerst to string should be added.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
-rw-r--r-- | drm/drmconnector.cpp | 16 | ||||
-rw-r--r-- | include/drmconnector.h | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/drm/drmconnector.cpp b/drm/drmconnector.cpp index 543827d..bca7575 100644 --- a/drm/drmconnector.cpp +++ b/drm/drmconnector.cpp @@ -22,6 +22,9 @@ #include <errno.h> #include <stdint.h> +#include <array> +#include <sstream> + #include <log/log.h> #include <xf86drmMode.h> @@ -35,6 +38,7 @@ DrmConnector::DrmConnector(DrmDevice *drm, drmModeConnectorPtr c, encoder_(current_encoder), display_(-1), type_(c->connector_type), + type_id_(c->connector_type_id), state_(c->connection), mm_width_(c->mmWidth), mm_height_(c->mmHeight), @@ -112,6 +116,18 @@ bool DrmConnector::valid_type() const { return internal() || external() || writeback(); } +std::string DrmConnector::name() const { + constexpr std::array names = {"None", "VGA", "DVI-I", "DVI-D", + "DVI-A", "Composite", "SVIDEO", "LVDS", + "Component", "DIN", "DP", "HDMI-A", + "HDMI-B", "TV", "eDP", "Virtual", + "DSI"}; + + std::ostringstream name_buf; + name_buf << names[type_] << "-" << type_id_; + return name_buf.str(); +} + int DrmConnector::UpdateModes() { int fd = drm_->fd(); diff --git a/include/drmconnector.h b/include/drmconnector.h index 9c526c8..c9fd7ab 100644 --- a/include/drmconnector.h +++ b/include/drmconnector.h @@ -23,6 +23,7 @@ #include <stdint.h> #include <xf86drmMode.h> +#include <string> #include <vector> namespace android { @@ -49,6 +50,8 @@ class DrmConnector { bool writeback() const; bool valid_type() const; + std::string name() const; + int UpdateModes(); const std::vector<DrmMode> &modes() const { @@ -86,6 +89,7 @@ class DrmConnector { int display_; uint32_t type_; + uint32_t type_id_; drmModeConnection state_; uint32_t mm_width_; |