summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpy/alpha-test.py2
-rwxr-xr-xpy/db.py3
-rwxr-xr-xpy/functest.py3
-rwxr-xr-xpy/gamma.py3
-rw-r--r--py/helpers.py12
-rwxr-xr-xpy/iact.py2
-rw-r--r--py/pykmsbase.cpp3
-rwxr-xr-xpy/test.py3
-rwxr-xr-xpy/trans-test.py2
9 files changed, 25 insertions, 8 deletions
diff --git a/py/alpha-test.py b/py/alpha-test.py
index 6957bb4..113fab0 100755
--- a/py/alpha-test.py
+++ b/py/alpha-test.py
@@ -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:
diff --git a/py/db.py b/py/db.py
index 315f993..6073765 100755
--- 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()
diff --git a/py/functest.py b/py/functest.py
index 624f320..c2548fa 100755
--- a/py/functest.py
+++ b/py/functest.py
@@ -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)
diff --git a/py/gamma.py b/py/gamma.py
index 6dfd935..e1daa43 100755
--- a/py/gamma.py
+++ b/py/gamma.py
@@ -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);
diff --git a/py/helpers.py b/py/helpers.py
index fd67d41..e92163c 100644
--- a/py/helpers.py
+++ b/py/helpers.py
@@ -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")
diff --git a/py/iact.py b/py/iact.py
index 82511c3..cfb1745 100755
--- a/py/iact.py
+++ b/py/iact.py
@@ -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)
diff --git a/py/pykmsbase.cpp b/py/pykmsbase.cpp
index f31986a..efc760a 100644
--- a/py/pykmsbase.cpp
+++ b/py/pykmsbase.cpp
@@ -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()) + ">"; })
;
diff --git a/py/test.py b/py/test.py
index 70d4887..7625f10 100755
--- a/py/test.py
+++ b/py/test.py
@@ -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)
diff --git a/py/trans-test.py b/py/trans-test.py
index 9635737..e80802b 100755
--- a/py/trans-test.py
+++ b/py/trans-test.py
@@ -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: