From 1edb19130f3025498e387e385e6692546d1287eb Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 26 Apr 2016 13:02:56 +0300 Subject: kmscapture: separate step to enable streaming --- tests/kmscapture.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/kmscapture.cpp b/tests/kmscapture.cpp index 965d32e..ff62678 100644 --- a/tests/kmscapture.cpp +++ b/tests/kmscapture.cpp @@ -37,6 +37,7 @@ public: void show_next_frame(AtomicReq &req); int fd() const { return m_fd; } + void start_streaming(); private: ExtFramebuffer* GetExtFrameBuffer(Card& card, uint32_t i, PixelFormat pixfmt); int m_fd; /* camera file descriptor */ @@ -186,11 +187,6 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane, m_fb.push_back(fb); } - enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - r = ioctl(m_fd, VIDIOC_STREAMON, &type); - ASSERT(r == 0); - m_plane = plane; // Do initial plane setup with first fb, so that we only need to @@ -220,7 +216,6 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane, FAIL_IF(r, "initial plane setup failed"); } - CameraPipeline::~CameraPipeline() { for (unsigned i = 0; i < m_fb.size(); i++) @@ -232,6 +227,14 @@ CameraPipeline::~CameraPipeline() ::close(m_fd); } +void CameraPipeline::start_streaming() +{ + enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + int r = ioctl(m_fd, VIDIOC_STREAMON, &type); + FAIL_IF(r, "Failed to enable camera stream: %d", r); +} + void CameraPipeline::show_next_frame(AtomicReq& req) { int r; @@ -402,6 +405,9 @@ int main(int argc, char** argv) fds[nr_cameras].fd = 0; fds[nr_cameras].events = POLLIN; + for (auto cam : cameras) + cam->start_streaming(); + while (true) { int r = poll(fds.data(), nr_cameras + 1, -1); ASSERT(r > 0); -- cgit v1.2.3