summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/kmscapture.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/utils/kmscapture.cpp b/utils/kmscapture.cpp
index 43ef989..6dc4c5b 100644
--- a/utils/kmscapture.cpp
+++ b/utils/kmscapture.cpp
@@ -11,6 +11,7 @@
#include <kms++/kms++.h>
#include <kms++util/kms++util.h>
+#include <kms++/omap/omapkms++.h>
#define CAMERA_BUF_QUEUE_SIZE 3
#define MAX_CAMERA 9
@@ -26,9 +27,9 @@ enum class BufferProvider {
class CameraPipeline
{
public:
- CameraPipeline(int cam_fd, Card& card, Crtc* crtc, Plane* plane, uint32_t x, uint32_t y,
+ CameraPipeline(int cam_fd, OmapCard& card, Crtc* crtc, Plane* plane, uint32_t x, uint32_t y,
uint32_t iw, uint32_t ih, PixelFormat pixfmt,
- BufferProvider buffer_provider);
+ BufferProvider buffer_provider, bool cached);
~CameraPipeline();
CameraPipeline(const CameraPipeline& other) = delete;
@@ -43,7 +44,7 @@ private:
Crtc* m_crtc;
Plane* m_plane;
BufferProvider m_buffer_provider;
- vector<DumbFramebuffer*> m_fb; /* framebuffers for DRM buffers */
+ vector<OmapFramebuffer*> m_fb; /* framebuffers for DRM buffers */
vector<ExtFramebuffer*> m_extfb; /* framebuffers for V4L2 buffers */
int m_prev_fb_index;
uint32_t m_in_width, m_in_height; /* camera capture resolution */
@@ -102,9 +103,9 @@ bool inline better_size(struct v4l2_frmsize_discrete* v4ldisc,
return false;
}
-CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane, uint32_t x, uint32_t y,
+CameraPipeline::CameraPipeline(int cam_fd, OmapCard& card, Crtc *crtc, Plane* plane, uint32_t x, uint32_t y,
uint32_t iw, uint32_t ih, PixelFormat pixfmt,
- BufferProvider buffer_provider)
+ BufferProvider buffer_provider, bool cached)
: m_fd(cam_fd), m_crtc(crtc), m_buffer_provider(buffer_provider), m_prev_fb_index(-1)
{
@@ -165,14 +166,14 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
v4lbuf.memory = v4l_mem;
for (unsigned i = 0; i < CAMERA_BUF_QUEUE_SIZE; i++) {
- DumbFramebuffer *fb = NULL;
+ OmapFramebuffer *fb = NULL;
ExtFramebuffer *extfb = NULL;
if (m_buffer_provider == BufferProvider::V4L2)
extfb = GetExtFrameBuffer(card, i, pixfmt);
else
- fb = new DumbFramebuffer(card, m_in_width,
- m_in_height, pixfmt);
+ fb = new OmapFramebuffer(card, m_in_width,
+ m_in_height, pixfmt, cached);
v4lbuf.index = i;
if (m_buffer_provider == BufferProvider::DRM)
@@ -300,6 +301,7 @@ std::vector<std::string> glob(const std::string& pat)
static const char* usage_str =
"Usage: kmscapture [OPTIONS]\n\n"
"Options:\n"
+ " -c, --cached Map framebuffers cached\n"
" -s, --single Single camera mode. Open only /dev/video0\n"
" --buffer-type=<drm|v4l> Use DRM or V4L provided buffers. Default: DRM\n"
" -h, --help Print this help\n"
@@ -308,9 +310,14 @@ static const char* usage_str =
int main(int argc, char** argv)
{
BufferProvider buffer_provider = BufferProvider::DRM;
+ bool cached_buffers = false;
bool single_cam = false;
OptionSet optionset = {
+ Option("c|cached", [&]()
+ {
+ cached_buffers = true;
+ }),
Option("s|single", [&]()
{
single_cam = true;
@@ -340,7 +347,7 @@ int main(int argc, char** argv)
auto pixfmt = PixelFormat::YUYV;
- Card card;
+ OmapCard card;
auto conn = card.get_first_connected_connector();
auto crtc = conn->get_current_crtc();
@@ -389,7 +396,8 @@ int main(int argc, char** argv)
Plane* plane = available_planes[i];
auto cam = new CameraPipeline(cam_fd, card, crtc, plane, i * plane_w, 0,
- plane_w, crtc->height(), pixfmt, buffer_provider);
+ plane_w, crtc->height(), pixfmt, buffer_provider,
+ cached_buffers);
cameras.push_back(cam);
}