From: Alexandre Courbot <acourbot@chromium.org>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Pawel Osciak <posciak@chromium.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Tomasz Figa <tfiga@chromium.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Gustavo Padovan <gustavo.padovan@collabora.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexandre Courbot <acourbot@chromium.org>
Subject: [RFC PATCH 7/9] media: v4l2-mem2mem: add request support
Date: Fri, 15 Dec 2017 16:56:23 +0900 [thread overview]
Message-ID: <20171215075625.27028-8-acourbot@chromium.org> (raw)
In-Reply-To: <20171215075625.27028-1-acourbot@chromium.org>
Support request API in the mem2mem framework. Drivers that specify ops
for the queue and entities can support requests seamlessly.
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
---
drivers/media/v4l2-core/v4l2-mem2mem.c | 34 ++++++++++++++++++++++++++++++++++
include/media/v4l2-mem2mem.h | 19 +++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index f62e68aa04c4..eb52bee8e06a 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -22,6 +22,7 @@
#include <media/v4l2-dev.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-event.h>
+#include <media/media-request.h>
MODULE_DESCRIPTION("Mem to mem device framework for videobuf");
MODULE_AUTHOR("Pawel Osciak, <pawel@osciak.com>");
@@ -219,6 +220,15 @@ void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
m2m_dev = m2m_ctx->m2m_dev;
dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx);
+#ifdef CONFIG_MEDIA_CONTROLLER
+ /* request is completed if all queues are done with it */
+ if (m2m_ctx->req_queue && m2m_ctx->req_queue->active_request &&
+ m2m_ctx->cap_q_ctx.q.cur_req == NULL &&
+ m2m_ctx->out_q_ctx.q.cur_req == NULL)
+ media_request_entity_complete(m2m_ctx->req_queue,
+ m2m_ctx->entity);
+#endif
+
if (!m2m_ctx->out_q_ctx.q.streaming
|| !m2m_ctx->cap_q_ctx.q.streaming) {
dprintk("Streaming needs to be on for both queues\n");
@@ -665,6 +675,15 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
}
EXPORT_SYMBOL_GPL(v4l2_m2m_ctx_init);
+void v4l2_mem_ctx_request_init(struct v4l2_m2m_ctx *ctx,
+ struct media_request_queue *req_queue,
+ struct media_entity *entity)
+{
+ ctx->entity = entity;
+ ctx->req_queue = req_queue;
+}
+EXPORT_SYMBOL_GPL(v4l2_mem_ctx_request_init);
+
void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx)
{
/* wait until the current context is dequeued from job_queue */
@@ -810,3 +829,18 @@ unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait)
}
EXPORT_SYMBOL_GPL(v4l2_m2m_fop_poll);
+int v4l2_m2m_process_request(struct media_request *req,
+ struct media_request_entity_data *data)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+ struct v4l2_fh *fh = data->fh;
+ struct v4l2_m2m_ctx *ctx = fh->m2m_ctx;
+
+ vb2_queue_start_request(&ctx->cap_q_ctx.q, req);
+ vb2_queue_start_request(&ctx->out_q_ctx.q, req);
+
+ v4l2_m2m_try_schedule(ctx);
+#endif
+ return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_m2m_process_request);
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index e157d5c9b224..1c9925c3d4ce 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -19,6 +19,10 @@
#include <media/videobuf2-v4l2.h>
+struct media_entity;
+struct media_request;
+struct media_request_entity_data;
+
/**
* struct v4l2_m2m_ops - mem-to-mem device driver callbacks
* @device_run: required. Begin the actual job (transaction) inside this
@@ -83,6 +87,7 @@ struct v4l2_m2m_queue_ctx {
*
* @q_lock: struct &mutex lock
* @m2m_dev: opaque pointer to the internal data to handle M2M context
+ * @state: Pointer to state handler for channel support
* @cap_q_ctx: Capture (output to memory) queue context
* @out_q_ctx: Output (input from memory) queue context
* @queue: List of memory to memory contexts
@@ -100,6 +105,8 @@ struct v4l2_m2m_ctx {
/* internal use only */
struct v4l2_m2m_dev *m2m_dev;
+ struct media_request_queue *req_queue;
+ struct media_entity *entity;
struct v4l2_m2m_queue_ctx cap_q_ctx;
@@ -351,6 +358,16 @@ struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
void *drv_priv,
int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq));
+/**
+ * v4l2_mem_ctx_request_init() - enable a context to be used with requests
+ *
+ * @ctx: context to potentially use within a channel
+ * @req_queue: request queue that will be used with this context
+ */
+void v4l2_mem_ctx_request_init(struct v4l2_m2m_ctx *ctx,
+ struct media_request_queue *req_queue,
+ struct media_entity *entity);
+
static inline void v4l2_m2m_set_src_buffered(struct v4l2_m2m_ctx *m2m_ctx,
bool buffered)
{
@@ -602,6 +619,8 @@ int v4l2_m2m_ioctl_streamoff(struct file *file, void *fh,
enum v4l2_buf_type type);
int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma);
unsigned int v4l2_m2m_fop_poll(struct file *file, poll_table *wait);
+int v4l2_m2m_process_request(struct media_request *req,
+ struct media_request_entity_data *data);
#endif /* _MEDIA_V4L2_MEM2MEM_H */
--
2.15.1.504.g5279b80103-goog
next prev parent reply other threads:[~2017-12-15 7:57 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 7:56 [RFC PATCH 0/9] media: base request API support Alexandre Courbot
2017-12-15 7:56 ` [RFC PATCH 1/9] media: add request API core and UAPI Alexandre Courbot
2017-12-15 10:37 ` Philippe Ombredanne
2018-01-12 10:16 ` Hans Verkuil
2018-01-26 8:39 ` Sakari Ailus
2018-01-30 4:23 ` Alexandre Courbot
2018-02-02 7:33 ` Sakari Ailus
2018-02-02 7:41 ` Tomasz Figa
2018-02-02 8:00 ` Hans Verkuil
2017-12-15 7:56 ` [RFC PATCH 2/9] media: request: add generic queue Alexandre Courbot
2017-12-15 7:56 ` [RFC PATCH 3/9] media: request: add generic entity ops Alexandre Courbot
2017-12-15 7:56 ` [RFC PATCH 4/9] videodev2.h: Add request field to v4l2_buffer Alexandre Courbot
2018-01-12 10:22 ` Hans Verkuil
2018-01-15 8:24 ` Alexandre Courbot
2017-12-15 7:56 ` [RFC PATCH 5/9] media: vb2: add support for requests Alexandre Courbot
2018-01-12 10:49 ` Hans Verkuil
2018-01-15 8:24 ` Alexandre Courbot
2018-01-15 9:07 ` Hans Verkuil
2018-01-16 9:39 ` Alexandre Courbot
2018-01-16 10:37 ` Hans Verkuil
2018-01-17 8:01 ` Alexandre Courbot
2018-01-17 8:37 ` Hans Verkuil
2017-12-15 7:56 ` [RFC PATCH 6/9] media: vb2: add support for requests in QBUF ioctl Alexandre Courbot
2018-01-12 11:37 ` Hans Verkuil
2018-01-15 8:24 ` Alexandre Courbot
2018-01-15 9:19 ` Hans Verkuil
2018-01-16 9:40 ` Alexandre Courbot
2017-12-15 7:56 ` Alexandre Courbot [this message]
2017-12-15 7:56 ` [RFC PATCH 8/9] media: vim2m: add media device Alexandre Courbot
2017-12-15 7:56 ` [RFC PATCH 9/9] media: vim2m: add request support Alexandre Courbot
2017-12-18 20:53 ` Gustavo Padovan
2017-12-20 9:29 ` Alexandre Courbot
2017-12-15 21:02 ` [RFC PATCH 0/9] media: base request API support Nicolas Dufresne
2017-12-20 9:24 ` Alexandre Courbot
2017-12-15 21:04 ` Nicolas Dufresne
2017-12-20 9:27 ` Alexandre Courbot
2018-01-12 11:45 ` Hans Verkuil
2018-01-15 8:24 ` Alexandre Courbot
2018-01-15 8:43 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171215075625.27028-8-acourbot@chromium.org \
--to=acourbot@chromium.org \
--cc=gustavo.padovan@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=posciak@chromium.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®