aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-10-03 04:37:59 -0500
committerTomi Valkeinen2017-10-03 04:42:55 -0500
commit3ae05a32c0b9dcc4a83463c51f1abf5289cb4fe9 (patch)
tree3ec881f09ddf6b01eb3e21019e8f65f4ac085afc
parent2d26d172c477c2ea22c4603c6f6c5ba5027f8c80 (diff)
downloadexternal-kmsxx-3ae05a32c0b9dcc4a83463c51f1abf5289cb4fe9.tar.gz
external-kmsxx-3ae05a32c0b9dcc4a83463c51f1abf5289cb4fe9.tar.xz
external-kmsxx-3ae05a32c0b9dcc4a83463c51f1abf5289cb4fe9.zip
kmscapture: clean up fb handling
-rw-r--r--utils/kmscapture.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/utils/kmscapture.cpp b/utils/kmscapture.cpp
index c72d38c..1a9b51b 100644
--- a/utils/kmscapture.cpp
+++ b/utils/kmscapture.cpp
@@ -43,8 +43,7 @@ private:
43 Crtc* m_crtc; 43 Crtc* m_crtc;
44 Plane* m_plane; 44 Plane* m_plane;
45 BufferProvider m_buffer_provider; 45 BufferProvider m_buffer_provider;
46 vector<DumbFramebuffer*> m_fb; /* framebuffers for DRM buffers */ 46 vector<Framebuffer*> m_fb;
47 vector<ExtFramebuffer*> m_extfb; /* framebuffers for V4L2 buffers */
48 int m_prev_fb_index; 47 int m_prev_fb_index;
49 uint32_t m_in_width, m_in_height; /* camera capture resolution */ 48 uint32_t m_in_width, m_in_height; /* camera capture resolution */
50 /* image properties for display */ 49 /* image properties for display */
@@ -161,11 +160,10 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
161 v4lbuf.memory = v4l_mem; 160 v4lbuf.memory = v4l_mem;
162 161
163 for (unsigned i = 0; i < CAMERA_BUF_QUEUE_SIZE; i++) { 162 for (unsigned i = 0; i < CAMERA_BUF_QUEUE_SIZE; i++) {
164 DumbFramebuffer *fb = NULL; 163 Framebuffer *fb;
165 ExtFramebuffer *extfb = NULL;
166 164
167 if (m_buffer_provider == BufferProvider::V4L2) 165 if (m_buffer_provider == BufferProvider::V4L2)
168 extfb = GetExtFrameBuffer(card, i, pixfmt); 166 fb = GetExtFrameBuffer(card, i, pixfmt);
169 else 167 else
170 fb = new DumbFramebuffer(card, m_in_width, 168 fb = new DumbFramebuffer(card, m_in_width,
171 m_in_height, pixfmt); 169 m_in_height, pixfmt);
@@ -176,10 +174,7 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
176 r = ioctl(m_fd, VIDIOC_QBUF, &v4lbuf); 174 r = ioctl(m_fd, VIDIOC_QBUF, &v4lbuf);
177 ASSERT(r == 0); 175 ASSERT(r == 0);
178 176
179 if (m_buffer_provider == BufferProvider::V4L2) 177 m_fb.push_back(fb);
180 m_extfb.push_back(extfb);
181 else
182 m_fb.push_back(fb);
183 } 178 }
184 179
185 m_plane = plane; 180 m_plane = plane;
@@ -188,11 +183,7 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
188 // set the FB when page flipping 183 // set the FB when page flipping
189 AtomicReq req(card); 184 AtomicReq req(card);
190 185
191 Framebuffer *fb; 186 Framebuffer *fb = m_fb[0];
192 if (m_buffer_provider == BufferProvider::V4L2)
193 fb = m_extfb[0];
194 else
195 fb = m_fb[0];
196 187
197 req.add(m_plane, "CRTC_ID", m_crtc->id()); 188 req.add(m_plane, "CRTC_ID", m_crtc->id());
198 req.add(m_plane, "FB_ID", fb->id()); 189 req.add(m_plane, "FB_ID", fb->id());
@@ -216,9 +207,6 @@ CameraPipeline::~CameraPipeline()
216 for (unsigned i = 0; i < m_fb.size(); i++) 207 for (unsigned i = 0; i < m_fb.size(); i++)
217 delete m_fb[i]; 208 delete m_fb[i];
218 209
219 for (unsigned i = 0; i < m_extfb.size(); i++)
220 delete m_extfb[i];
221
222 ::close(m_fd); 210 ::close(m_fd);
223} 211}
224 212
@@ -251,11 +239,7 @@ void CameraPipeline::show_next_frame(AtomicReq& req)
251 239
252 unsigned fb_index = v4l2buf.index; 240 unsigned fb_index = v4l2buf.index;
253 241
254 Framebuffer *fb; 242 Framebuffer *fb = m_fb[fb_index];
255 if (m_buffer_provider == BufferProvider::V4L2)
256 fb = m_extfb[fb_index];
257 else
258 fb = m_fb[fb_index];
259 243
260 req.add(m_plane, "FB_ID", fb->id()); 244 req.add(m_plane, "FB_ID", fb->id());
261 245