aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-05-30 05:56:28 -0500
committerTomi Valkeinen2017-05-30 06:22:00 -0500
commit2d86678f0a78abf67cdef6be375f7d787c4f017d (patch)
treedb8602f4f75448706155145b5345dc3009d9fa23
parentaf3f9890cc3927d92de4048bc238d62866784a35 (diff)
downloadexternal-kmsxx-2d86678f0a78abf67cdef6be375f7d787c4f017d.tar.gz
external-kmsxx-2d86678f0a78abf67cdef6be375f7d787c4f017d.tar.xz
external-kmsxx-2d86678f0a78abf67cdef6be375f7d787c4f017d.zip
omapfb: add enum Flags for OmapFB
-rw-r--r--kms++/inc/kms++/omap/omapframebuffer.h12
-rw-r--r--kms++/src/omap/omapframebuffer.cpp12
-rw-r--r--py/pykms/pykmsomap.cpp19
-rwxr-xr-xpy/tests/rottest.py2
4 files changed, 30 insertions, 15 deletions
diff --git a/kms++/inc/kms++/omap/omapframebuffer.h b/kms++/inc/kms++/omap/omapframebuffer.h
index dcaaa4f..02ac79f 100644
--- a/kms++/inc/kms++/omap/omapframebuffer.h
+++ b/kms++/inc/kms++/omap/omapframebuffer.h
@@ -12,8 +12,14 @@ class OmapCard;
12class OmapFramebuffer : public MappedFramebuffer 12class OmapFramebuffer : public MappedFramebuffer
13{ 13{
14public: 14public:
15 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, bool tiled = false); 15 enum Flags
16 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool tiled = false); 16 {
17 None = 0,
18 Tiled = 1 << 0,
19 };
20
21 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, Flags flags = Flags::None);
22 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, Flags flags = Flags::None);
17 virtual ~OmapFramebuffer(); 23 virtual ~OmapFramebuffer();
18 24
19 uint32_t width() const { return Framebuffer::width(); } 25 uint32_t width() const { return Framebuffer::width(); }
@@ -42,7 +48,7 @@ private:
42 uint8_t* map; 48 uint8_t* map;
43 }; 49 };
44 50
45 void Create(bool tiled); 51 void Create(Flags buffer_flags);
46 void Destroy(); 52 void Destroy();
47 53
48 unsigned m_num_planes; 54 unsigned m_num_planes;
diff --git a/kms++/src/omap/omapframebuffer.cpp b/kms++/src/omap/omapframebuffer.cpp
index 9997933..4aa1cdb 100644
--- a/kms++/src/omap/omapframebuffer.cpp
+++ b/kms++/src/omap/omapframebuffer.cpp
@@ -26,15 +26,15 @@ using namespace std;
26namespace kms 26namespace kms
27{ 27{
28 28
29OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc, bool tiled) 29OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc, Flags flags)
30 : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc), tiled) 30 : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc), flags)
31{ 31{
32} 32}
33 33
34OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool tiled) 34OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, Flags flags)
35 :MappedFramebuffer(card, width, height), m_omap_card(card), m_format(format) 35 :MappedFramebuffer(card, width, height), m_omap_card(card), m_format(format)
36{ 36{
37 Create(tiled); 37 Create(flags);
38} 38}
39 39
40OmapFramebuffer::~OmapFramebuffer() 40OmapFramebuffer::~OmapFramebuffer()
@@ -42,7 +42,7 @@ OmapFramebuffer::~OmapFramebuffer()
42 Destroy(); 42 Destroy();
43} 43}
44 44
45void OmapFramebuffer::Create(bool tiled) 45void OmapFramebuffer::Create(Flags buffer_flags)
46{ 46{
47 const PixelFormatInfo& format_info = get_pixel_format_info(m_format); 47 const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
48 48
@@ -58,7 +58,7 @@ void OmapFramebuffer::Create(bool tiled)
58 58
59 uint32_t stride; 59 uint32_t stride;
60 60
61 if (!tiled) { 61 if (!(buffer_flags & Flags::Tiled)) {
62 stride = width() * pi.bitspp / 8; 62 stride = width() * pi.bitspp / 8;
63 63
64 uint32_t size = stride * height() / pi.ysub; 64 uint32_t size = stride * height() / pi.ysub;
diff --git a/py/pykms/pykmsomap.cpp b/py/pykms/pykmsomap.cpp
index bad20fb..2074092 100644
--- a/py/pykms/pykmsomap.cpp
+++ b/py/pykms/pykmsomap.cpp
@@ -14,13 +14,22 @@ void init_pykmsomap(py::module &m)
14 .def(py::init<>()) 14 .def(py::init<>())
15 ; 15 ;
16 16
17 py::class_<OmapFramebuffer>(m, "OmapFramebuffer", py::base<MappedFramebuffer>()) 17 py::class_<OmapFramebuffer> omapfb(m, "OmapFramebuffer", py::base<MappedFramebuffer>());
18 .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, bool>(), 18
19 // XXX we should use py::arithmetic() here to support or and and operators, but it's not supported in the pybind11 we use
20 py::enum_<OmapFramebuffer::Flags>(omapfb, "Flags")
21 .value("None", OmapFramebuffer::Flags::None)
22 .value("Tiled", OmapFramebuffer::Flags::Tiled)
23 .export_values()
24 ;
25
26 omapfb
27 .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
19 py::keep_alive<1, 2>(), // Keep Card alive until this is destructed 28 py::keep_alive<1, 2>(), // Keep Card alive until this is destructed
20 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("tiled") = false) 29 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
21 .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, bool>(), 30 .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
22 py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed 31 py::keep_alive<1, 2>(), // Keep OmapCard alive until this is destructed
23 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("tiled") = false) 32 py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
24 .def_property_readonly("format", &OmapFramebuffer::format) 33 .def_property_readonly("format", &OmapFramebuffer::format)
25 .def_property_readonly("num_planes", &OmapFramebuffer::num_planes) 34 .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
26 .def("fd", &OmapFramebuffer::prime_fd) 35 .def("fd", &OmapFramebuffer::prime_fd)
diff --git a/py/tests/rottest.py b/py/tests/rottest.py
index d81a962..8988134 100755
--- a/py/tests/rottest.py
+++ b/py/tests/rottest.py
@@ -96,7 +96,7 @@ fb_h = 150
96x_scale = 1 96x_scale = 1
97y_scale = 1 97y_scale = 1
98 98
99fb = pykms.OmapFramebuffer(card, fb_w, fb_h, "NV12", tiled = True); 99fb = pykms.OmapFramebuffer(card, fb_w, fb_h, "NV12", flags = pykms.OmapFramebuffer.Tiled);
100#fb = pykms.DumbFramebuffer(card, fb_w, fb_h, "NV12") 100#fb = pykms.DumbFramebuffer(card, fb_w, fb_h, "NV12")
101pykms.draw_test_pattern(fb); 101pykms.draw_test_pattern(fb);
102 102