summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-03-21 15:04:24 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-03-21 15:04:24 +0200
commit2439ae8738ad9410441c6160f512ab64ec94333d (patch)
treefbb274db500a09fa0191f260b04659b85350154a
parent9aeb121657a076a0c03ac6e7fc3c1e93e465e5d9 (diff)
parentdce8d396848c509d77b7fe8f745ea29e74af9c0c (diff)
Merge branch 'universal-planes2' of git://github.com/jsarha/kmsxx
-rw-r--r--kms++util/inc/kms++util/resourcemanager.h1
-rw-r--r--kms++util/src/resourcemanager.cpp21
-rw-r--r--py/pykms/pykmsutil.cpp3
-rwxr-xr-xpy/tests/plane_hog.py136
4 files changed, 160 insertions, 1 deletions
diff --git a/kms++util/inc/kms++util/resourcemanager.h b/kms++util/inc/kms++util/resourcemanager.h
index dac6c9e..b4a210d 100644
--- a/kms++util/inc/kms++util/resourcemanager.h
+++ b/kms++util/inc/kms++util/resourcemanager.h
@@ -16,6 +16,7 @@ public:
Connector* reserve_connector(Connector* conn);
Crtc* reserve_crtc(Connector* conn);
Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined);
+ Plane* reserve_generic_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
Plane* reserve_overlay_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
diff --git a/kms++util/src/resourcemanager.cpp b/kms++util/src/resourcemanager.cpp
index 5c83ad7..23a1480 100644
--- a/kms++util/src/resourcemanager.cpp
+++ b/kms++util/src/resourcemanager.cpp
@@ -129,7 +129,26 @@ Crtc* ResourceManager::reserve_crtc(Connector* conn)
Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format)
{
for (Plane* plane : crtc->get_possible_planes()) {
- if (plane->plane_type() != type)
+ if (plane->plane_type() == type)
+ continue;
+
+ if (format != PixelFormat::Undefined && !plane->supports_format(format))
+ continue;
+
+ if (contains(m_reserved_planes, plane))
+ continue;
+
+ m_reserved_planes.push_back(plane);
+ return plane;
+ }
+
+ return nullptr;
+}
+
+Plane* ResourceManager::reserve_generic_plane(Crtc* crtc, PixelFormat format)
+{
+ for (Plane* plane : crtc->get_possible_planes()) {
+ if (plane->plane_type() == PlaneType::Cursor)
continue;
if (format != PixelFormat::Undefined && !plane->supports_format(format))
diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp
index 8421cc5..46b7765 100644
--- a/py/pykms/pykmsutil.cpp
+++ b/py/pykms/pykmsutil.cpp
@@ -30,6 +30,9 @@ void init_pykmstest(py::module &m)
py::arg("crtc"),
py::arg("type"),
py::arg("format") = PixelFormat::Undefined)
+ .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
+ py::arg("crtc"),
+ py::arg("format") = PixelFormat::Undefined)
.def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
py::arg("crtc"),
py::arg("format") = PixelFormat::Undefined)
diff --git a/py/tests/plane_hog.py b/py/tests/plane_hog.py
new file mode 100755
index 0000000..5bdc937
--- /dev/null
+++ b/py/tests/plane_hog.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python3
+
+import pykms
+import sys
+
+card = pykms.Card()
+res = pykms.ResourceManager(card)
+
+conn1 = False
+conn2 = False
+
+for conn in card.connectors:
+ if not conn1:
+ conn1 = conn
+ elif not conn2:
+ conn2 = conn
+ else:
+ break
+
+crtc1 = res.reserve_crtc(conn1)
+mode1 = conn1.get_default_mode()
+modeb1 = mode1.to_blob(card)
+print("CRTC idx %d goes to %s connector" % (crtc1.idx, conn1.fullname))
+
+if conn2:
+ crtc2 = res.reserve_crtc(conn2)
+ mode2 = conn2.get_default_mode()
+ modeb2 = mode2.to_blob(card)
+ print("CRTC idx %d goes to %s connector" % (crtc2.idx, conn2.fullname))
+
+fbwidth = 480
+fbheight = 270
+
+fb = pykms.DumbFramebuffer(card, fbwidth, fbheight, "AR24");
+pykms.draw_test_pattern(fb);
+
+# Disable request
+card.disable_planes()
+
+plane_list = []
+
+while True:
+ plane = res.reserve_generic_plane(crtc1)
+ if plane:
+ print("Got plane idx %d" % plane.idx)
+ plane_list.append(plane)
+ else:
+ break
+
+print("Got %d planes" % len(plane_list))
+
+req = pykms.AtomicReq(card)
+req.add(conn1, "CRTC_ID", crtc1.id)
+req.add(crtc1, {"ACTIVE": 1,
+ "MODE_ID": modeb1.id})
+
+input("Press enter to enable crtc idx %d at %s" % (crtc1.idx, conn1.fullname))
+r = req.commit_sync(allow_modeset = True)
+
+print("Crtc enable request returned %d\n" % r)
+
+x = 0
+y = 0
+z = 0
+
+for plane in plane_list:
+ input("Press enter to enable plane idx %d on crtc idx %d" %
+ (plane.idx, crtc1.idx))
+ req = pykms.AtomicReq(card)
+ req.add(plane, {"FB_ID": fb.id,
+ "CRTC_ID": crtc1.id,
+ "SRC_X": 0 << 16,
+ "SRC_Y": 0 << 16,
+ "SRC_W": fb.width << 16,
+ "SRC_H": fb.height << 16,
+ "CRTC_X": x,
+ "CRTC_Y": y,
+ "CRTC_W": fb.width,
+ "CRTC_H": fb.height,
+ "zorder": z})
+ r = req.commit_sync()
+ print("Plane enable request returned %d\n" % r)
+
+ x = x + 50
+ y = y + 50
+ z = z + 1
+
+if not conn2:
+ sys.exit()
+
+req = pykms.AtomicReq(card)
+req.add(conn2, "CRTC_ID", crtc2.id)
+req.add(crtc2, {"ACTIVE": 1,
+ "MODE_ID": modeb2.id})
+
+input("Press enter to enable crtc idx %d at %s" % (crtc2.idx, conn2.fullname))
+r = req.commit_sync(allow_modeset = True)
+print("Crtc enable request returned %d\n" % r)
+
+x = 0
+y = 0
+z = 0
+
+# Code assumes that planes for crtc1 also work for crtc2
+for plane in reversed(plane_list):
+
+ input("Press enter to disable plane idx %d on crtc idx %d" %
+ (plane.idx, crtc1.idx))
+ req = pykms.AtomicReq(card)
+ req.add(plane, {"FB_ID": 0,
+ "CRTC_ID": 0})
+ r = req.commit_sync(allow_modeset = True)
+ print("Plane disable request returned %d\n" % r)
+
+ input("Press enter to enable plane idx %d on crtc idx %d" %
+ (plane.idx, crtc2.idx))
+ req = pykms.AtomicReq(card)
+ req.add(plane, {"FB_ID": fb.id,
+ "CRTC_ID": crtc2.id,
+ "SRC_X": 0 << 16,
+ "SRC_Y": 0 << 16,
+ "SRC_W": fb.width << 16,
+ "SRC_H": fb.height << 16,
+ "CRTC_X": x,
+ "CRTC_Y": y,
+ "CRTC_W": fb.width,
+ "CRTC_H": fb.height,
+ "zorder": z})
+ r = req.commit_sync(allow_modeset = True)
+ print("Plane enable request returned %d\n" % r)
+
+ x = x + 50
+ y = y + 50
+ z = z + 1
+
+input("press enter to exit\n")