[RFC PATCH 8/8] media: vim2m: add request support
From: Alexandre Courbot
Date: Fri Jan 26 2018 - 01:03:14 EST
Set the necessary ops for supporting requests in vim2m.
Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxxxx>
---
drivers/media/platform/vim2m.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index a32e8a7950eb..1ddbad5eb569 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -30,6 +30,8 @@
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-vmalloc.h>
+#include <media/media-request.h>
+#include <media/media-request-mgr.h>
MODULE_DESCRIPTION("Virtual device for mem2mem framework testing");
MODULE_AUTHOR("Pawel Osciak, <pawel@xxxxxxxxxx>");
@@ -370,6 +372,24 @@ static void job_abort(void *priv)
ctx->aborting = 1;
}
+static void apply_request_params(struct media_request *req,
+ struct vim2m_ctx *ctx)
+{
+ struct media_request_entity_data *data;
+
+ if (!req)
+ return;
+
+ data = media_request_get_entity_data(req, &ctx->dev->vfd.entity,
+ &ctx->fh);
+ if (WARN_ON(!data))
+ return;
+
+ /* apply controls here */
+
+ data->applied = true;
+}
+
/* device_run() - prepares and starts the device
*
* This simulates all the immediate preparations required before starting
@@ -385,8 +405,15 @@ static void device_run(void *priv)
src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
+ /* Apply request if needed */
+ apply_request_params(src_buf->vb2_buf.request, ctx);
+ WARN_ON(dst_buf->vb2_buf.request != NULL);
+
device_process(ctx, src_buf, dst_buf);
+ /* Inform user about which request produced the destination buffer */
+ dst_buf->request_fd = src_buf->request_fd;
+
/* Run a timer, which simulates a hardware irq */
schedule_irq(dev, ctx->transtime);
}
@@ -841,6 +868,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
src_vq->mem_ops = &vb2_vmalloc_memops;
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
src_vq->lock = &ctx->dev->dev_mutex;
+ src_vq->allow_requests = true;
ret = vb2_queue_init(src_vq);
if (ret)
@@ -1006,6 +1034,9 @@ static int vim2m_probe(struct platform_device *pdev)
#ifdef CONFIG_MEDIA_CONTROLLER
dev->mdev.dev = &pdev->dev;
+ dev->mdev.req_mgr = media_request_mgr_alloc(&dev->mdev);
+ if (IS_ERR(dev->mdev.req_mgr))
+ return PTR_ERR(dev->mdev.req_mgr);
strlcpy(dev->mdev.model, "vim2m", sizeof(dev->mdev.model));
media_device_init(&dev->mdev);
dev->v4l2_dev.mdev = &dev->mdev;
--
2.16.0.rc1.238.g530d649a79-goog