summaryrefslogtreecommitdiff
path: root/testpat/testpat.cpp
blob: 5632224617fa8690f8968918999c231b806e78d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <cstdio>
#include <algorithm>

#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<Framebuffer*> fbs;
	vector<Crtc*> used_crtcs;

	for (auto conn : connectors)
	{
		if (conn->connected() == false)
			continue;

		Crtc* crtc = conn->get_current_crtc();
		if (!crtc) {
			vector<Crtc*> 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;
}