diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-02-24 08:46:47 +0100 |
---|---|---|
committer | Tomasz Stanislawski <t.stanislaws@samsung.com> | 2013-03-13 10:49:34 +0100 |
commit | 65586a3b359cfca99b5b3a041968e50f466f25d0 (patch) | |
tree | d343877f8cf69e4b0407c9df0f42a8c211121205 | |
parent | 8fd603a178b0eeed7db63e26991ae7f011506fb9 (diff) |
v4l2-drm-example: Factor out page flipping
Factor the common page flip code out to a function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | v4l2-drm-example/dmabuf-sharing.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/v4l2-drm-example/dmabuf-sharing.c b/v4l2-drm-example/dmabuf-sharing.c index 7156046..6c7abe5 100644 --- a/v4l2-drm-example/dmabuf-sharing.c +++ b/v4l2-drm-example/dmabuf-sharing.c @@ -334,6 +334,15 @@ static void drm_init(struct drm_device *dev, const struct v4l2_pix_format *fmt, BYE_ON(ret, "failed to find valid mode\n"); } +static void drm_page_flip(struct drm_device *dev, struct buffer *buffer) +{ + int ret; + + ret = drmModePageFlip(dev->fd, dev->crtc_id, buffer->fb_handle, + DRM_MODE_PAGE_FLIP_EVENT, (void*)(unsigned long)buffer->index); + BYE_ON(ret, "drmModePageFlip failed: %s\n", ERRSTR); +} + static void v4l2_init(struct v4l2_device *dev, unsigned int num_buffers) { int ret; @@ -474,9 +483,7 @@ int main(int argc, char *argv[]) BYE_ON(ret, "drmModeSetCrtc failed: %s\n", ERRSTR); /* Enqueue the first buffer to DRM and all other buffers to V4L2 */ - ret = drmModePageFlip(drm.fd, drm.crtc_id, buffers[0].fb_handle, - DRM_MODE_PAGE_FLIP_EVENT, 0); - BYE_ON(ret, "drmModePageFlip failed: %s\n", ERRSTR); + drm_page_flip(&drm, &buffers[0]); for (unsigned int i = 1; i < s.buffer_count; ++i) v4l2_queue_buffer(&v4l2, &buffers[i]); @@ -501,12 +508,9 @@ int main(int argc, char *argv[]) struct buffer *buffer; buffer = v4l2_dequeue_buffer(&v4l2, buffers); - - ret = drmModePageFlip(drm.fd, drm.crtc_id, buffer->fb_handle, - DRM_MODE_PAGE_FLIP_EVENT, (void*)(unsigned long)buffer->index); - BYE_ON(ret, "drmModePageFlip failed: %s\n", ERRSTR); - + drm_page_flip(&drm, buffer); } + if (fds[1].revents & POLLIN) { drmEventContext evctx; memset(&evctx, 0, sizeof evctx); |