diff options
Diffstat (limited to 'utils/wbcap.cpp')
-rw-r--r-- | utils/wbcap.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/utils/wbcap.cpp b/utils/wbcap.cpp index 4ec87ee..38a8cc0 100644 --- a/utils/wbcap.cpp +++ b/utils/wbcap.cpp | |||
@@ -23,8 +23,10 @@ public: | |||
23 | WBStreamer(VideoStreamer* streamer, Crtc* crtc, PixelFormat pixfmt) | 23 | WBStreamer(VideoStreamer* streamer, Crtc* crtc, PixelFormat pixfmt) |
24 | : m_capdev(*streamer) | 24 | : m_capdev(*streamer) |
25 | { | 25 | { |
26 | Videomode m = crtc->mode(); | ||
27 | |||
26 | m_capdev.set_port(crtc->idx()); | 28 | m_capdev.set_port(crtc->idx()); |
27 | m_capdev.set_format(pixfmt, crtc->mode().hdisplay, crtc->mode().vdisplay); | 29 | m_capdev.set_format(pixfmt, m.hdisplay, m.vdisplay / (m.interlace() ? 2 : 1)); |
28 | m_capdev.set_queue_size(s_fbs.size()); | 30 | m_capdev.set_queue_size(s_fbs.size()); |
29 | 31 | ||
30 | for (auto fb : s_free_fbs) { | 32 | for (auto fb : s_free_fbs) { |
@@ -87,10 +89,6 @@ public: | |||
87 | WBFlipState(Card& card, Crtc* crtc, Plane* plane) | 89 | WBFlipState(Card& card, Crtc* crtc, Plane* plane) |
88 | : m_card(card), m_crtc(crtc), m_plane(plane) | 90 | : m_card(card), m_crtc(crtc), m_plane(plane) |
89 | { | 91 | { |
90 | } | ||
91 | |||
92 | void setup(uint32_t x, uint32_t y, uint32_t width, uint32_t height) | ||
93 | { | ||
94 | auto fb = s_ready_fbs.back(); | 92 | auto fb = s_ready_fbs.back(); |
95 | s_ready_fbs.pop_back(); | 93 | s_ready_fbs.pop_back(); |
96 | 94 | ||
@@ -99,8 +97,8 @@ public: | |||
99 | req.add(m_plane, "CRTC_ID", m_crtc->id()); | 97 | req.add(m_plane, "CRTC_ID", m_crtc->id()); |
100 | req.add(m_plane, "FB_ID", fb->id()); | 98 | req.add(m_plane, "FB_ID", fb->id()); |
101 | 99 | ||
102 | req.add(m_plane, "CRTC_X", x); | 100 | req.add(m_plane, "CRTC_X", 0); |
103 | req.add(m_plane, "CRTC_Y", y); | 101 | req.add(m_plane, "CRTC_Y", 0); |
104 | req.add(m_plane, "CRTC_W", min((uint32_t)m_crtc->mode().hdisplay, fb->width())); | 102 | req.add(m_plane, "CRTC_W", min((uint32_t)m_crtc->mode().hdisplay, fb->width())); |
105 | req.add(m_plane, "CRTC_H", min((uint32_t)m_crtc->mode().vdisplay, fb->height())); | 103 | req.add(m_plane, "CRTC_H", min((uint32_t)m_crtc->mode().vdisplay, fb->height())); |
106 | 104 | ||
@@ -325,17 +323,22 @@ int main(int argc, char** argv) | |||
325 | Videomode dst_mode = dst_mode_name.empty() ? dst_conn->get_default_mode() : dst_conn->get_mode(dst_mode_name); | 323 | Videomode dst_mode = dst_mode_name.empty() ? dst_conn->get_default_mode() : dst_conn->get_mode(dst_mode_name); |
326 | dst_crtc->set_mode(dst_conn, dst_mode); | 324 | dst_crtc->set_mode(dst_conn, dst_mode); |
327 | 325 | ||
328 | uint32_t width = src_mode.hdisplay; | 326 | uint32_t src_width = src_mode.hdisplay; |
329 | uint32_t height = src_mode.vdisplay; | 327 | uint32_t src_height = src_mode.vdisplay; |
328 | |||
329 | uint32_t dst_width = src_mode.hdisplay; | ||
330 | uint32_t dst_height = src_mode.vdisplay; | ||
331 | if (src_mode.interlace()) | ||
332 | dst_height /= 2; | ||
330 | 333 | ||
331 | printf("src %s, crtc %s\n", src_conn->fullname().c_str(), src_mode.to_string().c_str()); | 334 | printf("src %s, crtc %s\n", src_conn->fullname().c_str(), src_mode.to_string().c_str()); |
332 | 335 | ||
333 | printf("dst %s, crtc %s\n", dst_conn->fullname().c_str(), dst_mode.to_string().c_str()); | 336 | printf("dst %s, crtc %s\n", dst_conn->fullname().c_str(), dst_mode.to_string().c_str()); |
334 | 337 | ||
335 | printf("fb %ux%u\n", width, height); | 338 | printf("src_fb %ux%u, dst_fb %ux%u\n", src_width, src_height, dst_width, dst_height); |
336 | 339 | ||
337 | for (int i = 0; i < CAMERA_BUF_QUEUE_SIZE; ++i) { | 340 | for (int i = 0; i < CAMERA_BUF_QUEUE_SIZE; ++i) { |
338 | auto fb = new DumbFramebuffer(card, width, height, pixfmt); | 341 | auto fb = new DumbFramebuffer(card, dst_width, dst_height, pixfmt); |
339 | s_fbs.push_back(fb); | 342 | s_fbs.push_back(fb); |
340 | s_free_fbs.push_back(fb); | 343 | s_free_fbs.push_back(fb); |
341 | } | 344 | } |
@@ -345,12 +348,11 @@ int main(int argc, char** argv) | |||
345 | s_free_fbs.pop_back(); | 348 | s_free_fbs.pop_back(); |
346 | 349 | ||
347 | // This draws a moving bar to SRC display | 350 | // This draws a moving bar to SRC display |
348 | BarFlipState barflipper(card, src_crtc, src_plane, width, height); | 351 | BarFlipState barflipper(card, src_crtc, src_plane, src_width, src_height); |
349 | barflipper.start_flipping(); | 352 | barflipper.start_flipping(); |
350 | 353 | ||
351 | // This shows the captures SRC frames on DST display | 354 | // This shows the captured SRC frames on DST display |
352 | WBFlipState wbflipper(card, dst_crtc, dst_plane); | 355 | WBFlipState wbflipper(card, dst_crtc, dst_plane); |
353 | wbflipper.setup(0, 0, width, height); | ||
354 | 356 | ||
355 | WBStreamer wb(vid.get_capture_streamer(), src_crtc, pixfmt); | 357 | WBStreamer wb(vid.get_capture_streamer(), src_crtc, pixfmt); |
356 | wb.start_streaming(); | 358 | wb.start_streaming(); |