public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
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 <pawel@osciak.com>,
	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 8/9] [media] vivid: add jobs API support for capture device
Date: Thu, 28 Sep 2017 18:50:26 +0900	[thread overview]
Message-ID: <20170928095027.127173-9-acourbot@chromium.org> (raw)
In-Reply-To: <20170928095027.127173-1-acourbot@chromium.org>

Add support for jobs in the vivid capture device, using the generic
state handler.

Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
---
 drivers/media/platform/vivid/vivid-core.c        | 16 ++++++++++++++++
 drivers/media/platform/vivid/vivid-core.h        |  2 ++
 drivers/media/platform/vivid/vivid-kthread-cap.c |  5 +++++
 3 files changed, 23 insertions(+)

diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
index ef344b9a48af..161c2199d2aa 100644
--- a/drivers/media/platform/vivid/vivid-core.c
+++ b/drivers/media/platform/vivid/vivid-core.c
@@ -35,6 +35,7 @@
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-event.h>
+#include <media/v4l2-job-generic.h>
 
 #include "vivid-core.h"
 #include "vivid-vid-common.h"
@@ -639,6 +640,14 @@ static void vivid_dev_release(struct v4l2_device *v4l2_dev)
 	kfree(dev);
 }
 
+void vivid_process_active_job(struct v4l2_job_state_handler *hdl)
+{
+	struct vivid_dev *dev = container_of(hdl, struct vivid_dev,
+					     state_hdl_vid_cap.base);
+
+	vb2_queue_active_job_buffers(&dev->vb_vid_cap_q);
+}
+
 static int vivid_create_instance(struct platform_device *pdev, int inst)
 {
 	static const struct v4l2_dv_timings def_dv_timings =
@@ -1071,6 +1080,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
 		q->min_buffers_needed = 2;
 		q->lock = &dev->mutex;
 		q->dev = dev->v4l2_dev.dev;
+		q->state_handler = &dev->state_hdl_vid_cap.base;
 
 		ret = vb2_queue_init(q);
 		if (ret)
@@ -1185,6 +1195,12 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
 		vfd->lock = &dev->mutex;
 		video_set_drvdata(vfd, dev);
 
+		ret = v4l2_job_generic_init(&dev->state_hdl_vid_cap,
+					   vivid_process_active_job, NULL, vfd);
+		if (ret)
+			return ret;
+
+
 #ifdef CONFIG_VIDEO_VIVID_CEC
 		if (in_type_counter[HDMI]) {
 			struct cec_adapter *adap;
diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h
index 5cdf95bdc4d1..c4014816beb7 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -28,6 +28,7 @@
 #include <media/v4l2-dev.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-tpg.h>
+#include <media/v4l2-job-generic.h>
 #include "vivid-rds-gen.h"
 #include "vivid-vbi-gen.h"
 
@@ -156,6 +157,7 @@ struct vivid_dev {
 	struct v4l2_ctrl_handler	ctrl_hdl_loop_cap;
 	struct video_device		vid_cap_dev;
 	struct v4l2_ctrl_handler	ctrl_hdl_vid_cap;
+	struct v4l2_generic_state_handler state_hdl_vid_cap;
 	struct video_device		vid_out_dev;
 	struct v4l2_ctrl_handler	ctrl_hdl_vid_out;
 	struct video_device		vbi_cap_dev;
diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 6ca71aabb576..b31ebfa55eca 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -683,6 +683,7 @@ static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs)
 {
 	struct vivid_buffer *vid_cap_buf = NULL;
 	struct vivid_buffer *vbi_cap_buf = NULL;
+	bool vid_job_complete;
 
 	dprintk(dev, 1, "Video Capture Thread Tick\n");
 
@@ -700,6 +701,7 @@ static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs)
 	if (!list_empty(&dev->vid_cap_active)) {
 		vid_cap_buf = list_entry(dev->vid_cap_active.next, struct vivid_buffer, list);
 		list_del(&vid_cap_buf->list);
+		vid_job_complete = list_empty(&dev->vid_cap_active);
 	}
 	if (!list_empty(&dev->vbi_cap_active)) {
 		if (dev->field_cap != V4L2_FIELD_ALTERNATE ||
@@ -729,6 +731,9 @@ static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs)
 				VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
 		dprintk(dev, 2, "vid_cap buffer %d done\n",
 				vid_cap_buf->vb.vb2_buf.index);
+
+		if (vid_job_complete)
+			v4l2_jobqueue_job_finish(&dev->state_hdl_vid_cap.base);
 	}
 
 	if (vbi_cap_buf) {
-- 
2.14.2.822.g60be5d43e6-goog

  parent reply	other threads:[~2017-09-28  9:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28  9:50 [RFC PATCH 0/9] V4L2 Jobs API WIP Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 1/9] [media] v4l2-core: add v4l2_is_v4l2_file function Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 2/9] [media] v4l2-core: add core jobs API support Alexandre Courbot
2017-10-16 10:01   ` Hans Verkuil
2017-10-23  8:35     ` Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 3/9] [media] videobuf2: add support for jobs API Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 4/9] [media] v4l2-ctrls: " Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 5/9] [media] v4l2-job: add generic jobs ops Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 6/9] [media] m2m: add generic support for jobs API Alexandre Courbot
2017-09-28  9:50 ` [RFC PATCH 7/9] [media] vim2m: add jobs API support Alexandre Courbot
2017-09-28  9:50 ` Alexandre Courbot [this message]
2017-09-28  9:50 ` [RFC PATCH 9/9] [media] document jobs API Alexandre Courbot
2017-10-16 11:06 ` [RFC PATCH 0/9] V4L2 Jobs API WIP Hans Verkuil
2017-10-23  8:36   ` Alexandre Courbot
2017-10-23 19:03   ` Gustavo Padovan
2017-10-19 14:43 ` Sakari Ailus
2017-10-23  8:45   ` Alexandre Courbot
2017-10-25 15:48     ` Laurent Pinchart
2017-10-25 16:19       ` Hans Verkuil
2017-10-25 23:06         ` Laurent Pinchart
2017-10-26  3:08       ` Tomasz Figa
2017-10-26  2:49   ` Tomasz Figa

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=20170928095027.127173-9-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=pawel@osciak.com \
    --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