All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] media: coda: set codec earlier
@ 2019-04-08 12:32 Philipp Zabel
  2019-04-08 12:32 ` [PATCH 02/10] media: coda: remove mask from decoder h.264 level control Philipp Zabel
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Philipp Zabel @ 2019-04-08 12:32 UTC (permalink / raw)
  To: linux-media; +Cc: kernel

The chosen codec depends on the coded format, which is known as soon as
the S_FMT call on the coded queue. This allows to use the codec in
callbacks that may be called before start_streaming, such as buf_queue.

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

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index fa0b22fb7991..a403bc2995b4 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -764,6 +764,7 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv,
 {
 	struct coda_ctx *ctx = fh_to_ctx(priv);
 	struct coda_q_data *q_data_src;
+	const struct coda_codec *codec;
 	struct v4l2_rect r;
 	int ret;
 
@@ -784,6 +785,15 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv,
 	if (ctx->inst_type != CODA_INST_ENCODER)
 		return 0;
 
+	/* Setting the coded format determines the selected codec */
+	codec = coda_find_codec(ctx->dev, q_data_src->fourcc,
+				f->fmt.pix.pixelformat);
+	if (!codec) {
+		v4l2_err(&ctx->dev->v4l2_dev, "failed to determine codec\n");
+		return -EINVAL;
+	}
+	ctx->codec = codec;
+
 	ctx->colorspace = f->fmt.pix.colorspace;
 	ctx->xfer_func = f->fmt.pix.xfer_func;
 	ctx->ycbcr_enc = f->fmt.pix.ycbcr_enc;
@@ -796,6 +806,7 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 			      struct v4l2_format *f)
 {
 	struct coda_ctx *ctx = fh_to_ctx(priv);
+	const struct coda_codec *codec;
 	struct v4l2_format f_cap;
 	struct vb2_queue *dst_vq;
 	int ret;
@@ -811,6 +822,15 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 	if (ctx->inst_type != CODA_INST_DECODER)
 		return 0;
 
+	/* Setting the coded format determines the selected codec */
+	codec = coda_find_codec(ctx->dev, f->fmt.pix.pixelformat,
+				V4L2_PIX_FMT_YUV420);
+	if (!codec) {
+		v4l2_err(&ctx->dev->v4l2_dev, "failed to determine codec\n");
+		return -EINVAL;
+	}
+	ctx->codec = codec;
+
 	ctx->colorspace = f->fmt.pix.colorspace;
 	ctx->xfer_func = f->fmt.pix.xfer_func;
 	ctx->ycbcr_enc = f->fmt.pix.ycbcr_enc;
@@ -1680,14 +1700,6 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
 
 	ctx->gopcounter = ctx->params.gop_size - 1;
 
-	ctx->codec = coda_find_codec(ctx->dev, q_data_src->fourcc,
-				     q_data_dst->fourcc);
-	if (!ctx->codec) {
-		v4l2_err(v4l2_dev, "couldn't tell instance type.\n");
-		ret = -EINVAL;
-		goto err;
-	}
-
 	if (q_data_dst->fourcc == V4L2_PIX_FMT_JPEG)
 		ctx->params.gop_size = 1;
 	ctx->gopcounter = ctx->params.gop_size - 1;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2019-04-15  5:32 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 06/10] media: coda: implement encoder frame size enumeration Philipp Zabel
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

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.