Merge V4L2 related work
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 20 Jun 2016 05:53:36 +0000 (08:53 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 20 Jun 2016 05:53:36 +0000 (08:53 +0300)
kms++/inc/kms++/framebuffer.h
kms++/src/framebuffer.cpp
kmscube/cube-gbm.cpp

index cbf705d7c5d11f0b741eb14db85d276c22a491e2..faf2e71757ae6942c0ea5ea00528b00c15f3977a 100644 (file)
@@ -13,6 +13,8 @@ public:
 
        uint32_t width() const { return m_width; }
        uint32_t height() const { return m_height; }
+
+       void flush();
 protected:
        Framebuffer(Card& card, uint32_t width, uint32_t height);
 
index a7f589c00b8066d8513cb4340945602a3ada7921..39c4e163be287ff3cb54426cac712e287b2abbf2 100644 (file)
@@ -23,14 +23,28 @@ Framebuffer::Framebuffer(Card& card, uint32_t id)
 {
        auto fb = drmModeGetFB(card.fd(), id);
 
-       m_width = fb->width;
-       m_height = fb->height;
+       if (fb) {
+               m_width = fb->width;
+               m_height = fb->height;
 
-       drmModeFreeFB(fb);
+               drmModeFreeFB(fb);
+       } else {
+               m_width = m_height = 0;
+       }
 
        card.m_framebuffers.push_back(this);
 }
 
+void Framebuffer::flush()
+{
+       drmModeClip clip { };
+       clip.x1 = clip.y1 = 0;
+       clip.x2 = width();
+       clip.y2 = height();
+
+       drmModeDirtyFB(card().fd(), id(), &clip, 1);
+}
+
 Framebuffer::~Framebuffer()
 {
        auto& fbs = card().m_framebuffers;
index 15286847d6940d02016ab381e4c8ab0426c7766a..993434b186370429553e049efcc819b8cdf341f3 100644 (file)
@@ -132,8 +132,13 @@ public:
                uint32_t height = gbm_bo_get_height(bo);
                uint32_t stride = gbm_bo_get_stride(bo);
                uint32_t handle = gbm_bo_get_handle(bo).u32;
+               PixelFormat format = (PixelFormat)gbm_bo_get_format(bo);
 
-               fb = new ExtFramebuffer(card, width, height, 24, 32, stride, handle);
+               uint32_t handles[4] { handle };
+               uint32_t strides[4] { stride };
+               uint32_t offsets[4] { 0 };
+
+               fb = new ExtFramebuffer(card, width, height, format, handles, strides, offsets);
 
                gbm_bo_set_user_data(bo, fb, drm_fb_destroy_callback);