Add refresh() to connector, crtc and encoder
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 25 Jan 2017 11:19:44 +0000 (13:19 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 25 Jan 2017 11:20:20 +0000 (13:20 +0200)
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
kms++/inc/kms++/connector.h
kms++/inc/kms++/crtc.h
kms++/inc/kms++/encoder.h
kms++/src/connector.cpp
kms++/src/crtc.cpp
kms++/src/encoder.cpp
py/pykms/pykmsbase.cpp

index ccd77281eebd1df686ac7caadbfc1963b46009b1..34077308af154d195af2fef2a98b8d9f40fd4d35 100644 (file)
@@ -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;
index 14860babdb59f2c410cc45cf6c369905357143c8..c86fc8877c00ebeb6eb76c8e6fd3d6c10f5560e1 100644 (file)
@@ -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);
index b5aac709fe02817c21d7cf5197d6d6dbd8de197e..1d36adc3e2619f296131237e1d198e213c639771 100644 (file)
@@ -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;
 
index 7c6c179ebff4616b22187aec14c3927688cfcce1..48c581564621640b951e5995e6dd3539da534621 100644 (file)
@@ -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)
index 4c2f5ce7a2623a8595238f6ccad1fe01f16570dd..2d41bfac0a67f37ec998abe49e1dd920beca9e9a 100644 (file)
@@ -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()) {
index 2168f2ff511076dfd7013b1420db36b1020c3f5f..9cd5304d1fa4fc3b3ea2b52663456b0f1aaa23be 100644 (file)
@@ -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)
index 13c4dd1a170c56eb87ac7b0e4db2ad2f7369e341..2f568254240d0aec95e0741a72db2b52a9c53070 100644 (file)
@@ -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>())