diff options
author | Jyri Sarha <jsarha@ti.com> | 2015-10-20 16:46:01 +0300 |
---|---|---|
committer | Jyri Sarha <jsarha@ti.com> | 2015-10-20 19:18:32 +0300 |
commit | 63d9b04d14677d09b6279566f0e43d00c252770e (patch) | |
tree | 13a23ca9e8dedb6eb9ef633b1bf79dbc56318206 | |
parent | 17a0cd1a122b0a17a362bb44da559a936731d70c (diff) |
libkms++/connector: Add methods for getting details of the DRM object
-rw-r--r-- | libkms++/connector.cpp | 63 | ||||
-rw-r--r-- | libkms++/connector.h | 9 |
2 files changed, 72 insertions, 0 deletions
diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index 0d6d4d7..eca3edd 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -42,6 +42,17 @@ static const map<int, string> connection_str = { { DRM_MODE_UNKNOWNCONNECTION, "Unknown" }, }; +static const map<int, string> subpix_str = { +#define DEF_SUBPIX(c) { DRM_MODE_SUBPIXEL_##c, #c } + DEF_SUBPIX(UNKNOWN), + DEF_SUBPIX(HORIZONTAL_RGB), + DEF_SUBPIX(HORIZONTAL_BGR), + DEF_SUBPIX(VERTICAL_RGB), + DEF_SUBPIX(VERTICAL_BGR), + DEF_SUBPIX(NONE), +#undef DEF_SUBPIX +}; + struct ConnectorPriv { drmModeConnectorPtr drm_connector; @@ -139,4 +150,56 @@ Crtc* Connector::get_current_crtc() const return 0; } +uint32_t Connector::connector_type() const +{ + return m_priv->drm_connector->connector_type; +} + +uint32_t Connector::connector_type_id() const +{ + return m_priv->drm_connector->connector_type_id; +} + +uint32_t Connector::mmWidth() const +{ + return m_priv->drm_connector->mmWidth; +} + +uint32_t Connector::mmHeight() const +{ + return m_priv->drm_connector->mmHeight; +} + +uint32_t Connector::subpixel() const +{ + return m_priv->drm_connector->subpixel; +} + +const string& Connector::subpixel_str() const +{ + return subpix_str.at(subpixel()); +} + +std::vector<Videomode> Connector::get_modes() const +{ + vector<Videomode> modes; + + for (int i = 0; i < m_priv->drm_connector->count_modes; i++) + modes.push_back(drm_mode_to_video_mode( + m_priv->drm_connector->modes[i])); + + return modes; +} + +std::vector<Encoder*> Connector::get_encoders() const +{ + vector<Encoder*> encoders; + + for (int i = 0; i < m_priv->drm_connector->count_encoders; i++) { + auto enc = card().get_encoder(m_priv->drm_connector->encoders[i]); + encoders.push_back(enc); + } + return encoders; +} + } diff --git a/libkms++/connector.h b/libkms++/connector.h index 8ce6cda..f586f4e 100644 --- a/libkms++/connector.h +++ b/libkms++/connector.h @@ -37,6 +37,15 @@ public: bool connected() const; + const std::string& fullname() const { return m_fullname; } + uint32_t connector_type() const; + uint32_t connector_type_id() const; + uint32_t mmWidth() const; + uint32_t mmHeight() const; + uint32_t subpixel() const; + const std::string& subpixel_str() const; + std::vector<Videomode> get_modes() const; + std::vector<Encoder*> get_encoders() const; private: Connector(Card& card, uint32_t id, uint32_t idx); ~Connector(); |