All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: linux-media@vger.kernel.org
Cc: kernel@pengutronix.de
Subject: [PATCH 06/10] media: coda: implement encoder frame size enumeration
Date: Mon,  8 Apr 2019 14:32:52 +0200	[thread overview]
Message-ID: <20190408123256.22868-6-p.zabel@pengutronix.de> (raw)
In-Reply-To: <20190408123256.22868-1-p.zabel@pengutronix.de>

The stateful encoder API requires VIDIOC_ENUM_FRAMESIZES to be
implemented.
Allow enumeration of supported frame sizes for encoding.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-common.c | 37 +++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index c0421f06ca48..943f003c26c4 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1077,6 +1077,42 @@ static int coda_decoder_cmd(struct file *file, void *fh,
 	return 0;
 }
 
+static int coda_enum_framesizes(struct file *file, void *fh,
+				struct v4l2_frmsizeenum *fsize)
+{
+	struct coda_ctx *ctx = fh_to_ctx(fh);
+	struct coda_q_data *q_data_dst;
+	const struct coda_codec *codec;
+
+	if (ctx->inst_type != CODA_INST_ENCODER)
+		return -ENOTTY;
+
+	if (fsize->index)
+		return -EINVAL;
+
+	if (coda_format_normalize_yuv(fsize->pixel_format) ==
+	    V4L2_PIX_FMT_YUV420) {
+		q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+		codec = coda_find_codec(ctx->dev, fsize->pixel_format,
+					q_data_dst->fourcc);
+	} else {
+		codec = coda_find_codec(ctx->dev, V4L2_PIX_FMT_YUV420,
+					fsize->pixel_format);
+	}
+	if (!codec)
+		return -EINVAL;
+
+	fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
+	fsize->stepwise.min_width = MIN_W;
+	fsize->stepwise.max_width = codec->max_w;
+	fsize->stepwise.step_width = 1;
+	fsize->stepwise.min_height = MIN_H;
+	fsize->stepwise.max_height = codec->max_h;
+	fsize->stepwise.step_height = 1;
+
+	return 0;
+}
+
 static int coda_enum_frameintervals(struct file *file, void *fh,
 				    struct v4l2_frmivalenum *f)
 {
@@ -1255,6 +1291,7 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
 	.vidioc_g_parm		= coda_g_parm,
 	.vidioc_s_parm		= coda_s_parm,
 
+	.vidioc_enum_framesizes	= coda_enum_framesizes,
 	.vidioc_enum_frameintervals = coda_enum_frameintervals,
 
 	.vidioc_subscribe_event = coda_subscribe_event,
-- 
2.20.1


  parent reply	other threads:[~2019-04-08 12:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08 12:32 [PATCH 01/10] media: coda: set codec earlier Philipp Zabel
2019-04-08 12:32 ` [PATCH 02/10] media: coda: remove mask from decoder h.264 level control Philipp Zabel
2019-04-08 12:32 ` [PATCH 03/10] media: coda: clear error return value before picture run Philipp Zabel
2019-04-08 12:32 ` [PATCH 04/10] media: coda: add min number of buffers controls Philipp Zabel
2019-04-08 12:32 ` [PATCH 05/10] media: coda: disable encoder command on decoder and vice versa Philipp Zabel
2019-04-08 12:32 ` Philipp Zabel [this message]
2019-04-08 12:32 ` [PATCH 07/10] media: coda: limit frame interval enumeration to supported frame sizes Philipp Zabel
2019-04-10 13:43   ` Hans Verkuil
2019-04-10 14:22     ` Philipp Zabel
2019-04-10 16:11       ` Nicolas Dufresne
2019-04-10 16:24         ` Hans Verkuil
2019-04-11  8:22           ` Philipp Zabel
2019-04-11 10:18             ` Hans Verkuil
2019-04-11 11:52               ` Ian Arkver
2019-04-11 12:00               ` Philipp Zabel
2019-04-11 15:53                 ` Nicolas Dufresne
2019-04-15  5:32                   ` Tomasz Figa
2019-04-08 12:32 ` [PATCH 08/10] media: coda: allow encoder to set colorimetry on the output queue Philipp Zabel
2019-04-10 13:48   ` Hans Verkuil
2019-04-10 14:23     ` Philipp Zabel
2019-04-08 12:32 ` [PATCH 09/10] media: coda: throw error on create_bufs with too small size Philipp Zabel
2019-04-08 12:32 ` [PATCH 10/10] media: coda: require all decoder command flags to be cleared Philipp Zabel
2019-04-09 16:57   ` Philipp Zabel
2019-04-10 13:53     ` 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=20190408123256.22868-6-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --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.