From 009828beac9bfe9c36d336a4de0d297f90aece52 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 28 Sep 2015 01:13:34 +0300 Subject: Initial version --- testpat/CMakeLists.txt | 6 ++++ testpat/testpat.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 testpat/CMakeLists.txt create mode 100644 testpat/testpat.cpp (limited to 'testpat') diff --git a/testpat/CMakeLists.txt b/testpat/CMakeLists.txt new file mode 100644 index 0000000..aed4371 --- /dev/null +++ b/testpat/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories(${LIBDRM_INCLUDE_DIRS}) +link_directories(${LIBDRM_LIBRARY_DIRS}) + +add_executable (testpat testpat.cpp) + +target_link_libraries(testpat kms++ ${LIBDRM_LIBRARIES}) diff --git a/testpat/testpat.cpp b/testpat/testpat.cpp new file mode 100644 index 0000000..5632224 --- /dev/null +++ b/testpat/testpat.cpp @@ -0,0 +1,88 @@ +#include +#include + +#include "kms++.h" +#include "utils/testpat.h" + +#include "../test.h" + +using namespace std; +using namespace kms; + +int main() +{ + Card card; + + if (card.master() == false) + printf("Not DRM master, modeset may fail\n"); + + //card.print_short(); + + auto connectors = card.get_connectors(); + + vector fbs; + vector used_crtcs; + + for (auto conn : connectors) + { + if (conn->connected() == false) + continue; + + Crtc* crtc = conn->get_current_crtc(); + if (!crtc) { + vector list = conn->get_possible_crtcs(); + for (auto c : list) { + if (find(used_crtcs.begin(), used_crtcs.end(), c) == used_crtcs.end()) { + crtc = c; + break; + } + } + } + used_crtcs.push_back(crtc); + + ASSERT(crtc); + + int r; + + // RG16 XR24 UYVY YUYV NV12 + + auto mode = conn->get_default_mode(); + + auto fb = new Framebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); + draw_test_pattern(*fb); + fbs.push_back(fb); + + r = crtc->set_mode(conn, *fb, mode); + ASSERT(r == 0); + + + + Plane* plane = 0; + + for (Plane* p : crtc->get_possible_planes()) { + if (p->plane_type() == PlaneType::Overlay) { + plane = p; + break; + } + } + + if (plane) { + auto planefb = new Framebuffer(card, 400, 400, "YUYV"); + draw_test_pattern(*planefb); + fbs.push_back(planefb); + + r = crtc->set_plane(plane, *planefb, + 0, 0, planefb->width(), planefb->height(), + 0, 0, planefb->width(), planefb->height()); + + ASSERT(r == 0); + } + } + + printf("press enter to exit\n"); + + getchar(); + + for(auto fb : fbs) + delete fb; +} -- cgit v1.2.3