1 #pragma once 2 3 #include <kms++/framebuffer.h> 4 #include <kms++/pixelformats.h> 5 6 struct omap_bo; 7 8 namespace kms 9 { 10 class OmapCard; 11 12 class OmapFramebuffer : public Framebuffer 13 { 14 public: 15 enum Flags { 16 None = 0, 17 Tiled = 1 << 0, 18 MemContig = 1 << 1, 19 MemTiler = 1 << 2, 20 MemPin = 1 << 3, 21 }; 22 23 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, Flags flags = Flags::None); 24 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, Flags flags = Flags::None); 25 virtual ~OmapFramebuffer(); 26 width()27 uint32_t width() const { return Framebuffer::width(); } height()28 uint32_t height() const { return Framebuffer::height(); } 29 format()30 PixelFormat format() const { return m_format; } num_planes()31 unsigned num_planes() const { return m_num_planes; } 32 handle(unsigned plane)33 uint32_t handle(unsigned plane) const { return m_planes[plane].handle; } stride(unsigned plane)34 uint32_t stride(unsigned plane) const { return m_planes[plane].stride; } size(unsigned plane)35 uint32_t size(unsigned plane) const { return m_planes[plane].size; } offset(unsigned plane)36 uint32_t offset(unsigned plane) const { return m_planes[plane].offset; } 37 uint8_t* map(unsigned plane); 38 int prime_fd(unsigned plane); 39 40 private: 41 OmapCard& m_omap_card; 42 43 struct FramebufferPlane { 44 struct omap_bo* omap_bo; 45 uint32_t handle; 46 int prime_fd; 47 uint32_t size; 48 uint32_t stride; 49 uint32_t offset; 50 uint8_t* map; 51 }; 52 53 void Create(uint32_t width, uint32_t height, PixelFormat format, Flags buffer_flags); 54 void Destroy(); 55 56 unsigned m_num_planes; 57 struct FramebufferPlane m_planes[3]; 58 59 PixelFormat m_format; 60 }; 61 } // namespace kms 62