summaryrefslogtreecommitdiff
path: root/kms++
diff options
context:
space:
mode:
Diffstat (limited to 'kms++')
-rw-r--r--kms++/CMakeLists.txt7
-rw-r--r--kms++/inc/kms++/omap/omapframebuffer.h5
-rw-r--r--kms++/src/omap/omapcard.cpp6
-rw-r--r--kms++/src/omap/omapframebuffer.cpp54
4 files changed, 30 insertions, 42 deletions
diff --git a/kms++/CMakeLists.txt b/kms++/CMakeLists.txt
index 10352a2..66b4286 100644
--- a/kms++/CMakeLists.txt
+++ b/kms++/CMakeLists.txt
@@ -1,13 +1,10 @@
include_directories(${LIBDRM_INCLUDE_DIRS})
link_directories(${LIBDRM_LIBRARY_DIRS})
-include_directories(${LIBDRM_OMAP_INCLUDE_DIRS})
-link_directories(${LIBDRM_OMAP_LIBRARY_DIRS})
-
file(GLOB SRCS "src/*.cpp" "src/*.h")
file(GLOB PUB_HDRS "inc/kms++/*.h")
-if(LIBDRM_OMAP_FOUND)
+if(HAVE_OMAP_DRM)
file(GLOB OMAP_SRCS "src/omap/*.cpp" "src/omap/*.h")
file(GLOB OMAP_PUB_HDRS "inc/kms++/omap/*.h")
@@ -22,7 +19,7 @@ target_include_directories(kms++ PUBLIC
$<INSTALL_INTERFACE:include>
PRIVATE src)
-target_link_libraries(kms++ ${LIBDRM_LIBRARIES} ${LIBDRM_OMAP_LIBRARIES})
+target_link_libraries(kms++ ${LIBDRM_LIBRARIES})
set_target_properties(kms++ PROPERTIES
PUBLIC_HEADER "${PUB_HDRS}")
diff --git a/kms++/inc/kms++/omap/omapframebuffer.h b/kms++/inc/kms++/omap/omapframebuffer.h
index 16d6cf8..9b628f4 100644
--- a/kms++/inc/kms++/omap/omapframebuffer.h
+++ b/kms++/inc/kms++/omap/omapframebuffer.h
@@ -3,8 +3,6 @@
#include <kms++/mappedframebuffer.h>
#include <kms++/pixelformats.h>
-struct omap_bo;
-
namespace kms
{
class OmapCard;
@@ -30,10 +28,7 @@ public:
int prime_fd(unsigned plane);
private:
- OmapCard& m_omap_card;
-
struct FramebufferPlane {
- struct omap_bo* omap_bo;
uint32_t handle;
int prime_fd;
uint32_t size;
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;
}
}