summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 83d27aa)
raw | patch | inline | side by side (parent: 83d27aa)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Wed, 16 Mar 2016 10:18:12 +0000 (12:18 +0200) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Wed, 16 Mar 2016 10:18:12 +0000 (12:18 +0200) |
libkms++/dumbframebuffer.cpp | patch | blob | history | |
libkms++/pixelformats.cpp | [new file with mode: 0644] | patch | blob |
libkms++/pixelformats.h | patch | blob | history | |
libkmstest/cpuframebuffer.cpp | patch | blob | history |
index 4fae49ebc0045bac6cfc08f85d7c9c791ec9194c..0a05e61b6499d126d143c5f0ede1ac7b5057cc61 100644 (file)
Destroy();
}
-struct FormatPlaneInfo
-{
- uint8_t bitspp; /* bits per (macro) pixel */
- uint8_t xsub;
- uint8_t ysub;
-};
-
-struct FormatInfo
-{
- uint8_t num_planes;
- struct FormatPlaneInfo planes[4];
-};
-
-static const map<PixelFormat, FormatInfo> format_info_array = {
- /* YUV packed */
- { PixelFormat::UYVY, { 1, { { 32, 2, 1 } }, } },
- { PixelFormat::YUYV, { 1, { { 32, 2, 1 } }, } },
- { PixelFormat::YVYU, { 1, { { 32, 2, 1 } }, } },
- { PixelFormat::VYUY, { 1, { { 32, 2, 1 } }, } },
- /* YUV semi-planar */
- { PixelFormat::NV12, { 2, { { 8, 1, 1, }, { 16, 2, 2 } }, } },
- { PixelFormat::NV21, { 2, { { 8, 1, 1, }, { 16, 2, 2 } }, } },
- /* RGB16 */
- { PixelFormat::RGB565, { 1, { { 16, 1, 1 } }, } },
- /* RGB32 */
- { PixelFormat::XRGB8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::XBGR8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ARGB8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ABGR8888, { 1, { { 32, 1, 1 } }, } },
-};
-
void DumbFramebuffer::Create()
{
int r;
- const FormatInfo& format_info = format_info_array.at(m_format);
+ const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
m_num_planes = format_info.num_planes;
for (int i = 0; i < format_info.num_planes; ++i) {
- const FormatPlaneInfo& pi = format_info.planes[i];
+ const PixelFormatPlaneInfo& pi = format_info.planes[i];
FramebufferPlane& plane = m_planes[i];
/* create dumb buffer */
struct drm_mode_create_dumb creq = drm_mode_create_dumb();
creq.width = width();
creq.height = height() / pi.ysub;
- creq.bpp = pi.bitspp / pi.xsub;
+ creq.bpp = pi.bitspp;
r = drmIoctl(card().fd(), DRM_IOCTL_MODE_CREATE_DUMB, &creq);
if (r)
throw invalid_argument(string("DRM_IOCTL_MODE_CREATE_DUMB failed") + strerror(errno));
diff --git a/libkms++/pixelformats.cpp b/libkms++/pixelformats.cpp
--- /dev/null
@@ -0,0 +1,32 @@
+#include <map>
+
+#include "pixelformats.h"
+
+using namespace std;
+
+namespace kms
+{
+static const map<PixelFormat, PixelFormatInfo> format_info_array = {
+ /* YUV packed */
+ { PixelFormat::UYVY, { 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::YUYV, { 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::YVYU, { 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::VYUY, { 1, { { 16, 2, 1 } }, } },
+ /* YUV semi-planar */
+ { PixelFormat::NV12, { 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
+ { PixelFormat::NV21, { 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
+ /* RGB16 */
+ { PixelFormat::RGB565, { 1, { { 16, 1, 1 } }, } },
+ /* RGB32 */
+ { PixelFormat::XRGB8888, { 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::XBGR8888, { 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::ARGB8888, { 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::ABGR8888, { 1, { { 32, 1, 1 } }, } },
+};
+
+const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format)
+{
+ return format_info_array.at(format);
+}
+
+}
index d6f41d7a090d33b56ba92ec7cb3a211778ded364..813eaef7dbef45f4918d381e635733246d87e149 100644 (file)
--- a/libkms++/pixelformats.h
+++ b/libkms++/pixelformats.h
#pragma once
+#include <cstdint>
+#include <string>
+
namespace kms
{
constexpr uint32_t MakeFourCC(const char *fourcc)
return std::string(buf);
}
+struct PixelFormatPlaneInfo
+{
+ uint8_t bitspp;
+ uint8_t xsub;
+ uint8_t ysub;
+};
+
+struct PixelFormatInfo
+{
+ uint8_t num_planes;
+ struct PixelFormatPlaneInfo planes[4];
+};
+
+const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format);
+
}
index 3a9e52de2791ba3a3e8a70d0707b0c69ad02592e..1f14ddc92502c49071c8e48d7445fdfa20118d3f 100644 (file)
namespace kms {
-struct FormatPlaneInfo
-{
- uint8_t bitspp; /* bits per (macro) pixel */
- uint8_t xsub;
- uint8_t ysub;
-};
-
-struct FormatInfo
-{
- uint8_t num_planes;
- struct FormatPlaneInfo planes[4];
-};
-
-static const map<PixelFormat, FormatInfo> format_info_array = {
- /* YUV packed */
- { PixelFormat::UYVY, { 1, { { 32, 2, 1 } }, } },
- { PixelFormat::YUYV, { 1, { { 32, 2, 1 } }, } },
- { PixelFormat::YVYU, { 1, { { 32, 2, 1 } }, } },
- { PixelFormat::VYUY, { 1, { { 32, 2, 1 } }, } },
- /* YUV semi-planar */
- { PixelFormat::NV12, { 2, { { 8, 1, 1, }, { 16, 2, 2 } }, } },
- { PixelFormat::NV21, { 2, { { 8, 1, 1, }, { 16, 2, 2 } }, } },
- /* RGB16 */
- { PixelFormat::RGB565, { 1, { { 16, 1, 1 } }, } },
- /* RGB32 */
- { PixelFormat::XRGB8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::XBGR8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ARGB8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ABGR8888, { 1, { { 32, 1, 1 } }, } },
-};
-
CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format)
: m_width(width), m_height(height), m_format(format)
{
- const FormatInfo& format_info = format_info_array.at(m_format);
+ const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
m_num_planes = format_info.num_planes;
for (unsigned i = 0; i < format_info.num_planes; ++i) {
- const FormatPlaneInfo& pi = format_info.planes[i];
+ const PixelFormatPlaneInfo& pi = format_info.planes[i];
FramebufferPlane& plane = m_planes[i];
- plane.stride = width * pi.bitspp / 8 / pi.xsub;
+ plane.stride = width * pi.bitspp / 8;
plane.size = plane.stride * height/ pi.ysub;
plane.offset = 0;
plane.map = new uint8_t[plane.size];