summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/meson.build6
-rw-r--r--utils/omap-wbcap.cpp29
-rw-r--r--utils/omap-wbm2m.cpp50
3 files changed, 59 insertions, 26 deletions
diff --git a/utils/meson.build b/utils/meson.build
index b1e7918..ac73b5b 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -13,5 +13,7 @@ if libevdev_dep.found()
executable('kmstouch', 'kmstouch.cpp', dependencies : [ common_deps, libevdev_dep ], install : false)
endif
-executable('omap-wbcap', 'omap-wbcap.cpp', dependencies : [ common_deps ], install : false)
-executable('omap-wbm2m', 'omap-wbm2m.cpp', dependencies : [ common_deps ], install : false)
+if get_option('v4l2').enabled()
+ executable('omap-wbcap', 'omap-wbcap.cpp', dependencies : [ common_deps, libv4l2xx_dep ], install : false)
+ executable('omap-wbm2m', 'omap-wbm2m.cpp', dependencies : [ common_deps, libv4l2xx_dep ], install : false)
+endif
diff --git a/utils/omap-wbcap.cpp b/utils/omap-wbcap.cpp
index 8033869..5080159 100644
--- a/utils/omap-wbcap.cpp
+++ b/utils/omap-wbcap.cpp
@@ -6,7 +6,7 @@
#include <kms++/kms++.h>
#include <kms++util/kms++util.h>
-#include <kms++util/videodevice.h>
+#include <v4l2++/videodevice.h>
#define CAMERA_BUF_QUEUE_SIZE 5
@@ -21,17 +21,21 @@ static vector<DumbFramebuffer*> s_ready_fbs;
class WBStreamer
{
public:
- WBStreamer(VideoStreamer* streamer, Crtc* crtc, PixelFormat pixfmt)
+ WBStreamer(v4l2::VideoStreamer* streamer, Crtc* crtc, PixelFormat pixfmt)
: m_capdev(*streamer)
{
Videomode m = crtc->mode();
m_capdev.set_port(crtc->idx());
- m_capdev.set_format(pixfmt, m.hdisplay, m.vdisplay / (m.interlace() ? 2 : 1));
- m_capdev.set_queue_size(s_fbs.size());
+ m_capdev.set_format((v4l2::PixelFormat)pixfmt, m.hdisplay, m.vdisplay / (m.interlace() ? 2 : 1));
+ m_capdev.set_queue_size(s_fbs.size(), v4l2::VideoMemoryType::DMABUF);
for (auto fb : s_free_fbs) {
- m_capdev.queue(fb);
+ v4l2::VideoBuffer vbuf {};
+ vbuf.m_mem_type = v4l2::VideoMemoryType::DMABUF;
+ vbuf.m_fd = fb->prime_fd(0);
+
+ m_capdev.queue(vbuf);
s_wb_fbs.push_back(fb);
}
@@ -59,9 +63,10 @@ public:
DumbFramebuffer* Dequeue()
{
- auto fb = m_capdev.dequeue();
+ auto vbuf = m_capdev.dequeue();
- auto iter = find(s_wb_fbs.begin(), s_wb_fbs.end(), fb);
+ auto iter = find_if(s_wb_fbs.begin(), s_wb_fbs.end(), [fd=vbuf.m_fd](auto& fb) { return fb->prime_fd(0) == fd; });
+ auto fb = *iter;
s_wb_fbs.erase(iter);
s_ready_fbs.insert(s_ready_fbs.begin(), fb);
@@ -77,13 +82,17 @@ public:
auto fb = s_free_fbs.back();
s_free_fbs.pop_back();
- m_capdev.queue(fb);
+ v4l2::VideoBuffer vbuf {};
+ vbuf.m_mem_type = v4l2::VideoMemoryType::DMABUF;
+ vbuf.m_fd = fb->prime_fd(0);
+
+ m_capdev.queue(vbuf);
s_wb_fbs.insert(s_wb_fbs.begin(), fb);
}
private:
- VideoStreamer& m_capdev;
+ v4l2::VideoStreamer& m_capdev;
};
class WBFlipState : private PageFlipHandlerBase
@@ -304,7 +313,7 @@ int main(int argc, char** argv)
if (dst_conn_name.empty())
EXIT("No destination connector defined");
- VideoDevice vid("/dev/video11");
+ v4l2::VideoDevice vid("/dev/video11");
Card card;
ResourceManager resman(card);
diff --git a/utils/omap-wbm2m.cpp b/utils/omap-wbm2m.cpp
index a00fab2..6ac08e0 100644
--- a/utils/omap-wbm2m.cpp
+++ b/utils/omap-wbm2m.cpp
@@ -10,7 +10,7 @@
#include <kms++/kms++.h>
#include <kms++util/kms++util.h>
-#include <kms++util/videodevice.h>
+#include <v4l2++/videodevice.h>
const uint32_t NUM_SRC_BUFS = 2;
const uint32_t NUM_DST_BUFS = 2;
@@ -106,38 +106,55 @@ int main(int argc, char** argv)
printf("writing to %s\n", filename.c_str());
- VideoDevice vid("/dev/video10");
+ v4l2::VideoDevice vid("/dev/video10");
Card card;
uint32_t src_frame_num = 0;
uint32_t dst_frame_num = 0;
- VideoStreamer* out = vid.get_output_streamer();
- VideoStreamer* in = vid.get_capture_streamer();
+ v4l2::VideoStreamer* out = vid.get_output_streamer();
+ v4l2::VideoStreamer* in = vid.get_capture_streamer();
- out->set_format(src_fmt, src_width, src_height);
- in->set_format(dst_fmt, dst_width, dst_height);
+ out->set_format((v4l2::PixelFormat)src_fmt, src_width, src_height);
+ in->set_format((v4l2::PixelFormat)dst_fmt, dst_width, dst_height);
if (use_selection) {
out->set_selection(c_left, c_top, c_width, c_height);
printf("crop -> %u,%u-%ux%u\n", c_left, c_top, c_width, c_height);
}
- out->set_queue_size(NUM_SRC_BUFS);
- in->set_queue_size(NUM_DST_BUFS);
+ out->set_queue_size(NUM_SRC_BUFS, v4l2::VideoMemoryType::DMABUF);
+ in->set_queue_size(NUM_DST_BUFS, v4l2::VideoMemoryType::DMABUF);
+
+ vector<DumbFramebuffer*> out_fbs;
for (unsigned i = 0; i < min(NUM_SRC_BUFS, num_src_frames); ++i) {
auto fb = new DumbFramebuffer(card, src_width, src_height, src_fmt);
read_frame(fb, src_frame_num++);
- out->queue(fb);
+ out_fbs.push_back(fb);
+
+ v4l2::VideoBuffer vbuf {};
+ vbuf.m_mem_type = v4l2::VideoMemoryType::DMABUF;
+ vbuf.m_fd = fb->prime_fd(0);
+
+ out->queue(vbuf);
}
+ vector<DumbFramebuffer*> in_fbs;
+
for (unsigned i = 0; i < min(NUM_DST_BUFS, num_src_frames); ++i) {
auto fb = new DumbFramebuffer(card, dst_width, dst_height, dst_fmt);
- in->queue(fb);
+
+ in_fbs.push_back(fb);
+
+ v4l2::VideoBuffer vbuf {};
+ vbuf.m_mem_type = v4l2::VideoMemoryType::DMABUF;
+ vbuf.m_fd = fb->prime_fd(0);
+
+ in->queue(vbuf);
}
vector<pollfd> fds(3);
@@ -165,11 +182,14 @@ int main(int argc, char** argv)
fds[1].revents = 0;
try {
- DumbFramebuffer* dst_fb = in->dequeue();
+ auto dst_vbuf = in->dequeue();
+
+ auto dst_fb = *find_if(in_fbs.begin(), in_fbs.end(), [fd=dst_vbuf.m_fd](auto& fb) { return fb->prime_fd(0) == fd; });
+
printf("Writing frame %u\n", dst_frame_num);
for (unsigned i = 0; i < dst_fb->num_planes(); ++i)
os.write((char*)dst_fb->map(i), dst_fb->size(i));
- in->queue(dst_fb);
+ in->queue(dst_vbuf);
dst_frame_num++;
@@ -183,11 +203,13 @@ int main(int argc, char** argv)
break;
}
- DumbFramebuffer* src_fb = out->dequeue();
+ auto src_vbuf = out->dequeue();
+
+ auto src_fb = *find_if(out_fbs.begin(), out_fbs.end(), [fd=src_vbuf.m_fd](auto& fb) { return fb->prime_fd(0) == fd; });
if (src_frame_num < num_src_frames) {
read_frame(src_fb, src_frame_num++);
- out->queue(src_fb);
+ out->queue(src_vbuf);
}
}