]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - libkms++/plane.cpp
TODO: add YUV bug
[android/external-libkmsxx.git] / libkms++ / plane.cpp
1 #include <stdio.h>
2 #include <iostream>
3 #include <unistd.h>
4 #include <fcntl.h>
5 #include <cassert>
6 #include <xf86drm.h>
7 #include <xf86drmMode.h>
9 #include "kms++.h"
11 using namespace std;
13 namespace kms
14 {
16 struct PlanePriv
17 {
18         drmModePlanePtr drm_plane;
19 };
21 Plane::Plane(Card &card, uint32_t id)
22         :DrmObject(card, id, DRM_MODE_OBJECT_PLANE)
23 {
24         m_priv = new PlanePriv();
25         m_priv->drm_plane = drmModeGetPlane(this->card().fd(), this->id());
26         assert(m_priv->drm_plane);
27 }
29 Plane::~Plane()
30 {
31         drmModeFreePlane(m_priv->drm_plane);
32         delete m_priv;
33 }
35 void Plane::print_short() const
36 {
37         auto p = m_priv->drm_plane;
39         printf("Plane %d, %d modes, %d,%d -> %dx%d\n", id(),
40                p->count_formats,
41                p->crtc_x, p->crtc_y, p->x, p->y);
43         printf("\t");
44         for (unsigned i = 0; i < p->count_formats; ++i) {
45                 uint32_t f = p->formats[i];
46                 printf("%c%c%c%c ",
47                        (f >> 0) & 0xff,
48                        (f >> 8) & 0xff,
49                        (f >> 16) & 0xff,
50                        (f >> 24) & 0xff);
51         }
52         printf("\n");
53 }
55 bool Plane::supports_crtc(Crtc* crtc) const
56 {
57         return m_priv->drm_plane->possible_crtcs & (1 << crtc->idx());
58 }
60 PlaneType Plane::plane_type() const
61 {
62         return (PlaneType)get_prop_value("type");
63 }
64 }