summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6642f7c)
raw | patch | inline | side by side (parent: 6642f7c)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Sat, 31 Oct 2015 10:40:00 +0000 (12:40 +0200) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Fri, 13 Nov 2015 15:55:48 +0000 (17:55 +0200) |
libkms++/dumbframebuffer.cpp | patch | blob | history | |
libkms++/dumbframebuffer.h | patch | blob | history | |
libkmstest/conv.cpp | patch | blob | history |
index 46a6e5a5460f369eca350d8b8bd7a06d5756f5f9..730d2976d95a59210b6f9eb88682fdbcc33a4002 100644 (file)
plane.stride = creq.pitch;
plane.size = creq.height * creq.pitch;
plane.offset = 0;
-
- /*
- printf("buf %d: %dx%d, bitspp %d, stride %d, size %d\n",
- i, creq.width, creq.height, pi->bitspp, plane->stride, plane->size);
- */
-
- /* prepare buffer for memory mapping */
- struct drm_mode_map_dumb mreq = drm_mode_map_dumb();
- mreq.handle = plane.handle;
- r = drmIoctl(card().fd(), DRM_IOCTL_MODE_MAP_DUMB, &mreq);
- if (r)
- throw invalid_argument(string("DRM_IOCTL_MODE_MAP_DUMB failed") + strerror(errno));
-
- /* perform actual memory mapping */
- m_planes[i].map = (uint8_t *)mmap(0, plane.size, PROT_READ | PROT_WRITE, MAP_SHARED,
- card().fd(), mreq.offset);
- if (plane.map == MAP_FAILED)
- throw invalid_argument(string("mmap failed: ") + strerror(errno));
-
- /* clear the framebuffer to 0 */
- memset(plane.map, 0, plane.size);
-
+ plane.map = 0;
plane.prime_fd = -1;
}
}
}
-void DumbFramebuffer::clear()
+uint8_t* DumbFramebuffer::map(unsigned plane)
{
- for (unsigned i = 0; i < m_num_planes; ++i)
- memset(m_planes[i].map, 0, m_planes[i].size);
+ FramebufferPlane& p = m_planes[plane];
+
+ if (p.map)
+ return p.map;
+
+ /* prepare buffer for memory mapping */
+ struct drm_mode_map_dumb mreq = drm_mode_map_dumb();
+ mreq.handle = p.handle;
+ int r = drmIoctl(card().fd(), DRM_IOCTL_MODE_MAP_DUMB, &mreq);
+ if (r)
+ throw invalid_argument(string("DRM_IOCTL_MODE_MAP_DUMB failed") + strerror(errno));
+
+ /* perform actual memory mapping */
+ 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));
+
+ return p.map;
}
}
index 51f51237786739fa5c4076b0e4455f25413ef3e3..c221421a9971a83f460cdfa5345eff3c3785970f 100644 (file)
unsigned num_planes() const { return m_num_planes; }
uint32_t handle(unsigned plane) const { return m_planes[plane].handle; }
- uint8_t* map(unsigned plane) const { return m_planes[plane].map; }
uint32_t stride(unsigned plane) const { return m_planes[plane].stride; }
uint32_t size(unsigned plane) const { return m_planes[plane].size; }
uint32_t offset(unsigned plane) const { return m_planes[plane].offset; }
+ uint8_t* map(unsigned plane);
uint32_t prime_fd(unsigned plane);
- void clear();
-
private:
struct FramebufferPlane {
uint32_t handle;
diff --git a/libkmstest/conv.cpp b/libkmstest/conv.cpp
index 45f4a757de7928caa2d6ed016f1f66cfe71eb7b4..cd5f8d6006c905e7a30dd8d6ab61321eb92be4e7 100644 (file)
--- a/libkmstest/conv.cpp
+++ b/libkmstest/conv.cpp
namespace kms
{
-static RGB read_rgb(const DumbFramebuffer& fb, int x, int y)
+static RGB read_rgb(DumbFramebuffer& fb, int x, int y)
{
uint32_t *pc = (uint32_t *)(fb.map(0) + fb.stride(0) * y);
return RGB((c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
}
-static YUV read_rgb_as_yuv(const DumbFramebuffer& fb, int x, int y)
+static YUV read_rgb_as_yuv(DumbFramebuffer& fb, int x, int y)
{
RGB rgb = read_rgb(fb, x, y);
return YUV(rgb);
}
-static void fb_rgb_to_packed_yuv(DumbFramebuffer& dst_fb, const DumbFramebuffer& src_fb)
+static void fb_rgb_to_packed_yuv(DumbFramebuffer& dst_fb, DumbFramebuffer& src_fb)
{
unsigned w = src_fb.width();
unsigned h = src_fb.height();
}
}
-static void fb_rgb_to_semiplanar_yuv(DumbFramebuffer& dst_fb, const DumbFramebuffer& src_fb)
+static void fb_rgb_to_semiplanar_yuv(DumbFramebuffer& dst_fb, DumbFramebuffer& src_fb)
{
unsigned w = src_fb.width();
unsigned h = src_fb.height();
}
}
-static void fb_rgb_to_rgb565(DumbFramebuffer& dst_fb, const DumbFramebuffer& src_fb)
+static void fb_rgb_to_rgb565(DumbFramebuffer& dst_fb, DumbFramebuffer& src_fb)
{
unsigned w = src_fb.width();
unsigned h = src_fb.height();
@@ -113,7 +113,7 @@ static void fb_rgb_to_rgb565(DumbFramebuffer& dst_fb, const DumbFramebuffer& src
}
}
-void color_convert(DumbFramebuffer& dst, const DumbFramebuffer &src)
+void color_convert(DumbFramebuffer& dst, DumbFramebuffer &src)
{
switch (dst.format()) {
case PixelFormat::NV12: