summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-10-23 04:09:28 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2013-03-07 22:48:40 +0100
commit7171e8263fada3f37d955ec538c58ebb73d02b38 (patch)
treec8773f03f5ace6b27490b5f451e1383af3f85161
parent0048b16618a94c3c002bb620e5d5503039853a43 (diff)
isp: Support allocating an output buffers pool for the viewfinder
The viewfinder is usually used with a display device that allocates buffers. This led to the viewfinder API requiring the application to set the output buffers pool. For applications that don't have a buffers pool to give to the viewfinder support allocating a dedicated pool and exporting it to the application. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--isp/omap3isp.c44
-rw-r--r--isp/omap3isp.h5
2 files changed, 49 insertions, 0 deletions
diff --git a/isp/omap3isp.c b/isp/omap3isp.c
index 20ef13d..6a9bfa5 100644
--- a/isp/omap3isp.c
+++ b/isp/omap3isp.c
@@ -1161,6 +1161,50 @@ int omap3_isp_viewfinder_setup(struct omap3_isp_device *isp,
return 0;
}
+int omap3_isp_viewfinder_alloc_pool(struct omap3_isp_device *isp,
+ unsigned int nbufs)
+{
+ struct v4l2_buffers_pool *pool;
+ int ret;
+
+ pool = v4l2_buffers_pool_new(nbufs);
+ if (pool == NULL) {
+ printf("error: unable to allocate buffers pool for viewfinder.\n");
+ return -ENOMEM;
+ }
+
+ ret = v4l2_alloc_buffers(isp->viewfinder.output->video, pool,
+ V4L2_MEMORY_MMAP);
+ if (ret < 0) {
+ printf("error: unable to allocate buffers for viewfinder.\n");
+ return ret;
+ }
+
+ isp->viewfinder.output->pool = pool;
+ isp->viewfinder.output->queued = 0;
+
+ return 0;
+}
+
+void omap3_isp_viewfinder_free_pool(struct omap3_isp_device *isp)
+{
+ int ret;
+
+ ret = v4l2_free_buffers(isp->viewfinder.output->video);
+ if (ret < 0)
+ printf("error: unable to free viewfinder buffers.\n");
+
+ v4l2_buffers_pool_delete(isp->viewfinder.output->pool);
+
+ isp->viewfinder.output->pool = NULL;
+}
+
+struct v4l2_buffers_pool *
+omap3_isp_viewfinder_get_pool(struct omap3_isp_device *isp)
+{
+ return isp->viewfinder.output->pool;
+}
+
int omap3_isp_viewfinder_set_pool(struct omap3_isp_device *isp,
struct v4l2_buffers_pool *pool)
{
diff --git a/isp/omap3isp.h b/isp/omap3isp.h
index 26e5062..d2d93dd 100644
--- a/isp/omap3isp.h
+++ b/isp/omap3isp.h
@@ -67,6 +67,11 @@ void omap3_isp_close(struct omap3_isp_device *isp);
int omap3_isp_viewfinder_setup(struct omap3_isp_device *isp,
struct v4l2_rect *crop,
struct v4l2_mbus_framefmt *ofmt);
+int omap3_isp_viewfinder_alloc_pool(struct omap3_isp_device *isp,
+ unsigned int nbufs);
+void omap3_isp_viewfinder_free_pool(struct omap3_isp_device *isp);
+struct v4l2_buffers_pool *
+omap3_isp_viewfinder_get_pool(struct omap3_isp_device *isp);
int omap3_isp_viewfinder_set_pool(struct omap3_isp_device *isp,
struct v4l2_buffers_pool *pool);
int omap3_isp_viewfinder_set_scaler(struct omap3_isp_device *isp,