xref: /aosp_15_r20/external/libkmsxx/kms++/inc/kms++/dumbframebuffer.h (revision f0687c8a10b3e371dbe09214db6664e37c283cca)
1 #pragma once
2 
3 #include <array>
4 
5 #include "framebuffer.h"
6 #include "pixelformats.h"
7 
8 namespace kms
9 {
10 class DumbFramebuffer : public Framebuffer
11 {
12 public:
13 	DumbFramebuffer(Card& card, uint32_t width, uint32_t height, const std::string& fourcc);
14 	DumbFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format);
15 	~DumbFramebuffer() override;
16 
width()17 	uint32_t width() const override { return Framebuffer::width(); }
height()18 	uint32_t height() const override { return Framebuffer::height(); }
19 
format()20 	PixelFormat format() const override { return m_format; }
num_planes()21 	unsigned num_planes() const override { return m_num_planes; }
22 
handle(unsigned plane)23 	uint32_t handle(unsigned plane) const { return m_planes.at(plane).handle; }
stride(unsigned plane)24 	uint32_t stride(unsigned plane) const override { return m_planes.at(plane).stride; }
size(unsigned plane)25 	uint32_t size(unsigned plane) const override { return m_planes.at(plane).size; }
offset(unsigned plane)26 	uint32_t offset(unsigned plane) const override { return m_planes.at(plane).offset; }
27 	uint8_t* map(unsigned plane) override;
28 	int prime_fd(unsigned plane) override;
29 
30 private:
31 	struct FramebufferPlane {
32 		uint32_t handle;
33 		int prime_fd;
34 		uint32_t size;
35 		uint32_t stride;
36 		uint32_t offset;
37 		uint8_t* map;
38 	};
39 
40 	unsigned m_num_planes;
41 	std::array<FramebufferPlane, 4> m_planes;
42 
43 	PixelFormat m_format;
44 };
45 } // namespace kms
46