aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-03-21 08:04:24 -0500
committerTomi Valkeinen2017-03-21 08:04:24 -0500
commit2439ae8738ad9410441c6160f512ab64ec94333d (patch)
treefbb274db500a09fa0191f260b04659b85350154a
parent9aeb121657a076a0c03ac6e7fc3c1e93e465e5d9 (diff)
parentdce8d396848c509d77b7fe8f745ea29e74af9c0c (diff)
downloadexternal-kmsxx-2439ae8738ad9410441c6160f512ab64ec94333d.tar.gz
external-kmsxx-2439ae8738ad9410441c6160f512ab64ec94333d.tar.xz
external-kmsxx-2439ae8738ad9410441c6160f512ab64ec94333d.zip
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:
16 Connector* reserve_connector(Connector* conn); 16 Connector* reserve_connector(Connector* conn);
17 Crtc* reserve_crtc(Connector* conn); 17 Crtc* reserve_crtc(Connector* conn);
18 Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined); 18 Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined);
19 Plane* reserve_generic_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
19 Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined); 20 Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
20 Plane* reserve_overlay_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined); 21 Plane* reserve_overlay_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
21 22
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)
129Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format) 129Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format)
130{ 130{
131 for (Plane* plane : crtc->get_possible_planes()) { 131 for (Plane* plane : crtc->get_possible_planes()) {
132 if (plane->plane_type() != type) 132 if (plane->plane_type() == type)
133 continue;
134
135 if (format != PixelFormat::Undefined && !plane->supports_format(format))
136 continue;
137
138 if (contains(m_reserved_planes, plane))
139 continue;
140
141 m_reserved_planes.push_back(plane);
142 return plane;
143 }
144
145 return nullptr;
146}
147
148Plane* ResourceManager::reserve_generic_plane(Crtc* crtc, PixelFormat format)
149{
150 for (Plane* plane : crtc->get_possible_planes()) {
151 if (plane->plane_type() == PlaneType::Cursor)
133 continue; 152 continue;
134 153
135 if (format != PixelFormat::Undefined && !plane->supports_format(format)) 154 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)
30 py::arg("crtc"), 30 py::arg("crtc"),
31 py::arg("type"), 31 py::arg("type"),
32 py::arg("format") = PixelFormat::Undefined) 32 py::arg("format") = PixelFormat::Undefined)
33 .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
34 py::arg("crtc"),
35 py::arg("format") = PixelFormat::Undefined)
33 .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane, 36 .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
34 py::arg("crtc"), 37 py::arg("crtc"),
35 py::arg("format") = PixelFormat::Undefined) 38 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 @@
1#!/usr/bin/python3
2
3import pykms
4import sys
5
6card = pykms.Card()
7res = pykms.ResourceManager(card)
8
9conn1 = False
10conn2 = False
11
12for conn in card.connectors:
13 if not conn1:
14 conn1 = conn
15 elif not conn2:
16 conn2 = conn
17 else:
18 break
19
20crtc1 = res.reserve_crtc(conn1)
21mode1 = conn1.get_default_mode()
22modeb1 = mode1.to_blob(card)
23print("CRTC idx %d goes to %s connector" % (crtc1.idx, conn1.fullname))
24
25if conn2:
26 crtc2 = res.reserve_crtc(conn2)
27 mode2 = conn2.get_default_mode()
28 modeb2 = mode2.to_blob(card)
29 print("CRTC idx %d goes to %s connector" % (crtc2.idx, conn2.fullname))
30
31fbwidth = 480
32fbheight = 270
33
34fb = pykms.DumbFramebuffer(card, fbwidth, fbheight, "AR24");
35pykms.draw_test_pattern(fb);
36
37# Disable request
38card.disable_planes()
39
40plane_list = []
41
42while True:
43 plane = res.reserve_generic_plane(crtc1)
44 if plane:
45 print("Got plane idx %d" % plane.idx)
46 plane_list.append(plane)
47 else:
48 break
49
50print("Got %d planes" % len(plane_list))
51
52req = pykms.AtomicReq(card)
53req.add(conn1, "CRTC_ID", crtc1.id)
54req.add(crtc1, {"ACTIVE": 1,
55 "MODE_ID": modeb1.id})
56
57input("Press enter to enable crtc idx %d at %s" % (crtc1.idx, conn1.fullname))
58r = req.commit_sync(allow_modeset = True)
59
60print("Crtc enable request returned %d\n" % r)
61
62x = 0
63y = 0
64z = 0
65
66for plane in plane_list:
67 input("Press enter to enable plane idx %d on crtc idx %d" %
68 (plane.idx, crtc1.idx))
69 req = pykms.AtomicReq(card)
70 req.add(plane, {"FB_ID": fb.id,
71 "CRTC_ID": crtc1.id,
72 "SRC_X": 0 << 16,
73 "SRC_Y": 0 << 16,
74 "SRC_W": fb.width << 16,
75 "SRC_H": fb.height << 16,
76 "CRTC_X": x,
77 "CRTC_Y": y,
78 "CRTC_W": fb.width,
79 "CRTC_H": fb.height,
80 "zorder": z})
81 r = req.commit_sync()
82 print("Plane enable request returned %d\n" % r)
83
84 x = x + 50
85 y = y + 50
86 z = z + 1
87
88if not conn2:
89 sys.exit()
90
91req = pykms.AtomicReq(card)
92req.add(conn2, "CRTC_ID", crtc2.id)
93req.add(crtc2, {"ACTIVE": 1,
94 "MODE_ID": modeb2.id})
95
96input("Press enter to enable crtc idx %d at %s" % (crtc2.idx, conn2.fullname))
97r = req.commit_sync(allow_modeset = True)
98print("Crtc enable request returned %d\n" % r)
99
100x = 0
101y = 0
102z = 0
103
104# Code assumes that planes for crtc1 also work for crtc2
105for plane in reversed(plane_list):
106
107 input("Press enter to disable plane idx %d on crtc idx %d" %
108 (plane.idx, crtc1.idx))
109 req = pykms.AtomicReq(card)
110 req.add(plane, {"FB_ID": 0,
111 "CRTC_ID": 0})
112 r = req.commit_sync(allow_modeset = True)
113 print("Plane disable request returned %d\n" % r)
114
115 input("Press enter to enable plane idx %d on crtc idx %d" %
116 (plane.idx, crtc2.idx))
117 req = pykms.AtomicReq(card)
118 req.add(plane, {"FB_ID": fb.id,
119 "CRTC_ID": crtc2.id,
120 "SRC_X": 0 << 16,
121 "SRC_Y": 0 << 16,
122 "SRC_W": fb.width << 16,
123 "SRC_H": fb.height << 16,
124 "CRTC_X": x,
125 "CRTC_Y": y,
126 "CRTC_W": fb.width,
127 "CRTC_H": fb.height,
128 "zorder": z})
129 r = req.commit_sync(allow_modeset = True)
130 print("Plane enable request returned %d\n" % r)
131
132 x = x + 50
133 y = y + 50
134 z = z + 1
135
136input("press enter to exit\n")