All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dafna Hirschfeld <dafna3@gmail.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, helen.koike@collabora.com,
	Dafna Hirschfeld <dafna3@gmail.com>
Subject: [PATCH v5 21/23] media: vicodec: Register another node for stateless decoder
Date: Wed,  6 Mar 2019 13:13:41 -0800	[thread overview]
Message-ID: <20190306211343.15302-22-dafna3@gmail.com> (raw)
In-Reply-To: <20190306211343.15302-1-dafna3@gmail.com>

Add stateless decoder instance field to the dev struct and
register another node for the statelsess decoder.
The stateless API for the node will be implemented in further patches.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
---
 drivers/media/platform/vicodec/vicodec-core.c | 46 +++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c
index 6c9a41838d31..7733b22247b6 100644
--- a/drivers/media/platform/vicodec/vicodec-core.c
+++ b/drivers/media/platform/vicodec/vicodec-core.c
@@ -104,6 +104,7 @@ struct vicodec_dev {
 	struct v4l2_device	v4l2_dev;
 	struct vicodec_dev_instance stateful_enc;
 	struct vicodec_dev_instance stateful_dec;
+	struct vicodec_dev_instance stateless_dec;
 #ifdef CONFIG_MEDIA_CONTROLLER
 	struct media_device	mdev;
 #endif
@@ -114,6 +115,7 @@ struct vicodec_ctx {
 	struct v4l2_fh		fh;
 	struct vicodec_dev	*dev;
 	bool			is_enc;
+	bool			is_stateless;
 	spinlock_t		*lock;
 
 	struct v4l2_ctrl_handler hdl;
@@ -373,6 +375,9 @@ static void device_run(void *priv)
 
 	if (ctx->is_enc)
 		v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx);
+	else if (ctx->is_stateless)
+		v4l2_m2m_job_finish(dev->stateless_dec.m2m_dev,
+				    ctx->fh.m2m_ctx);
 	else
 		v4l2_m2m_job_finish(dev->stateful_dec.m2m_dev, ctx->fh.m2m_ctx);
 }
@@ -1494,8 +1499,14 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
 	src_vq->ops = &vicodec_qops;
 	src_vq->mem_ops = &vb2_vmalloc_memops;
 	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
-	src_vq->lock = ctx->is_enc ? &ctx->dev->stateful_enc.mutex :
-		&ctx->dev->stateful_dec.mutex;
+	if (ctx->is_enc)
+		src_vq->lock = &ctx->dev->stateful_enc.mutex;
+	else if (ctx->is_stateless)
+		src_vq->lock = &ctx->dev->stateless_dec.mutex;
+	else
+		src_vq->lock = &ctx->dev->stateful_dec.mutex;
+	src_vq->supports_requests = ctx->is_stateless;
+	src_vq->requires_requests = ctx->is_stateless;
 	ret = vb2_queue_init(src_vq);
 	if (ret)
 		return ret;
@@ -1564,6 +1575,8 @@ static int vicodec_open(struct file *file)
 
 	if (vfd == &dev->stateful_enc.vfd)
 		ctx->is_enc = true;
+	else if (vfd == &dev->stateless_dec.vfd)
+		ctx->is_stateless = true;
 
 	v4l2_fh_init(&ctx->fh, video_devdata(file));
 	file->private_data = &ctx->fh;
@@ -1576,6 +1589,8 @@ static int vicodec_open(struct file *file)
 			  1, 31, 1, 20);
 	v4l2_ctrl_new_std(hdl, &vicodec_ctrl_ops, V4L2_CID_FWHT_P_FRAME_QP,
 			  1, 31, 1, 20);
+	if (ctx->is_stateless)
+		v4l2_ctrl_new_custom(hdl, &vicodec_ctrl_stateless_state, NULL);
 	if (hdl->error) {
 		rc = hdl->error;
 		v4l2_ctrl_handler_free(hdl);
@@ -1615,6 +1630,10 @@ static int vicodec_open(struct file *file)
 		ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_enc.m2m_dev,
 						    ctx, &queue_init);
 		ctx->lock = &dev->stateful_enc.lock;
+	} else if (ctx->is_stateless) {
+		ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateless_dec.m2m_dev,
+						    ctx, &queue_init);
+		ctx->lock = &dev->stateless_dec.lock;
 	} else {
 		ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->stateful_dec.m2m_dev,
 						    ctx, &queue_init);
@@ -1751,6 +1770,10 @@ static int vicodec_probe(struct platform_device *pdev)
 			      "stateful-decoder", false))
 		goto unreg_sf_enc;
 
+	if (register_instance(dev, &dev->stateless_dec,
+			      "videdev-stateless-dec", false))
+		goto unreg_sf_dec;
+
 #ifdef CONFIG_MEDIA_CONTROLLER
 	ret = v4l2_m2m_register_media_controller(dev->stateful_enc.m2m_dev,
 						 &dev->stateful_enc.vfd,
@@ -1768,23 +1791,36 @@ static int vicodec_probe(struct platform_device *pdev)
 		goto unreg_m2m_sf_enc_mc;
 	}
 
+	ret = v4l2_m2m_register_media_controller(dev->stateless_dec.m2m_dev,
+						 &dev->stateless_dec.vfd,
+						 MEDIA_ENT_F_PROC_VIDEO_DECODER);
+	if (ret) {
+		v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller for stateless dec\n");
+		goto unreg_m2m_sf_dec_mc;
+	}
+
 	ret = media_device_register(&dev->mdev);
 	if (ret) {
 		v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n");
-		goto unreg_m2m_sf_dec_mc;
+		goto unreg_m2m_sl_dec_mc;
 	}
 #endif
 	return 0;
 
 #ifdef CONFIG_MEDIA_CONTROLLER
+unreg_m2m_sl_dec_mc:
+	v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev);
 unreg_m2m_sf_dec_mc:
 	v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev);
 unreg_m2m_sf_enc_mc:
 	v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev);
 unreg_m2m:
+	video_unregister_device(&dev->stateless_dec.vfd);
+	v4l2_m2m_release(dev->stateless_dec.m2m_dev);
+#endif
+unreg_sf_dec:
 	video_unregister_device(&dev->stateful_dec.vfd);
 	v4l2_m2m_release(dev->stateful_dec.m2m_dev);
-#endif
 unreg_sf_enc:
 	video_unregister_device(&dev->stateful_enc.vfd);
 	v4l2_m2m_release(dev->stateful_enc.m2m_dev);
@@ -1804,6 +1840,7 @@ static int vicodec_remove(struct platform_device *pdev)
 	media_device_unregister(&dev->mdev);
 	v4l2_m2m_unregister_media_controller(dev->stateful_enc.m2m_dev);
 	v4l2_m2m_unregister_media_controller(dev->stateful_dec.m2m_dev);
+	v4l2_m2m_unregister_media_controller(dev->stateless_dec.m2m_dev);
 	media_device_cleanup(&dev->mdev);
 #endif
 
@@ -1811,6 +1848,7 @@ static int vicodec_remove(struct platform_device *pdev)
 	v4l2_m2m_release(dev->stateful_dec.m2m_dev);
 	video_unregister_device(&dev->stateful_enc.vfd);
 	video_unregister_device(&dev->stateful_dec.vfd);
+	video_unregister_device(&dev->stateless_dec.vfd);
 	v4l2_device_unregister(&dev->v4l2_dev);
 
 	return 0;
-- 
2.17.1


  parent reply	other threads:[~2019-03-06 21:14 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 21:13 [PATCH v5 00/23] support for stateless decoder Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 01/23] vb2: add requires_requests bit for stateless codecs Dafna Hirschfeld
2019-03-12 15:29   ` Paul Kocialkowski
2019-03-20 10:21   ` Mauro Carvalho Chehab
2019-03-20 10:45     ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 02/23] videodev2.h: add V4L2_BUF_CAP_REQUIRES_REQUESTS Dafna Hirschfeld
2019-03-12 15:29   ` Paul Kocialkowski
2019-03-20 10:11   ` Mauro Carvalho Chehab
2019-03-20 10:39     ` Hans Verkuil
2019-03-20 11:42       ` Mauro Carvalho Chehab
2019-03-20 12:20         ` Hans Verkuil
2019-03-20 12:37           ` Mauro Carvalho Chehab
2019-03-20 12:41             ` Hans Verkuil
2019-03-20 13:09               ` Mauro Carvalho Chehab
2019-03-06 21:13 ` [PATCH v5 03/23] cedrus: set requires_requests Dafna Hirschfeld
2019-03-12 15:32   ` Paul Kocialkowski
2019-03-13 14:59     ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 04/23] media: vicodec: selection api should only check single buffer types Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 05/23] media: vicodec: upon release, call m2m release before freeing ctrl handler Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 06/23] media: v4l2-ctrl: v4l2_ctrl_request_setup returns with error upon failure Dafna Hirschfeld
2019-03-12 15:40   ` Paul Kocialkowski
2019-03-06 21:13 ` [PATCH v5 07/23] media: vicodec: change variable name for the return value of v4l2_fwht_encode Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 08/23] media: vicodec: bugfix - call v4l2_m2m_buf_copy_metadata also if decoding fails Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 09/23] media: vicodec: bugfix: free compressed_frame upon device release Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 10/23] media: vicodec: Move raw frame preparation code to a function Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 11/23] media: vicodec: add field 'buf' to fwht_raw_frame Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 12/23] media: vicodec: keep the ref frame according to the format in decoder Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 13/23] media: vicodec: Validate version dependent header values in a separate function Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 14/23] media: vicodec: rename v4l2_fwht_default_fmt to v4l2_fwht_find_nth_fmt Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 15/23] media: vicodec: Handle the case that the reference buffer is NULL Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 16/23] media: vicodec: add struct for encoder/decoder instance Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 17/23] media: vicodec: add documentation to V4L2_CID_FWHT_I/P_FRAME_QP Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 18/23] media: vicodec: add documentation to V4L2_CID_MPEG_VIDEO_FWHT_PARAMS Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 19/23] media: vicodec: add documentation to V4L2_PIX_FMT_FWHT_STATELESS Dafna Hirschfeld
2019-03-06 21:13 ` [PATCH v5 20/23] media: vicodec: Introducing stateless fwht defs and structs Dafna Hirschfeld
2019-03-13 14:42   ` [PATCH v5 24/23] v4l2-ioctl.c: add V4L2_PIX_FMT_FWHT_STATELESS to v4l_fill_fmtdesc Hans Verkuil
2019-03-06 21:13 ` Dafna Hirschfeld [this message]
2019-03-13 14:38   ` [PATCH v5 21/23] media: vicodec: Register another node for stateless decoder Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 22/23] media: vicodec: Add support " Dafna Hirschfeld
2019-03-13 14:37   ` Hans Verkuil
2019-03-06 21:13 ` [PATCH v5 23/23] media: vicodec: set pixelformat to V4L2_PIX_FMT_FWHT_STATELESS " Dafna Hirschfeld

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=20190306211343.15302-22-dafna3@gmail.com \
    --to=dafna3@gmail.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.