diff options
author | Tomi Valkeinen | 2017-03-21 08:04:24 -0500 |
---|---|---|
committer | Tomi Valkeinen | 2017-03-21 08:04:24 -0500 |
commit | 2439ae8738ad9410441c6160f512ab64ec94333d (patch) | |
tree | fbb274db500a09fa0191f260b04659b85350154a | |
parent | 9aeb121657a076a0c03ac6e7fc3c1e93e465e5d9 (diff) | |
parent | dce8d396848c509d77b7fe8f745ea29e74af9c0c (diff) | |
download | external-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.h | 1 | ||||
-rw-r--r-- | kms++util/src/resourcemanager.cpp | 21 | ||||
-rw-r--r-- | py/pykms/pykmsutil.cpp | 3 | ||||
-rwxr-xr-x | py/tests/plane_hog.py | 136 |
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) | |||
129 | Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format) | 129 | Plane* 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 | |||
148 | Plane* 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 | |||
3 | import pykms | ||
4 | import sys | ||
5 | |||
6 | card = pykms.Card() | ||
7 | res = pykms.ResourceManager(card) | ||
8 | |||
9 | conn1 = False | ||
10 | conn2 = False | ||
11 | |||
12 | for conn in card.connectors: | ||
13 | if not conn1: | ||
14 | conn1 = conn | ||
15 | elif not conn2: | ||
16 | conn2 = conn | ||
17 | else: | ||
18 | break | ||
19 | |||
20 | crtc1 = res.reserve_crtc(conn1) | ||
21 | mode1 = conn1.get_default_mode() | ||
22 | modeb1 = mode1.to_blob(card) | ||
23 | print("CRTC idx %d goes to %s connector" % (crtc1.idx, conn1.fullname)) | ||
24 | |||
25 | if 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 | |||
31 | fbwidth = 480 | ||
32 | fbheight = 270 | ||
33 | |||
34 | fb = pykms.DumbFramebuffer(card, fbwidth, fbheight, "AR24"); | ||
35 | pykms.draw_test_pattern(fb); | ||
36 | |||
37 | # Disable request | ||
38 | card.disable_planes() | ||
39 | |||
40 | plane_list = [] | ||
41 | |||
42 | while 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 | |||
50 | print("Got %d planes" % len(plane_list)) | ||
51 | |||
52 | req = pykms.AtomicReq(card) | ||
53 | req.add(conn1, "CRTC_ID", crtc1.id) | ||
54 | req.add(crtc1, {"ACTIVE": 1, | ||
55 | "MODE_ID": modeb1.id}) | ||
56 | |||
57 | input("Press enter to enable crtc idx %d at %s" % (crtc1.idx, conn1.fullname)) | ||
58 | r = req.commit_sync(allow_modeset = True) | ||
59 | |||
60 | print("Crtc enable request returned %d\n" % r) | ||
61 | |||
62 | x = 0 | ||
63 | y = 0 | ||
64 | z = 0 | ||
65 | |||
66 | for 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 | |||
88 | if not conn2: | ||
89 | sys.exit() | ||
90 | |||
91 | req = pykms.AtomicReq(card) | ||
92 | req.add(conn2, "CRTC_ID", crtc2.id) | ||
93 | req.add(crtc2, {"ACTIVE": 1, | ||
94 | "MODE_ID": modeb2.id}) | ||
95 | |||
96 | input("Press enter to enable crtc idx %d at %s" % (crtc2.idx, conn2.fullname)) | ||
97 | r = req.commit_sync(allow_modeset = True) | ||
98 | print("Crtc enable request returned %d\n" % r) | ||
99 | |||
100 | x = 0 | ||
101 | y = 0 | ||
102 | z = 0 | ||
103 | |||
104 | # Code assumes that planes for crtc1 also work for crtc2 | ||
105 | for 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 | |||
136 | input("press enter to exit\n") | ||