Fix the rest of the py scripts
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 23 May 2016 06:31:08 +0000 (09:31 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 23 May 2016 06:43:43 +0000 (09:43 +0300)
py/alpha-test.py
py/db.py
py/helpers.py
py/pykmsbase.cpp
py/pykmstest.cpp
py/trans-test.py

index 99c84fbfd5d09f34acec760faf52c3e0c9e5ed08..6957bb4277cd5be4bdf16cb59033820b3ab40955 100755 (executable)
@@ -50,15 +50,15 @@ for i in range(len(planes)):
     plane = planes[i]
     fb = fbs[i]
 
-    print("set crtc {}, plane {}, fb {}".format(crtc.id(), p.id(), fbs[i].id()))
+    print("set crtc {}, plane {}, fb {}".format(crtc.id, p.id, fbs[i].id))
 
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
         "zorder": i,
     })
 
index c51ca700f9c02a063532e886b2e7c81c9e45d772..315f99376fc065f67d6c2e12af33399a513bd9d1 100755 (executable)
--- a/py/db.py
+++ b/py/db.py
@@ -33,13 +33,12 @@ class FlipHandler(pykms.PageFlipHandlerBase):
 
         if card.has_atomic:
             ctx = pykms.AtomicReq(card)
-            ctx.add(crtc, "FB_ID", fb.id)
+            ctx.add(crtc.primary_plane, "FB_ID", fb.id)
             ctx.commit(self)
         else:
             crtc.page_flip(fb, self)
 
 
-
 card = pykms.Card()
 conn = card.get_first_connected_connector()
 mode = conn.get_default_mode()
index acb90989f6f488309ba1e1bf60c747d537d25f35..c5235238d26df4d8d215aeb78c4526fb279eb2f9 100644 (file)
@@ -12,12 +12,12 @@ def props(o):
         print("%-15s %d (%#x)" % (prop.name, propval, propval))
 
 def set_props(ob, map):
-    areq = pykms.AtomicReq(ob.card())
+    areq = pykms.AtomicReq(ob.card)
 
     for key, value in map.items():
         areq.add(ob, key, value)
 
-    if areq.commit() != 0:
+    if areq.commit_sync() != 0:
         print("commit failed")
 
 red = pykms.RGB(255, 0, 0)
@@ -35,5 +35,5 @@ def disable_planes(card):
         areq.add(p, "FB_ID", 0)
         areq.add(p, "CRTC_ID", 0)
 
-    if areq.commit() != 0:
+    if areq.commit_sync() != 0:
         print("disabling planes failed")
index 53c73517ade1cb70cbb932b655dfe1de141f0e07..b27ed3ca4389390c5e5a347cfb14715765272092 100644 (file)
@@ -43,6 +43,7 @@ void init_pykmsbase(py::module &m)
                        .def("page_flip", &Crtc::page_flip)
                        .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("__repr__", [](const Crtc& o) { return "<pykms.Crtc " + to_string(o.id()) + ">"; })
                        ;
 
index 781a43aa668e711534ed0d9b2534b17b2e6948a4..407330d06ad28368810df86534d17eff62fb0699 100644 (file)
@@ -14,6 +14,10 @@ void init_pykmstest(py::module &m)
                        .def(py::init<>())
                        .def(py::init<uint8_t, uint8_t, uint8_t&>())
                        .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>())
+                       .def_property_readonly("rgb888", &RGB::rgb888)
+                       .def_property_readonly("argb8888", &RGB::argb8888)
+                       .def_property_readonly("abgr8888", &RGB::abgr8888)
+                       .def_property_readonly("rgb565", &RGB::rgb565)
                        ;
 
        // Use lambdas to handle IMappedFramebuffer
index 57855ff14df22a7a0a37bc270695aefe1f5dcec6..96357379d866272ead2a41cb15a4c4b192117763 100755 (executable)
@@ -32,18 +32,18 @@ def test_am5_trans_dest():
     fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24"))
 
     fb = fbs[0]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), purple)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, purple)
     pykms.draw_rect(fb, 100, 100, 100, 200, green)
     pykms.draw_rect(fb, 300, 100, 100, 200, red)
     pykms.draw_rect(fb, 500, 100, 100, 200, white)
 
     fb = fbs[1]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), cyan)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan)
     pykms.draw_rect(fb, 250, 100, 200, 200, yellow)
 
     set_props(crtc, {
         "trans-key-mode": 1,
-        "trans-key": purple.rgb888(),
+        "trans-key": purple.rgb888,
         "background": 0,
         "alpha_blender": 0,
     })
@@ -51,17 +51,17 @@ def test_am5_trans_dest():
     plane = 0
 
     for i in range(0,2):
-        print("set crtc {}, plane {}, fb {}".format(crtc.id(), planes[i].id(), fbs[i].id()))
+        print("set crtc {}, plane {}, fb {}".format(crtc.id, planes[i].id, fbs[i].id))
 
         plane = planes[i]
         fb = fbs[i]
         set_props(plane, {
-            "FB_ID": fb.id(),
-            "CRTC_ID": crtc.id(),
-            "SRC_W": fb.width() << 16,
-            "SRC_H": fb.height() << 16,
-            "CRTC_W": fb.width(),
-            "CRTC_H": fb.height(),
+            "FB_ID": fb.id,
+            "CRTC_ID": crtc.id,
+            "SRC_W": fb.width << 16,
+            "SRC_H": fb.height << 16,
+            "CRTC_W": fb.width,
+            "CRTC_H": fb.height,
             "zorder": i,
         })
 
@@ -72,17 +72,17 @@ def test_am5_trans_src():
     fbs.append(pykms.DumbFramebuffer(card, w, h, "XR24"))
 
     fb = fbs[0]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), white)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, white)
     pykms.draw_rect(fb, 200, 200, 100, 100, red)
-    pykms.draw_rect(fb, fb.width() - 300, 200, 100, 100, green)
+    pykms.draw_rect(fb, fb.width - 300, 200, 100, 100, green)
 
     fb = fbs[1]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), cyan)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan)
     pykms.draw_rect(fb, 100, 100, 500, 500, purple)
 
     set_props(crtc, {
         "trans-key-mode": 2,
-        "trans-key": purple.rgb888(),
+        "trans-key": purple.rgb888,
         "background": 0,
         "alpha_blender": 0,
     })
@@ -90,17 +90,17 @@ def test_am5_trans_src():
     plane = 0
 
     for i in range(0,2):
-        print("set crtc {}, plane {}, fb {}".format(crtc.id(), planes[i].id(), fbs[i].id()))
+        print("set crtc {}, plane {}, fb {}".format(crtc.id, planes[i].id, fbs[i].id))
 
         plane = planes[i]
         fb = fbs[i]
         set_props(plane, {
-            "FB_ID": fb.id(),
-            "CRTC_ID": crtc.id(),
-            "SRC_W": fb.width() << 16,
-            "SRC_H": fb.height() << 16,
-            "CRTC_W": fb.width(),
-            "CRTC_H": fb.height(),
+            "FB_ID": fb.id,
+            "CRTC_ID": crtc.id,
+            "SRC_W": fb.width << 16,
+            "SRC_H": fb.height << 16,
+            "CRTC_W": fb.width,
+            "CRTC_H": fb.height,
             "zorder": 3 if i == 1 else 0,
         })
 
@@ -118,14 +118,14 @@ def test_am4_normal_trans_dst():
     pykms.draw_rect(fb, 300, 50, 50, 200, white)
 
     fb = fbs[1]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), blue)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, blue)
 
     fb = fbs[2]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), cyan)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan)
 
     set_props(crtc, {
         "trans-key-mode": 1,
-        "trans-key": purple.rgb888(),
+        "trans-key": purple.rgb888,
         "background": 0,
         "alpha_blender": 0,
     })
@@ -135,10 +135,10 @@ def test_am4_normal_trans_dst():
     plane = planes[0]
     fb = fbs[0]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_W": w,
         "CRTC_H": h,
     })
@@ -148,16 +148,16 @@ def test_am4_normal_trans_dst():
     plane = planes[1]
     fb = fbs[1]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
         "SRC_X": 0 << 16,
         "SRC_Y": 0 << 16,
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_X": 0,
         "CRTC_Y": 0,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
     })
 
     time.sleep(1)
@@ -165,16 +165,16 @@ def test_am4_normal_trans_dst():
     plane = planes[2]
     fb = fbs[2]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
         "SRC_X": 0 << 16,
         "SRC_Y": 0 << 16,
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_X": w // 3,
         "CRTC_Y": 0,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
     })
 
 def test_am4_normal_trans_src():
@@ -188,16 +188,16 @@ def test_am4_normal_trans_src():
     pykms.draw_rect(fb, w - 200 - 50, 100, 50, 200, green)
 
     fb = fbs[1]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), blue)
-    pykms.draw_rect(fb, 100, 100, fb.width() - 200, fb.height() - 200, purple)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, blue)
+    pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, purple)
 
     fb = fbs[2]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), cyan)
-    pykms.draw_rect(fb, 100, 100, fb.width() - 200, fb.height() - 200, purple)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan)
+    pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, purple)
 
     set_props(crtc, {
         "trans-key-mode": 2,
-        "trans-key": purple.rgb888(),
+        "trans-key": purple.rgb888,
         "background": 0,
         "alpha_blender": 0,
     })
@@ -207,10 +207,10 @@ def test_am4_normal_trans_src():
     plane = planes[0]
     fb = fbs[0]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_W": w,
         "CRTC_H": h,
     })
@@ -220,16 +220,16 @@ def test_am4_normal_trans_src():
     plane = planes[1]
     fb = fbs[1]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
         "SRC_X": 0 << 16,
         "SRC_Y": 0 << 16,
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_X": 0,
         "CRTC_Y": 0,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
     })
 
     time.sleep(1)
@@ -237,16 +237,16 @@ def test_am4_normal_trans_src():
     plane = planes[2]
     fb = fbs[2]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
         "SRC_X": 0 << 16,
         "SRC_Y": 0 << 16,
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
-        "CRTC_X": w - fb.width(),
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
+        "CRTC_X": w - fb.width,
         "CRTC_Y": 0,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
     })
 
 def test_am4_alpha_trans_src():
@@ -260,16 +260,16 @@ def test_am4_alpha_trans_src():
     pykms.draw_rect(fb, w - 200 - 50, 100, 50, 200, green)
 
     fb = fbs[1]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), blue)
-    pykms.draw_rect(fb, 100, 100, fb.width() - 200, fb.height() - 200, purple)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, blue)
+    pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, purple)
 
     fb = fbs[2]
-    pykms.draw_rect(fb, 0, 0, fb.width(), fb.height(), cyan)
-    pykms.draw_rect(fb, 100, 100, fb.width() - 200, fb.height() - 200, purple)
+    pykms.draw_rect(fb, 0, 0, fb.width, fb.height, cyan)
+    pykms.draw_rect(fb, 100, 100, fb.width - 200, fb.height - 200, purple)
 
     set_props(crtc, {
         "trans-key-mode": 1,
-        "trans-key": purple.rgb888(),
+        "trans-key": purple.rgb888,
         "background": 0,
         "alpha_blender": 1,
     })
@@ -279,10 +279,10 @@ def test_am4_alpha_trans_src():
     plane = planes[0]
     fb = fbs[0]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_W": w,
         "CRTC_H": h,
     })
@@ -292,16 +292,16 @@ def test_am4_alpha_trans_src():
     plane = planes[1]
     fb = fbs[1]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
         "SRC_X": 0 << 16,
         "SRC_Y": 0 << 16,
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
         "CRTC_X": 0,
         "CRTC_Y": 0,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
     })
 
     time.sleep(1)
@@ -309,16 +309,16 @@ def test_am4_alpha_trans_src():
     plane = planes[2]
     fb = fbs[2]
     set_props(plane, {
-        "FB_ID": fb.id(),
-        "CRTC_ID": crtc.id(),
+        "FB_ID": fb.id,
+        "CRTC_ID": crtc.id,
         "SRC_X": 0 << 16,
         "SRC_Y": 0 << 16,
-        "SRC_W": fb.width() << 16,
-        "SRC_H": fb.height() << 16,
-        "CRTC_X": w - fb.width(),
+        "SRC_W": fb.width << 16,
+        "SRC_H": fb.height << 16,
+        "CRTC_X": w - fb.width,
         "CRTC_Y": 0,
-        "CRTC_W": fb.width(),
-        "CRTC_H": fb.height(),
+        "CRTC_W": fb.width,
+        "CRTC_H": fb.height,
     })