omapfb: add enum Flags for OmapFB
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 30 May 2017 10:56:28 +0000 (13:56 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 30 May 2017 11:22:00 +0000 (14:22 +0300)
kms++/inc/kms++/omap/omapframebuffer.h
kms++/src/omap/omapframebuffer.cpp
py/pykms/pykmsomap.cpp
py/tests/rottest.py

index dcaaa4fd9a97039680cc42354607e0712ef74440..02ac79f3b3dce85ba06c595f8b2c9df0c4eceefb 100644 (file)
@@ -12,8 +12,14 @@ class OmapCard;
 class OmapFramebuffer : public MappedFramebuffer
 {
 public:
-       OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, bool tiled = false);
-       OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool tiled = false);
+       enum Flags
+       {
+               None = 0,
+               Tiled = 1 << 0,
+       };
+
+       OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, Flags flags = Flags::None);
+       OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, Flags flags = Flags::None);
        virtual ~OmapFramebuffer();
 
        uint32_t width() const { return Framebuffer::width(); }
@@ -42,7 +48,7 @@ private:
                uint8_t* map;
        };
 
-       void Create(bool tiled);
+       void Create(Flags buffer_flags);
        void Destroy();
 
        unsigned m_num_planes;
index 9997933d85eff05aea5a78d7a1564e54d9adc4d0..4aa1cdb8703470bf03a875e8f08a8a0f272dab4d 100644 (file)
@@ -26,15 +26,15 @@ using namespace std;
 namespace kms
 {
 
-OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc, bool tiled)
-       : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc), tiled)
+OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc, Flags flags)
+       : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc), flags)
 {
 }
 
-OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool tiled)
+OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, Flags flags)
        :MappedFramebuffer(card, width, height), m_omap_card(card), m_format(format)
 {
-       Create(tiled);
+       Create(flags);
 }
 
 OmapFramebuffer::~OmapFramebuffer()
@@ -42,7 +42,7 @@ OmapFramebuffer::~OmapFramebuffer()
        Destroy();
 }
 
-void OmapFramebuffer::Create(bool tiled)
+void OmapFramebuffer::Create(Flags buffer_flags)
 {
        const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
 
@@ -58,7 +58,7 @@ void OmapFramebuffer::Create(bool tiled)
 
                uint32_t stride;
 
-               if (!tiled) {
+               if (!(buffer_flags & Flags::Tiled)) {
                        stride = width() * pi.bitspp / 8;
 
                        uint32_t size = stride * height() / pi.ysub;
index bad20fb0f3852c39ea25d3aeb7e82a7a70704fd3..20740929c48e1ddf7a1118ff034c7d23b7a339e4 100644 (file)
@@ -14,13 +14,22 @@ void init_pykmsomap(py::module &m)
                        .def(py::init<>())
                        ;
 
-       py::class_<OmapFramebuffer>(m, "OmapFramebuffer", py::base<MappedFramebuffer>())
-                       .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, bool>(),
+       py::class_<OmapFramebuffer> omapfb(m, "OmapFramebuffer", py::base<MappedFramebuffer>());
+
+       // XXX we should use py::arithmetic() here to support or and and operators, but it's not supported in the pybind11 we use
+       py::enum_<OmapFramebuffer::Flags>(omapfb, "Flags")
+                       .value("None", OmapFramebuffer::Flags::None)
+                       .value("Tiled", OmapFramebuffer::Flags::Tiled)
+                       .export_values()
+                       ;
+
+       omapfb
+                       .def(py::init<OmapCard&, uint32_t, uint32_t, const string&, OmapFramebuffer::Flags>(),
                             py::keep_alive<1, 2>(),    // Keep Card alive until this is destructed
-                            py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("tiled") = false)
-                       .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, bool>(),
+                            py::arg("card"), py::arg("width"), py::arg("height"), py::arg("fourcc"), py::arg("flags") = OmapFramebuffer::None)
+                       .def(py::init<OmapCard&, uint32_t, uint32_t, PixelFormat, OmapFramebuffer::Flags>(),
                             py::keep_alive<1, 2>(),    // Keep OmapCard alive until this is destructed
-                            py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("tiled") = false)
+                            py::arg("card"), py::arg("width"), py::arg("height"), py::arg("pixfmt"), py::arg("flags") = OmapFramebuffer::None)
                        .def_property_readonly("format", &OmapFramebuffer::format)
                        .def_property_readonly("num_planes", &OmapFramebuffer::num_planes)
                        .def("fd", &OmapFramebuffer::prime_fd)
index d81a962a61ffb95028913ccaaad5e72f0bb003cc..8988134122e45569c4a73efedaa8ced73c44f2a3 100755 (executable)
@@ -96,7 +96,7 @@ fb_h = 150
 x_scale = 1
 y_scale = 1
 
-fb = pykms.OmapFramebuffer(card, fb_w, fb_h, "NV12", tiled = True);
+fb = pykms.OmapFramebuffer(card, fb_w, fb_h, "NV12", flags = pykms.OmapFramebuffer.Tiled);
 #fb = pykms.DumbFramebuffer(card, fb_w, fb_h, "NV12")
 pykms.draw_test_pattern(fb);