aboutsummaryrefslogtreecommitdiffstats
path: root/kms++
diff options
context:
space:
mode:
authorTomi Valkeinen2017-05-18 05:21:07 -0500
committerTomi Valkeinen2017-05-24 05:23:07 -0500
commit513766368980cda9adc613f690550cc42dfc85c0 (patch)
tree553c0f8d878166e0662e4a6f3c73850d5a1b4a0e /kms++
parent2602a5d27444423595764556947218a8a23129ac (diff)
downloadexternal-libkmsxx-513766368980cda9adc613f690550cc42dfc85c0.tar.gz
external-libkmsxx-513766368980cda9adc613f690550cc42dfc85c0.tar.xz
external-libkmsxx-513766368980cda9adc613f690550cc42dfc85c0.zip
omapfb: add TILER support
Add TILER rotation support for omapframebuffer. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'kms++')
-rw-r--r--kms++/inc/kms++/omap/omapframebuffer.h6
-rw-r--r--kms++/src/omap/omapframebuffer.cpp72
2 files changed, 61 insertions, 17 deletions
diff --git a/kms++/inc/kms++/omap/omapframebuffer.h b/kms++/inc/kms++/omap/omapframebuffer.h
index 16d6cf8..dcaaa4f 100644
--- a/kms++/inc/kms++/omap/omapframebuffer.h
+++ b/kms++/inc/kms++/omap/omapframebuffer.h
@@ -12,8 +12,8 @@ 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); 15 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const std::string& fourcc, bool tiled = false);
16 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format); 16 OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool tiled = false);
17 virtual ~OmapFramebuffer(); 17 virtual ~OmapFramebuffer();
18 18
19 uint32_t width() const { return Framebuffer::width(); } 19 uint32_t width() const { return Framebuffer::width(); }
@@ -42,7 +42,7 @@ private:
42 uint8_t* map; 42 uint8_t* map;
43 }; 43 };
44 44
45 void Create(); 45 void Create(bool tiled);
46 void Destroy(); 46 void Destroy();
47 47
48 unsigned m_num_planes; 48 unsigned m_num_planes;
diff --git a/kms++/src/omap/omapframebuffer.cpp b/kms++/src/omap/omapframebuffer.cpp
index e1e2234..9997933 100644
--- a/kms++/src/omap/omapframebuffer.cpp
+++ b/kms++/src/omap/omapframebuffer.cpp
@@ -17,20 +17,24 @@ extern "C" {
17#include <omap_drmif.h> 17#include <omap_drmif.h>
18} 18}
19 19
20#define __round_mask(x, y) ((__typeof__(x))((y)-1))
21#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
22#define PAGE_SIZE 4096
23
20using namespace std; 24using namespace std;
21 25
22namespace kms 26namespace kms
23{ 27{
24 28
25OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc) 29OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, const string& fourcc, bool tiled)
26 : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc)) 30 : OmapFramebuffer(card, width, height, FourCCToPixelFormat(fourcc), tiled)
27{ 31{
28} 32}
29 33
30OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format) 34OmapFramebuffer::OmapFramebuffer(OmapCard& card, uint32_t width, uint32_t height, PixelFormat format, bool tiled)
31 : MappedFramebuffer(card, width, height), m_omap_card(card), m_format(format) 35 :MappedFramebuffer(card, width, height), m_omap_card(card), m_format(format)
32{ 36{
33 Create(); 37 Create(tiled);
34} 38}
35 39
36OmapFramebuffer::~OmapFramebuffer() 40OmapFramebuffer::~OmapFramebuffer()
@@ -38,7 +42,7 @@ OmapFramebuffer::~OmapFramebuffer()
38 Destroy(); 42 Destroy();
39} 43}
40 44
41void OmapFramebuffer::Create() 45void OmapFramebuffer::Create(bool tiled)
42{ 46{
43 const PixelFormatInfo& format_info = get_pixel_format_info(m_format); 47 const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
44 48
@@ -50,13 +54,52 @@ void OmapFramebuffer::Create()
50 54
51 uint32_t flags = OMAP_BO_SCANOUT | OMAP_BO_WC; 55 uint32_t flags = OMAP_BO_SCANOUT | OMAP_BO_WC;
52 56
53 uint32_t size = width() * height() * pi.bitspp / 8; 57 struct omap_bo* bo;
54 58
55 struct omap_bo* bo = omap_bo_new(m_omap_card.dev(), size, flags); 59 uint32_t stride;
56 if (!bo) 60
57 throw invalid_argument(string("omap_bo_new failed: ") + strerror(errno)); 61 if (!tiled) {
58 62 stride = width() * pi.bitspp / 8;
59 uint32_t stride = width() * pi.bitspp / 8; 63
64 uint32_t size = stride * height() / pi.ysub;
65
66 bo = omap_bo_new(m_omap_card.dev(), size, flags);
67 if (!bo)
68 throw invalid_argument(string("omap_bo_new failed: ") + strerror(errno));
69 } else {
70 unsigned bitspertiler;
71
72 switch (m_format) {
73 case PixelFormat::NV12:
74 bitspertiler = i == 0 ? 8 : 16; break;
75 case PixelFormat::YUYV:
76 case PixelFormat::UYVY:
77 bitspertiler = 32; break;
78 case PixelFormat::ARGB8888:
79 case PixelFormat::XRGB8888:
80 bitspertiler = 32; break;
81 case PixelFormat::RGB565:
82 bitspertiler = 16; break;
83 default:
84 throw invalid_argument("unimplemented format");
85 }
86
87 switch (bitspertiler) {
88 case 8: flags |= OMAP_BO_TILED_8; break;
89 case 16: flags |= OMAP_BO_TILED_16; break;
90 case 32: flags |= OMAP_BO_TILED_32; break;
91 default:
92 throw invalid_argument("bad bitspertiler");
93 }
94
95 uint32_t width_tiler = width() * pi.bitspp / bitspertiler;
96
97 bo = omap_bo_new_tiled(m_omap_card.dev(), width_tiler, height(), flags);
98 if (!bo)
99 throw invalid_argument(string("omap_bo_new_tiled failed: ") + strerror(errno));
100
101 stride = round_up(width() * pi.bitspp / 8, PAGE_SIZE);
102 }
60 103
61 plane.omap_bo = bo; 104 plane.omap_bo = bo;
62 plane.handle = omap_bo_handle(bo); 105 plane.handle = omap_bo_handle(bo);
@@ -67,7 +110,7 @@ void OmapFramebuffer::Create()
67 plane.prime_fd = -1; 110 plane.prime_fd = -1;
68 } 111 }
69 112
70 /* create framebuffer object for the dumb-buffer */ 113 /* create framebuffer object */
71 uint32_t bo_handles[4] = { m_planes[0].handle, m_planes[1].handle }; 114 uint32_t bo_handles[4] = { m_planes[0].handle, m_planes[1].handle };
72 uint32_t pitches[4] = { m_planes[0].stride, m_planes[1].stride }; 115 uint32_t pitches[4] = { m_planes[0].stride, m_planes[1].stride };
73 uint32_t offsets[4] = { m_planes[0].offset, m_planes[1].offset }; 116 uint32_t offsets[4] = { m_planes[0].offset, m_planes[1].offset };
@@ -82,6 +125,7 @@ void OmapFramebuffer::Create()
82 125
83void OmapFramebuffer::Destroy() 126void OmapFramebuffer::Destroy()
84{ 127{
128 /* delete framebuffer */
85 drmModeRmFB(card().fd(), id()); 129 drmModeRmFB(card().fd(), id());
86 130
87 for (uint i = 0; i < m_num_planes; ++i) { 131 for (uint i = 0; i < m_num_planes; ++i) {