summaryrefslogtreecommitdiff
path: root/kms++/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2016-12-08 01:11:44 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-04-16 19:12:43 +0300
commit5610b6440617246972105a93ca6a35c9ed045db4 (patch)
tree0459a58382ce3addd3e25b2c7b158a87c17b635a /kms++/src
parent9847712d62ab55c5aff4abaf92c9093566b50cd1 (diff)
Remove libdrm_omap dependency
The library is just a wrapper around ioctls. It doesn't provide much value, and its API is marked as experimental and should thus not be expected to be stable. As third party library dependencies are always painful for distributors and packagers, use the ioctls directly for now. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'kms++/src')
-rw-r--r--kms++/src/omap/omapcard.cpp6
-rw-r--r--kms++/src/omap/omapframebuffer.cpp54
2 files changed, 28 insertions, 32 deletions
diff --git a/kms++/src/omap/omapcard.cpp b/kms++/src/omap/omapcard.cpp
index e811b6d..7b78cde 100644
--- a/kms++/src/omap/omapcard.cpp
+++ b/kms++/src/omap/omapcard.cpp
@@ -1,10 +1,6 @@
#include <kms++/omap/omapcard.h>
-extern "C" {
-#include <omap_drmif.h>
-}
-
using namespace std;
namespace kms
@@ -18,12 +14,10 @@ OmapCard::OmapCard()
OmapCard::OmapCard(const string& device)
: Card(device)
{
- m_omap_dev = omap_device_new(fd());
}
OmapCard::~OmapCard()
{
- omap_device_del(m_omap_dev);
}
}
diff --git a/kms++/src/omap/omapframebuffer.cpp b/kms++/src/omap/omapframebuffer.cpp
index e1e2234..312552c 100644
--- a/kms++/src/omap/omapframebuffer.cpp
+++ b/kms++/src/omap/omapframebuffer.cpp
@@ -9,14 +9,11 @@
#include <drm_fourcc.h>
#include <drm.h>
#include <drm_mode.h>
+#include <drm/omap_drm.h>
#include <kms++/kms++.h>
#include <kms++/omap/omapkms++.h>
-extern "C" {
-#include <omap_drmif.h>
-}
-
using namespace std;
namespace kms
@@ -28,7 +25,7 @@ OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height
}
OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format)
- : MappedFramebuffer(card, width, height), m_omap_card(card), m_format(format)
+ : MappedFramebuffer(card, width, height), m_format(format)
{
Create();
}
@@ -48,20 +45,19 @@ void OmapFramebuffer::Create()
const PixelFormatPlaneInfo& pi = format_info.planes[i];
FramebufferPlane& plane = m_planes[i];
- uint32_t flags = OMAP_BO_SCANOUT | OMAP_BO_WC;
-
- uint32_t size = width() * height() * pi.bitspp / 8;
-
- struct omap_bo* bo = omap_bo_new(m_omap_card.dev(), size, flags);
- if (!bo)
- throw invalid_argument(string("omap_bo_new failed: ") + strerror(errno));
-
- uint32_t stride = width() * pi.bitspp / 8;
-
- plane.omap_bo = bo;
- plane.handle = omap_bo_handle(bo);
+ uint32_t stride = (width() * pi.bitspp + 7) / 8;
+ uint32_t size = stride * height();
+ struct drm_omap_gem_new creq = {
+ .size = { .bytes = size },
+ .flags = OMAP_BO_SCANOUT | OMAP_BO_WC,
+ };
+ int r = drmIoctl(card().fd(), DRM_IOCTL_OMAP_GEM_NEW, &creq);
+ if (r)
+ throw invalid_argument(string("DRM_IOCTL_OMAP_GEM_NEW failed: ") + strerror(errno));
+
+ plane.handle = creq.handle;
plane.stride = stride;
- plane.size = omap_bo_size(bo);
+ plane.size = size;
plane.offset = 0;
plane.map = 0;
plane.prime_fd = -1;
@@ -91,7 +87,8 @@ void OmapFramebuffer::Destroy()
if (plane.map)
munmap(plane.map, plane.size);
- omap_bo_del(plane.omap_bo);
+ struct drm_gem_close dreq = { .handle = plane.handle };
+ drmIoctl(card().fd(), DRM_IOCTL_GEM_CLOSE, &dreq);
if (plane.prime_fd >= 0)
::close(plane.prime_fd);
@@ -105,7 +102,13 @@ uint8_t* OmapFramebuffer::map(unsigned plane)
if (p.map)
return p.map;
- p.map = (uint8_t*)omap_bo_map(p.omap_bo);
+ struct drm_omap_gem_info mreq = { .handle = p.handle };
+ int r = drmIoctl(card().fd(), DRM_IOCTL_OMAP_GEM_INFO, &mreq);
+ if (r)
+ throw invalid_argument(string("DRM_IOCTL_OMAP_GEM_INFO failed: ") + strerror(errno));
+
+ p.map = (uint8_t *)mmap(0, p.size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ card().fd(), mreq.offset);
if (p.map == MAP_FAILED)
throw invalid_argument(string("mmap failed: ") + strerror(errno));
@@ -119,13 +122,12 @@ int OmapFramebuffer::prime_fd(unsigned int plane)
if (p.prime_fd >= 0)
return p.prime_fd;
- int fd = omap_bo_dmabuf(p.omap_bo);
- if (fd < 0)
- throw std::runtime_error("omap_bo_dmabuf failed\n");
-
- p.prime_fd = fd;
+ int r = drmPrimeHandleToFD(card().fd(), p.handle, DRM_CLOEXEC | O_RDWR,
+ &p.prime_fd);
+ if (r)
+ throw std::runtime_error("drmPrimeHandleToFD failed");
- return fd;
+ return p.prime_fd;
}
}