diff options
-rw-r--r-- | kms++/inc/kms++/connector.h | 2 | ||||
-rw-r--r-- | kms++/inc/kms++/crtc.h | 2 | ||||
-rw-r--r-- | kms++/inc/kms++/encoder.h | 2 | ||||
-rw-r--r-- | kms++/src/connector.cpp | 16 | ||||
-rw-r--r-- | kms++/src/crtc.cpp | 8 | ||||
-rw-r--r-- | kms++/src/encoder.cpp | 8 | ||||
-rw-r--r-- | py/pykms/pykmsbase.cpp | 3 |
7 files changed, 40 insertions, 1 deletions
diff --git a/kms++/inc/kms++/connector.h b/kms++/inc/kms++/connector.h index ccd7728..3407730 100644 --- a/kms++/inc/kms++/connector.h +++ b/kms++/inc/kms++/connector.h @@ -14,6 +14,8 @@ class Connector : public DrmPropObject { friend class Card; public: + void refresh(); + Videomode get_default_mode() const; Videomode get_mode(const std::string& mode) const; diff --git a/kms++/inc/kms++/crtc.h b/kms++/inc/kms++/crtc.h index 14860ba..c86fc88 100644 --- a/kms++/inc/kms++/crtc.h +++ b/kms++/inc/kms++/crtc.h @@ -14,6 +14,8 @@ class Crtc : public DrmPropObject friend class Card; friend class Connector; public: + void refresh(); + const std::vector<Plane*>& get_possible_planes() const { return m_possible_planes; } int set_mode(Connector* conn, Framebuffer& fb, const Videomode& mode); diff --git a/kms++/inc/kms++/encoder.h b/kms++/inc/kms++/encoder.h index b5aac70..1d36adc 100644 --- a/kms++/inc/kms++/encoder.h +++ b/kms++/inc/kms++/encoder.h @@ -12,6 +12,8 @@ class Encoder : public DrmPropObject { friend class Card; public: + void refresh(); + Crtc* get_crtc() const; std::vector<Crtc*> get_possible_crtcs() const; diff --git a/kms++/src/connector.cpp b/kms++/src/connector.cpp index 7c6c179..48c5815 100644 --- a/kms++/src/connector.cpp +++ b/kms++/src/connector.cpp @@ -73,13 +73,27 @@ Connector::Connector(Card &card, uint32_t id, uint32_t idx) m_fullname = name + "-" + to_string(m_priv->drm_connector->connector_type_id); } - Connector::~Connector() { drmModeFreeConnector(m_priv->drm_connector); delete m_priv; } +void Connector::refresh() +{ + drmModeFreeConnector(m_priv->drm_connector); + + m_priv->drm_connector = drmModeGetConnector(this->card().fd(), this->id()); + assert(m_priv->drm_connector); + + // XXX drmModeGetConnector() does forced probe, which seems to change (at least) EDID blob id. + // XXX So refresh the props again here. + refresh_props(); + + const auto& name = connector_names.at(m_priv->drm_connector->connector_type); + m_fullname = name + "-" + to_string(m_priv->drm_connector->connector_type_id); +} + void Connector::setup() { if (m_priv->drm_connector->encoder_id != 0) diff --git a/kms++/src/crtc.cpp b/kms++/src/crtc.cpp index 4c2f5ce..2d41bfa 100644 --- a/kms++/src/crtc.cpp +++ b/kms++/src/crtc.cpp @@ -31,6 +31,14 @@ Crtc::~Crtc() delete m_priv; } +void Crtc::refresh() +{ + drmModeFreeCrtc(m_priv->drm_crtc); + + m_priv->drm_crtc = drmModeGetCrtc(this->card().fd(), this->id()); + assert(m_priv->drm_crtc); +} + void Crtc::setup() { for (Plane* plane : card().get_planes()) { diff --git a/kms++/src/encoder.cpp b/kms++/src/encoder.cpp index 2168f2f..9cd5304 100644 --- a/kms++/src/encoder.cpp +++ b/kms++/src/encoder.cpp @@ -45,6 +45,14 @@ Encoder::~Encoder() delete m_priv; } +void Encoder::refresh() +{ + drmModeFreeEncoder(m_priv->drm_encoder); + + m_priv->drm_encoder = drmModeGetEncoder(this->card().fd(), this->id()); + assert(m_priv->drm_encoder); +} + Crtc* Encoder::get_crtc() const { if (m_priv->drm_encoder->crtc_id) diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 13c4dd1..2f56825 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -44,6 +44,7 @@ void init_pykmsbase(py::module &m) .def("get_mode", (Videomode (Connector::*)(const string& mode) const)&Connector::get_mode) .def("get_mode", (Videomode (Connector::*)(unsigned xres, unsigned yres, float refresh, bool ilace) const)&Connector::get_mode) .def("__repr__", [](const Connector& o) { return "<pykms.Connector " + to_string(o.id()) + ">"; }) + .def("refresh", &Connector::refresh) ; py::class_<Crtc, Crtc*>(m, "Crtc", py::base<DrmPropObject>()) @@ -55,9 +56,11 @@ void init_pykmsbase(py::module &m) .def_property_readonly("mode", &Crtc::mode) .def_property_readonly("mode_valid", &Crtc::mode_valid) .def("__repr__", [](const Crtc& o) { return "<pykms.Crtc " + to_string(o.id()) + ">"; }) + .def("refresh", &Crtc::refresh) ; py::class_<Encoder, Encoder*>(m, "Encoder", py::base<DrmPropObject>()) + .def("refresh", &Encoder::refresh) ; py::class_<Plane, Plane*>(m, "Plane", py::base<DrmPropObject>()) |