diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-06 19:56:26 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-07 17:04:28 +0300 |
commit | ded84bf2620313b701af9c88b0f6c6ada2c70eaa (patch) | |
tree | fc836815746d044f46fc99dac0782e8472ac2eb3 /py | |
parent | a688d32d209a45627da3e80128a933d70f5d48b6 (diff) |
py: fix scripts when there's no current crtc
Diffstat (limited to 'py')
-rwxr-xr-x | py/alpha-test.py | 2 | ||||
-rwxr-xr-x | py/db.py | 3 | ||||
-rwxr-xr-x | py/functest.py | 3 | ||||
-rwxr-xr-x | py/gamma.py | 3 | ||||
-rw-r--r-- | py/helpers.py | 12 | ||||
-rwxr-xr-x | py/iact.py | 2 | ||||
-rw-r--r-- | py/pykmsbase.cpp | 3 | ||||
-rwxr-xr-x | py/test.py | 3 | ||||
-rwxr-xr-x | py/trans-test.py | 2 |
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: @@ -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") @@ -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()) + ">"; }) ; @@ -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: |