py: fix scripts when there's no current crtc
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 6 Jun 2016 16:56:26 +0000 (19:56 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 7 Jun 2016 14:04:28 +0000 (17:04 +0300)
py/alpha-test.py
py/db.py
py/functest.py
py/gamma.py
py/helpers.py
py/iact.py
py/pykmsbase.cpp
py/test.py
py/trans-test.py

index 6957bb4277cd5be4bdf16cb59033820b3ab40955..113fab0ad73cdd597e55cc986280cd8a273b97d4 100755 (executable)
@@ -12,7 +12,7 @@ card = pykms.Card()
 
 conn = card.get_first_connected_connector()
 mode = conn.get_default_mode()
-crtc = conn.get_current_crtc()
+crtc = get_crtc_for_connector(conn)
 
 planes = []
 for p in card.planes:
index 315f99376fc065f67d6c2e12af33399a513bd9d1..60737650a95b9096f57fa3cf0e4711673dbf50ac 100755 (executable)
--- a/py/db.py
+++ b/py/db.py
@@ -3,6 +3,7 @@
 import sys
 import pykms
 import selectors
+from helpers import *
 
 bar_width = 20
 bar_speed = 8
@@ -42,7 +43,7 @@ class FlipHandler(pykms.PageFlipHandlerBase):
 card = pykms.Card()
 conn = card.get_first_connected_connector()
 mode = conn.get_default_mode()
-crtc = conn.get_current_crtc()
+crtc = get_crtc_for_connector(conn)
 
 fliphandler = FlipHandler()
 
index 624f3202c2753fbefb08661f8eaea60f986e3584..c2548fa044f45defbed698a81c586a20e93fe33d 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/python3
 
 import pykms
+from helpers import *
 
 card = pykms.Card()
 
@@ -11,7 +12,7 @@ mode = conn.get_default_mode()
 fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24");
 pykms.draw_test_pattern(fb);
 
-crtc = conn.get_current_crtc()
+crtc = get_crtc_for_connector(conn)
 
 crtc.set_mode(conn, fb, mode)
 
index 6dfd93541777020ab3e943c29a7d39ceb8f12d3f..e1daa43929beef7c745c5a01491a0a1768adfa59 100755 (executable)
@@ -11,8 +11,7 @@ card = pykms.Card()
 
 conn = card.get_first_connected_connector()
 mode = conn.get_default_mode()
-crtc = conn.get_current_crtc()
-mode = conn.get_default_mode()
+crtc = get_crtc_for_connector(conn)
 
 fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24");
 pykms.draw_test_pattern(fb);
index fd67d4160cb9214d77c9a8e43db0a392b0f879d2..e92163ceaac9c92015a8300da0ef859a0542d0fe 100644 (file)
@@ -52,3 +52,15 @@ def disable_planes(card):
 
     if areq.commit_sync() != 0:
         print("disabling planes failed")
+
+def get_crtc_for_connector(conn):
+    crtc = conn.get_current_crtc()
+
+    if crtc != None:
+        return crtc
+
+    for crtc in conn.get_possible_crtcs():
+        if crtc.mode_valid == False:
+            return crtc
+
+    raise RuntimeError("No free crtc found")
index 82511c3f0971392474510e64afc4bfd48df1db2a..cfb174575e091291256e923199c414613613387e 100755 (executable)
@@ -17,7 +17,7 @@ mode = conn.get_default_mode()
 fb = pykms.DumbFramebuffer(card, 200, 200, "XR24");
 pykms.draw_test_pattern(fb);
 
-crtc = conn.get_current_crtc()
+crtc = get_crtc_for_connector(conn)
 
 #crtc.set_mode(conn, fb, mode)
 
index f31986a7af6e4e5b40593f675bff18aae3d9d3fe..efc760aabb3d0e8538de95b20448fc2eae1e716b 100644 (file)
@@ -40,6 +40,7 @@ void init_pykmsbase(py::module &m)
                        .def_property_readonly("fullname", &Connector::fullname)
                        .def("get_default_mode", &Connector::get_default_mode)
                        .def("get_current_crtc", &Connector::get_current_crtc)
+                       .def("get_possible_crtcs", &Connector::get_possible_crtcs)
                        .def("get_modes", &Connector::get_modes)
                        .def("__repr__", [](const Connector& o) { return "<pykms.Connector " + to_string(o.id()) + ">"; })
                        ;
@@ -50,6 +51,8 @@ void init_pykmsbase(py::module &m)
                        .def("set_plane", &Crtc::set_plane)
                        .def_property_readonly("possible_planes", &Crtc::get_possible_planes)
                        .def_property_readonly("primary_plane", &Crtc::get_primary_plane)
+                       .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()) + ">"; })
                        ;
 
index 70d4887d364bcd619ab6b10fba3f1da05dd95de7..7625f101213e10aa3e07f9605464638eeaf239b1 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/python3
 
 import pykms
+from helpers import *
 
 card = pykms.Card()
 
@@ -11,7 +12,7 @@ mode = conn.get_default_mode()
 fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24");
 pykms.draw_test_pattern(fb);
 
-crtc = conn.get_current_crtc()
+crtc = get_crtc_for_connector(conn)
 
 crtc.set_mode(conn, fb, mode)
 
index 96357379d866272ead2a41cb15a4c4b192117763..e80802bbd80794f2d76b091b3f75bbd4e95b3ac8 100755 (executable)
@@ -12,7 +12,7 @@ card = pykms.Card()
 
 conn = card.get_first_connected_connector()
 mode = conn.get_default_mode()
-crtc = conn.get_current_crtc()
+crtc = get_crtc_for_connector(conn)
 
 planes = []
 for p in card.planes: