SHARE
TWEET

Untitled

a guest Nov 15th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <assert.h>
  2. #include <string.h>
  3. #include <unistd.h>
  4.  
  5. #include <kms++/kms++.h>
  6. #include <kms++util/resourcemanager.h>
  7.  
  8. int main () {
  9.     kms::Card card("/dev/dri/card4");
  10.     assert(card.has_has_universal_planes());
  11.     assert(card.has_atomic());
  12.  
  13.     kms::ResourceManager resmgr(card);
  14.  
  15.     kms::Connector* connector = card.get_connector(44);
  16.     assert(connector != nullptr);
  17.     connector = resmgr.reserve_connector(connector);
  18.     assert(connector != nullptr);
  19.     assert(connector->connected());
  20.  
  21.     kms::Crtc* crtc = resmgr.reserve_crtc(connector);
  22.     assert(crtc != nullptr);
  23.  
  24.     kms::Videomode mode = connector->get_default_mode();
  25.     std::unique_ptr<kms::Blob> modeblob = mode.to_blob(card);
  26.  
  27.     kms::Plane* plane = resmgr.reserve_generic_plane(crtc);
  28.     assert(plane != nullptr);
  29.  
  30.     kms::DumbFramebuffer fb(card, mode.hdisplay, mode.vdisplay, kms::PixelFormat::XRGB8888);
  31.     memset(fb.map(0), 0xff, fb.size(0));
  32.  
  33.     kms::AtomicReq req(card);
  34.  
  35.     req.add(connector, {
  36.             { "CRTC_ID", crtc->id() },
  37.     });
  38.  
  39.     req.add(crtc, {
  40.             { "ACTIVE", 1 },
  41.             { "MODE_ID", modeblob->id() },
  42.     });
  43.  
  44.     req.add(plane, {
  45.             { "FB_ID", fb.id() },
  46.             { "CRTC_ID", crtc->id() },
  47.             { "SRC_X", 0 << 16 },
  48.             { "SRC_Y", 0 << 16 },
  49.             { "SRC_W", fb.width() << 16 },
  50.             { "SRC_H", fb.height() << 16 },
  51.             { "CRTC_X", 0 },
  52.             { "CRTC_Y", 0 },
  53.             { "CRTC_W", fb.width() },
  54.             { "CRTC_H", fb.height() },
  55.     });
  56.  
  57.     req.commit_sync(true);
  58.     sleep(10);
  59.  
  60.     return 0;
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top