From 0b3c14f8db44bfa7f7bfa5e1655c5b15d2104f91 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 27 May 2016 16:33:31 +0300 Subject: testpat: atomic commit --- utils/testpat.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/testpat.cpp b/utils/testpat.cpp index 919774f..6aa6583 100644 --- a/utils/testpat.cpp +++ b/utils/testpat.cpp @@ -588,7 +588,7 @@ static void draw_test_patterns(const vector& outputs) } } -static void set_crtcs_n_planes(Card& card, const vector& outputs) +static void set_crtcs_n_planes_legacy(Card& card, const vector& outputs) { for (const OutputInfo& o : outputs) { auto conn = o.connector; @@ -614,6 +614,75 @@ static void set_crtcs_n_planes(Card& card, const vector& outputs) } } +static void set_crtcs_n_planes(Card& card, const vector& outputs) +{ + // Keep blobs here so that we keep ref to them until we have committed the req + vector> blobs; + + AtomicReq req(card); + + for (const OutputInfo& o : outputs) { + auto conn = o.connector; + auto crtc = o.crtc; + + if (!o.fbs.empty()) { + auto fb = o.fbs[0]; + + blobs.emplace_back(o.mode.to_blob(card)); + Blob* mode_blob = blobs.back().get(); + + req.add(conn, { + { "CRTC_ID", crtc->id() }, + }); + + req.add(crtc, { + { "ACTIVE", 1 }, + { "MODE_ID", mode_blob->id() }, + }); + + req.add(o.primary_plane, { + { "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", 0 }, + { "CRTC_Y", 0 }, + { "CRTC_W", fb->width() }, + { "CRTC_H", fb->height() }, + }); + } + + for (const PlaneInfo& p : o.planes) { + auto fb = p.fbs[0]; + + req.add(p.plane, { + { "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", p.x }, + { "CRTC_Y", p.y }, + { "CRTC_W", p.w }, + { "CRTC_H", p.h }, + }); + } + } + + int r; + + r = req.test(true); + if (r) + EXIT("Atomic test failed: %d\n", r); + + r = req.commit_sync(true); + if (r) + EXIT("Atomic commit failed: %d\n", r); +} + int main(int argc, char **argv) { vector output_args = parse_cmdline(argc, argv); @@ -635,7 +704,10 @@ int main(int argc, char **argv) print_outputs(outputs); - set_crtcs_n_planes(card, outputs); + if (card.has_atomic()) + set_crtcs_n_planes(card, outputs); + else + set_crtcs_n_planes_legacy(card, outputs); printf("press enter to exit\n"); -- cgit v1.2.3