aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-10-10 03:16:19 -0500
committerTomi Valkeinen2017-10-10 06:07:36 -0500
commitf32b82c17cd357ae1c8ed2636266113955293feb (patch)
treea9ea2855b589f9150e271f16f3567e5273bd0643
parent876b2c9ee357eb680a2bae3703c1658d9e935536 (diff)
downloadexternal-kmsxx-f32b82c17cd357ae1c8ed2636266113955293feb.tar.gz
external-kmsxx-f32b82c17cd357ae1c8ed2636266113955293feb.tar.xz
external-kmsxx-f32b82c17cd357ae1c8ed2636266113955293feb.zip
kmscube: update drm resource allocation
-rw-r--r--kmscube/cube-gbm.cpp52
1 files changed, 17 insertions, 35 deletions
diff --git a/kmscube/cube-gbm.cpp b/kmscube/cube-gbm.cpp
index 980352c..e239a0c 100644
--- a/kmscube/cube-gbm.cpp
+++ b/kmscube/cube-gbm.cpp
@@ -181,8 +181,8 @@ private:
181class OutputHandler : private PageFlipHandlerBase 181class OutputHandler : private PageFlipHandlerBase
182{ 182{
183public: 183public:
184 OutputHandler(Card& card, GbmDevice& gdev, const EglState& egl, Connector* connector, Crtc* crtc, Videomode& mode, Plane* plane, float rotation_mult) 184 OutputHandler(Card& card, GbmDevice& gdev, const EglState& egl, Connector* connector, Crtc* crtc, Videomode& mode, Plane* root_plane, Plane* plane, float rotation_mult)
185 : m_frame_num(0), m_connector(connector), m_crtc(crtc), m_plane(plane), m_mode(mode), 185 : m_frame_num(0), m_connector(connector), m_crtc(crtc), m_root_plane(root_plane), m_plane(plane), m_mode(mode),
186 m_rotation_mult(rotation_mult) 186 m_rotation_mult(rotation_mult)
187 { 187 {
188 m_surface1 = unique_ptr<GbmEglSurface>(new GbmEglSurface(card, gdev, egl, mode.hdisplay, mode.vdisplay)); 188 m_surface1 = unique_ptr<GbmEglSurface>(new GbmEglSurface(card, gdev, egl, mode.hdisplay, mode.vdisplay));
@@ -215,22 +215,9 @@ public:
215 planefb = m_surface2->lock_next(); 215 planefb = m_surface2->lock_next();
216 } 216 }
217 217
218
219 ret = m_crtc->set_mode(m_connector, *fb, m_mode); 218 ret = m_crtc->set_mode(m_connector, *fb, m_mode);
220 FAIL_IF(ret, "failed to set mode"); 219 FAIL_IF(ret, "failed to set mode");
221 220
222 Plane* root_plane = 0;
223 for (Plane* p : m_crtc->get_possible_planes()) {
224 if (p->crtc_id() == m_crtc->id()) {
225 root_plane = p;
226 break;
227 }
228 }
229
230 FAIL_IF(!root_plane, "No primary plane for crtc %d", m_crtc->id());
231
232 m_root_plane = root_plane;
233
234 if (m_plane) { 221 if (m_plane) {
235 ret = m_crtc->set_plane(m_plane, *planefb, 222 ret = m_crtc->set_plane(m_plane, *planefb,
236 0, 0, planefb->width(), planefb->height(), 223 0, 0, planefb->width(), planefb->height(),
@@ -307,9 +294,9 @@ private:
307 294
308 Connector* m_connector; 295 Connector* m_connector;
309 Crtc* m_crtc; 296 Crtc* m_crtc;
297 Plane* m_root_plane;
310 Plane* m_plane; 298 Plane* m_plane;
311 Videomode m_mode; 299 Videomode m_mode;
312 Plane* m_root_plane;
313 300
314 unique_ptr<GbmEglSurface> m_surface1; 301 unique_ptr<GbmEglSurface> m_surface1;
315 unique_ptr<GbmEglSurface> m_surface2; 302 unique_ptr<GbmEglSurface> m_surface2;
@@ -329,35 +316,30 @@ void main_gbm()
329 GbmDevice gdev(card); 316 GbmDevice gdev(card);
330 EglState egl(gdev.handle()); 317 EglState egl(gdev.handle());
331 318
319 ResourceManager resman(card);
320
332 vector<unique_ptr<OutputHandler>> outputs; 321 vector<unique_ptr<OutputHandler>> outputs;
333 vector<Plane*> used_planes;
334 322
335 float rot_mult = 1; 323 float rot_mult = 1;
336 324
337 for (auto pipe : card.get_connected_pipelines()) { 325 for (Connector* conn : card.get_connectors()) {
338 auto connector = pipe.connector; 326 if (!conn->connected())
339 auto crtc = pipe.crtc; 327 continue;
340 auto mode = connector->get_default_mode();
341 328
342 Plane* plane = 0; 329 resman.reserve_connector(conn);
343 330
344 if (s_support_planes) { 331 Crtc* crtc = resman.reserve_crtc(conn);
345 for (Plane* p : crtc->get_possible_planes()) { 332 auto mode = conn->get_default_mode();
346 if (find(used_planes.begin(), used_planes.end(), p) != used_planes.end())
347 continue;
348 333
349 if (p->plane_type() != PlaneType::Overlay) 334 Plane* root_plane = resman.reserve_generic_plane(crtc);
350 continue; 335 FAIL_IF(!root_plane, "Root plane not available");
351 336
352 plane = p; 337 Plane* plane = nullptr;
353 break;
354 }
355 }
356 338
357 if (plane) 339 if (s_support_planes)
358 used_planes.push_back(plane); 340 plane = resman.reserve_generic_plane(crtc);
359 341
360 auto out = new OutputHandler(card, gdev, egl, connector, crtc, mode, plane, rot_mult); 342 auto out = new OutputHandler(card, gdev, egl, conn, crtc, mode, root_plane, plane, rot_mult);
361 outputs.emplace_back(out); 343 outputs.emplace_back(out);
362 344
363 rot_mult *= 1.33; 345 rot_mult *= 1.33;