]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - libkms++/plane.cpp
libkms: fix Connector::get_default_mode when no modes
[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 bool Plane::supports_crtc(Crtc* crtc) const
36 {
37         return m_priv->drm_plane->possible_crtcs & (1 << crtc->idx());
38 }
40 bool Plane::supports_format(PixelFormat fmt) const
41 {
42         auto p = m_priv->drm_plane;
44         for (unsigned i = 0; i < p->count_formats; ++i)
45                 if ((uint32_t)fmt == p->formats[i])
46                         return true;
48         return false;
49 }
51 PlaneType Plane::plane_type() const
52 {
53         if (card().has_has_universal_planes())
54                 return (PlaneType)get_prop_value("type");
55         else
56                 return PlaneType::Overlay;
57 }
59 vector<PixelFormat> Plane::get_formats() const
60 {
61         auto p = m_priv->drm_plane;
62         vector<PixelFormat> r;
64         for (unsigned i = 0; i < p->count_formats; ++i)
65                 r.push_back((PixelFormat) p->formats[i]);
67         return r;
68 }
70 uint32_t Plane::crtc_id() const
71 {
72         return m_priv->drm_plane->crtc_id;
73 }
75 uint32_t Plane::fb_id() const
76 {
77         return m_priv->drm_plane->fb_id;
78 }
80 uint32_t Plane::crtc_x() const
81 {
82         return m_priv->drm_plane->crtc_x;
83 }
85 uint32_t Plane::crtc_y() const
86 {
87         return m_priv->drm_plane->crtc_y;
88 }
90 uint32_t Plane::x() const
91 {
92         return m_priv->drm_plane->x;
93 }
95 uint32_t Plane::y() const
96 {
97         return m_priv->drm_plane->y;
98 }
100 uint32_t Plane::gamma_size() const
102         return m_priv->drm_plane->gamma_size;