Add support for YVYU and VYUY
[android/external-libkmsxx.git] / tests / testpat.cpp
1 #include <cstdio>
2 #include <algorithm>
4 #include "kms++.h"
6 #include "test.h"
8 using namespace std;
9 using namespace kms;
11 int main()
12 {
13         Card card;
15         if (card.master() == false)
16                 printf("Not DRM master, modeset may fail\n");
18         //card.print_short();
20         auto pipes = card.get_connected_pipelines();
22         vector<Framebuffer*> fbs;
24         for (auto pipe : pipes)
25         {
26                 auto conn = pipe.connector;
27                 auto crtc = pipe.crtc;
29                 // RG16 XR24 UYVY YUYV NV12
31                 auto mode = conn->get_default_mode();
33                 auto fb = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, PixelFormat::XRGB8888);
34                 draw_test_pattern(*fb);
35                 fbs.push_back(fb);
37                 printf("conn %u, crtc %u, fb %u\n", conn->id(), crtc->id(), fb->id());
39                 int r = crtc->set_mode(conn, *fb, mode);
40                 ASSERT(r == 0);
41         }
43         for (auto pipe: pipes)
44         {
45                 auto crtc = pipe.crtc;
47                 Plane* plane = 0;
49                 for (Plane* p : crtc->get_possible_planes()) {
50                         if (p->plane_type() == PlaneType::Overlay) {
51                                 plane = p;
52                                 break;
53                         }
54                 }
56                 if (plane) {
57                         auto planefb = new DumbFramebuffer(card, 400, 400, PixelFormat::YUYV);
58                         draw_test_pattern(*planefb);
59                         fbs.push_back(planefb);
61                         int r = crtc->set_plane(plane, *planefb,
62                                             0, 0, planefb->width(), planefb->height(),
63                                             0, 0, planefb->width(), planefb->height());
65                         ASSERT(r == 0);
66                 }
67         }
69         printf("press enter to exit\n");
71         getchar();
73         for(auto fb : fbs)
74                 delete fb;
75 }