summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2016-12-08 01:44:33 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-04-16 19:12:43 +0300
commitf3a478951ac576c69a5828d80ff23d02e0940b9e (patch)
tree9341af022ea38c2f19100eb59e3243f0f9380424
parent5610b6440617246972105a93ca6a35c9ed045db4 (diff)
omap: Add support for cached GEM objects
OMAP buffers are mapped to userspace in write-combining mode by default. Add support for cached mappings. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--kms++/inc/kms++/omap/omapframebuffer.h6
-rw-r--r--kms++/src/omap/omapframebuffer.cpp13
-rw-r--r--py/pykms/pykmsomap.cpp4
3 files changed, 12 insertions, 11 deletions
diff --git a/kms++/inc/kms++/omap/omapframebuffer.h b/kms++/inc/kms++/omap/omapframebuffer.h
index 9b628f4..d23e5ba 100644
--- a/kms++/inc/kms++/omap/omapframebuffer.h
+++ b/kms++/inc/kms++/omap/omapframebuffer.h
@@ -10,8 +10,8 @@ class OmapCard;
class OmapFramebuffer : public MappedFramebuffer
{
public:
- OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc);
- OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format);
+ OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, bool cached = false);
+ OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool cached = false);
virtual ~OmapFramebuffer();
uint32_t width() const { return Framebuffer::width(); }
@@ -37,7 +37,7 @@ private:
uint8_t* map;
};
- void Create();
+ void Create(bool cached);
void Destroy();
unsigned m_num_planes;
diff --git a/kms++/src/omap/omapframebuffer.cpp b/kms++/src/omap/omapframebuffer.cpp
index 312552c..0c8489e 100644
--- a/kms++/src/omap/omapframebuffer.cpp
+++ b/kms++/src/omap/omapframebuffer.cpp
@@ -19,15 +19,15 @@ using namespace std;
namespace kms
{
-OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc)
- : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc))
+OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc, bool cached)
+ : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc), cached)
{
}
-OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format)
+OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool cached)
: MappedFramebuffer(card, width, height), m_format(format)
{
- Create();
+ Create(cached);
}
OmapFramebuffer::~OmapFramebuffer()
@@ -35,7 +35,7 @@ OmapFramebuffer::~OmapFramebuffer()
Destroy();
}
-void OmapFramebuffer::Create()
+void OmapFramebuffer::Create(bool cached)
{
const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
@@ -49,8 +49,9 @@ void OmapFramebuffer::Create()
uint32_t size = stride * height();
struct drm_omap_gem_new creq = {
.size = { .bytes = size },
- .flags = OMAP_BO_SCANOUT | OMAP_BO_WC,
};
+ creq.flags = (cached ? OMAP_BO_CACHED : OMAP_BO_WC)
+ | OMAP_BO_SCANOUT;
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));
diff --git a/py/pykms/pykmsomap.cpp b/py/pykms/pykmsomap.cpp
index a749f76..0b27e51 100644
--- a/py/pykms/pykmsomap.cpp
+++ b/py/pykms/pykmsomap.cpp
@@ -15,9 +15,9 @@ void init_pykmsomap(py::module &m)
;
py::class_<OmapFramebuffer>(m, "OmapFramebuffer", py::base<MappedFramebuffer>())
- .def(py::init<OmapCard&, uint32_t, uint32_t, const string&>(),
+ .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, bool>(),
py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
- .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat>(),
+ .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, bool>(),
py::keep_alive<1, 2>()) // Keep OmapCard alive until this is destructed
;
}