diff options
author | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-02 23:23:54 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-03 17:49:45 +0300 |
commit | e789f93b241fe74cf92eed9ffb0d18b853d79fa1 (patch) | |
tree | 52f233db8f414920527d6e251e534a80316459a1 /libkms++ | |
parent | 9b382fd474a6cc949e93bf6f34ce258ef7dd76a2 (diff) |
save & restore mode
Diffstat (limited to 'libkms++')
-rw-r--r-- | libkms++/card.cpp | 8 | ||||
-rw-r--r-- | libkms++/card.h | 2 | ||||
-rw-r--r-- | libkms++/connector.cpp | 8 | ||||
-rw-r--r-- | libkms++/connector.h | 3 | ||||
-rw-r--r-- | libkms++/crtc.cpp | 11 | ||||
-rw-r--r-- | libkms++/crtc.h | 2 |
6 files changed, 34 insertions, 0 deletions
diff --git a/libkms++/card.cpp b/libkms++/card.cpp index 5f8dbd1..39a1fb6 100644 --- a/libkms++/card.cpp +++ b/libkms++/card.cpp @@ -107,12 +107,20 @@ Card::Card() Card::~Card() { + restore_modes(); + for (auto pair : m_obmap) delete pair.second; close(m_fd); } +void Card::restore_modes() +{ + for (auto conn : get_connectors()) + conn->restore_mode(); +} + template <class T> static void print_obs(const map<uint32_t, DrmObject*>& obmap) { for (auto pair : obmap) { diff --git a/libkms++/card.h b/libkms++/card.h index a8db76f..ac0cba4 100644 --- a/libkms++/card.h +++ b/libkms++/card.h @@ -42,6 +42,8 @@ public: std::vector<Pipeline> get_connected_pipelines(); private: + void restore_modes(); + std::map<uint32_t, DrmObject*> m_obmap; int m_fd; diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index 8ff5a5f..06703d6 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -72,6 +72,14 @@ void Connector::setup() if (enc) m_current_crtc = enc->get_crtc(); } + + m_saved_crtc = m_current_crtc; +} + +void Connector::restore_mode() +{ + if (m_saved_crtc) + m_saved_crtc->restore_mode(this); } void Connector::print_short() const diff --git a/libkms++/connector.h b/libkms++/connector.h index 84845d5..56ac315 100644 --- a/libkms++/connector.h +++ b/libkms++/connector.h @@ -42,11 +42,14 @@ private: ~Connector(); void setup(); + void restore_mode(); ConnectorPriv* m_priv; std::string m_fullname; Crtc* m_current_crtc; + + Crtc* m_saved_crtc; }; } diff --git a/libkms++/crtc.cpp b/libkms++/crtc.cpp index b0a962e..9716c97 100644 --- a/libkms++/crtc.cpp +++ b/libkms++/crtc.cpp @@ -39,6 +39,17 @@ void Crtc::setup() } } +void Crtc::restore_mode(Connector* conn) +{ + auto c = m_priv->drm_crtc; + + uint32_t conns[] = { conn->id() }; + + drmModeSetCrtc(card().fd(), id(), c->buffer_id, + c->x, c->y, + conns, 1, &c->mode); +} + void Crtc::print_short() const { auto c = m_priv->drm_crtc; diff --git a/libkms++/crtc.h b/libkms++/crtc.h index d30d497..1cbf4c4 100644 --- a/libkms++/crtc.h +++ b/libkms++/crtc.h @@ -12,6 +12,7 @@ struct CrtcPriv; class Crtc : public DrmObject { friend class Card; + friend class Connector; public: void print_short() const; @@ -30,6 +31,7 @@ private: ~Crtc(); void setup(); + void restore_mode(Connector *conn); CrtcPriv* m_priv; |