summaryrefslogtreecommitdiff
path: root/tests/kmsview.cpp
blob: cafd1606e4f0f61b7c9d2d949fe9bea8342274b6 (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
#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;
}