int main(int argc, char** argv) { string src_conn_name = "unknown"; string dst_conn_name = "hdmi"; PixelFormat pixfmt = PixelFormat::XRGB8888; OptionSet optionset = { Option("s|src=", [&](string s) { src_conn_name = s; }), Option("d|dst=", [&](string s) { dst_conn_name = s; }), Option("f|format=", [&](string s) { pixfmt = FourCCToPixelFormat(s); }), Option("h|help", [&]() { puts(usage_str); exit(-1); }), }; optionset.parse(argc, argv); if (optionset.params().size() > 0) { puts(usage_str); exit(-1); } VideoDevice vid("/dev/video11"); Card card; ResourceManager resman(card); auto src_conn = resman.reserve_connector(src_conn_name); auto src_crtc = resman.reserve_crtc(src_conn); uint32_t src_width = src_crtc->mode().hdisplay; uint32_t src_height = src_crtc->mode().vdisplay; printf("src %s, crtc %ux%u\n", src_conn->fullname().c_str(), src_width, src_height); auto dst_conn = resman.reserve_connector(dst_conn_name); auto dst_crtc = resman.reserve_crtc(dst_conn); auto dst_plane = resman.reserve_overlay_plane(dst_crtc, pixfmt); FAIL_IF(!dst_plane, "Plane not found"); uint32_t dst_width = min((uint32_t)dst_crtc->mode().hdisplay, src_width); uint32_t dst_height = min((uint32_t)dst_crtc->mode().vdisplay, src_height); printf("dst %s, crtc %ux%u, plane %ux%u\n", dst_conn->fullname().c_str(), dst_crtc->mode().hdisplay, dst_crtc->mode().vdisplay, dst_width, dst_height); for (int i = 0; i < CAMERA_BUF_QUEUE_SIZE; ++i) { auto fb = new DumbFramebuffer(card, src_width, src_height, pixfmt); s_fbs.push_back(fb); s_free_fbs.push_back(fb); } // get one fb for initial setup s_ready_fbs.push_back(s_free_fbs.back()); s_free_fbs.pop_back(); // This draws a moving bar to SRC display BarFlipState barflipper(card, src_crtc); barflipper.start_flipping(); // This shows the captures SRC frames on DST display WBFlipState wbflipper(card, dst_crtc, dst_plane); wbflipper.setup(0, 0, dst_width, dst_height); WBStreamer wb(vid.get_capture_streamer(), src_crtc, src_width, src_height, pixfmt); wb.start_streaming(); vector<pollfd> fds(3); fds[0].fd = 0; fds[0].events = POLLIN; fds[1].fd = wb.fd(); fds[1].events = POLLIN; fds[2].fd = card.fd(); fds[2].events = POLLIN; while (true) { int r = poll(fds.data(), fds.size(), -1); ASSERT(r > 0); if (fds[0].revents != 0) break; if (fds[1].revents) { fds[1].revents = 0; wb.Dequeue(); wbflipper.queue_next(); } if (fds[2].revents) { fds[2].revents = 0; card.call_page_flip_handlers(); wb.Queue(); } } printf("exiting...\n"); }
int main(int argc, char **argv) { string dev_path; unsigned id = 0; OptionSet optionset = { Option("|device=", [&](string s) { dev_path = s; }), Option("|id=", [&](string s) { id = stoul(s); }), Option("p", [&](string s) { opts.print_props = true; }), Option("m", [&](string s) { opts.print_modes = true; }), Option("r", [&](string s) { opts.recurse = true; }), Option("h|help", [&]() { usage(); exit(-1); }), }; optionset.parse(argc, argv); if (optionset.params().size() > 0) { usage(); exit(-1); } Card card; /* No options impliles recursion */ if (id == 0) { opts.recurse = true; for (auto conn : card.get_connectors()) print_connector(*conn, 0); return 0; } else { auto ob = card.get_object(id); if (!ob) { cerr << "kmsprint" << ": Object id " << id << " not found." << endl; return -1; } if (auto co = dynamic_cast<Connector*>(ob)) print_connector(*co, 0); else if (auto en = dynamic_cast<Encoder*>(ob)) print_encoder(*en, 0); else if (auto cr = dynamic_cast<Crtc*>(ob)) print_crtc(*cr, 0); else if (auto pl = dynamic_cast<Plane*>(ob)) print_plane(*pl, 0); else { cerr << "kmsprint" << ": Unkown DRM Object type" << endl; return -1; } return 0; } }