]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - tests/testpat.cpp
99804076dfc00bdf1ed89e7ddda9477dd58a7236
[android/external-libkmsxx.git] / tests / testpat.cpp
1 #include <cstdio>
2 #include <algorithm>
4 #include "kms++.h"
5 #include "utils/testpat.h"
7 #include "test.h"
9 using namespace std;
10 using namespace kms;
12 int main()
13 {
14         Card card;
16         if (card.master() == false)
17                 printf("Not DRM master, modeset may fail\n");
19         //card.print_short();
21         auto pipes = card.get_connected_pipelines();
23         vector<Framebuffer*> fbs;
25         for (auto pipe : pipes)
26         {
27                 auto conn = pipe.connector;
28                 auto crtc = pipe.crtc;
30                 // RG16 XR24 UYVY YUYV NV12
32                 auto mode = conn->get_default_mode();
34                 auto fb = new Framebuffer(card, mode.hdisplay, mode.vdisplay, "XR24");
35                 draw_test_pattern(*fb);
36                 fbs.push_back(fb);
38                 printf("conn %u, crtc %u, fb %u\n", conn->id(), crtc->id(), fb->id());
40                 int r = crtc->set_mode(conn, *fb, mode);
41                 ASSERT(r == 0);
42         }
44         for (auto pipe: pipes)
45         {
46                 auto crtc = pipe.crtc;
48                 Plane* plane = 0;
50                 for (Plane* p : crtc->get_possible_planes()) {
51                         if (p->plane_type() == PlaneType::Overlay) {
52                                 plane = p;
53                                 break;
54                         }
55                 }
57                 if (plane) {
58                         auto planefb = new Framebuffer(card, 400, 400, "YUYV");
59                         draw_test_pattern(*planefb);
60                         fbs.push_back(planefb);
62                         int r = crtc->set_plane(plane, *planefb,
63                                             0, 0, planefb->width(), planefb->height(),
64                                             0, 0, planefb->width(), planefb->height());
66                         ASSERT(r == 0);
67                 }
68         }
70         printf("press enter to exit\n");
72         getchar();
74         for(auto fb : fbs)
75                 delete fb;
76 }