diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-10-09 12:34:23 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-10-09 12:34:23 +0300 |
commit | a024a5f9131cc5de3b461ee3524f4dcb15f9f535 (patch) | |
tree | b52ea1b182c6e4774f550def23a226b1e226f8dd | |
parent | 3ea1d4ebea22a60e8e849897d88780e2eb0f6eb9 (diff) |
add kmsview
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/kmsview.cpp | 62 |
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a309bda..10b269f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,3 +7,5 @@ target_link_libraries(db kms++ kmstest ${LIBDRM_LIBRARIES}) add_executable (testpat testpat.cpp) target_link_libraries(testpat kms++ kmstest ${LIBDRM_LIBRARIES}) +add_executable (kmsview kmsview.cpp) +target_link_libraries(kmsview kms++ kmstest ${LIBDRM_LIBRARIES}) diff --git a/tests/kmsview.cpp b/tests/kmsview.cpp new file mode 100644 index 0000000..cafd160 --- /dev/null +++ b/tests/kmsview.cpp @@ -0,0 +1,62 @@ +#include <cstdio> +#include <fstream> + +#include "kms++.h" + +#include "test.h" + +using namespace std; +using namespace kms; + +int main(int argc, char** argv) +{ + if (argc != 5) { + printf("Usage: %s <file> <width> <height> <fourcc>\n", argv[0]); + return -1; + } + + string filename = argv[1]; + uint32_t w = stoi(argv[2]); + uint32_t h = stoi(argv[3]); + string modestr = argv[4]; + + auto pixfmt = FourCCToPixelFormat(modestr); + + Card card; + + auto conn = card.get_first_connected_connector(); + auto crtc = conn->get_current_crtc(); + + auto fb = new DumbFramebuffer(card, w, h, pixfmt); + + ifstream is(filename, ifstream::binary); + is.read((char*)fb->map(0), fb->size(0)); + is.close(); + + Plane* plane = 0; + + for (Plane* p : crtc->get_possible_planes()) { + if (p->plane_type() != PlaneType::Overlay) + continue; + + if (!p->supports_format(pixfmt)) + continue; + + plane = p; + break; + } + + FAIL_IF(!plane, "available plane not found"); + + int r = crtc->set_plane(plane, *fb, + 0, 0, w, h, + 0, 0, w, h); + + ASSERT(r == 0); + + printf("press enter to exit\n"); + + getchar(); + + delete fb; +} |