summaryrefslogtreecommitdiff
path: root/libkms++/plane.cpp
blob: afb9c780edcc79ee8e505dc894c7e24163e4b604 (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
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <cassert>
#include <xf86drm.h>
#include <xf86drmMode.h>

#include "kms++.h"

using namespace std;

namespace kms
{

struct PlanePriv
{
	drmModePlanePtr drm_plane;
};

Plane::Plane(Card &card, uint32_t id)
	:DrmObject(card, id, DRM_MODE_OBJECT_PLANE)
{
	m_priv = new PlanePriv();
	m_priv->drm_plane = drmModeGetPlane(this->card().fd(), this->id());
	assert(m_priv->drm_plane);
}

Plane::~Plane()
{
	drmModeFreePlane(m_priv->drm_plane);
	delete m_priv;
}

void Plane::print_short() const
{
	auto p = m_priv->drm_plane;

	printf("Plane %d, %d modes, %d,%d -> %dx%d\n", id(),
	       p->count_formats,
	       p->crtc_x, p->crtc_y, p->x, p->y);

	printf("\t");
	for (unsigned i = 0; i < p->count_formats; ++i) {
		uint32_t f = p->formats[i];
		printf("%c%c%c%c ",
		       (f >> 0) & 0xff,
		       (f >> 8) & 0xff,
		       (f >> 16) & 0xff,
		       (f >> 24) & 0xff);
	}
	printf("\n");
}

bool Plane::supports_crtc(Crtc* crtc) const
{
	return m_priv->drm_plane->possible_crtcs & (1 << crtc->idx());
}

PlaneType Plane::plane_type() const
{
	return (PlaneType)get_prop_value("type");
}
}