All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] media: coda: reuse coda_s_fmt_vid_cap to propagate format in coda_s_fmt_vid_out
@ 2018-04-27 16:19 Philipp Zabel
  2018-04-27 16:19 ` [PATCH v2 2/3] media: coda: do not try to propagate format if capture queue busy Philipp Zabel
  2018-04-27 16:19 ` [PATCH v2 3/3] media: coda: set colorimetry on coded queue Philipp Zabel
  0 siblings, 2 replies; 3+ messages in thread
From: Philipp Zabel @ 2018-04-27 16:19 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Tomasz Figa, Ian Arkver, Philipp Zabel

Instead of duplicating the same code, call into coda_s_fmt_vid_out to
propagate the output format to the capture queue.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1 [1]:
 - split out into a separate patch

[1] https://patchwork.linuxtv.org/patch/48266/

This is what coda_s_fmt_vid_cap currently looks like:

static int coda_s_fmt_vid_cap(struct file *file, void *priv,
			      struct v4l2_format *f)
{
	struct coda_ctx *ctx = fh_to_ctx(priv);
	struct coda_q_data *q_data_src;
	struct v4l2_rect r;
	int ret;

	ret = coda_try_fmt_vid_cap(file, priv, f);
	if (ret)
		return ret;

	q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
	r.left = 0;
	r.top = 0;
	r.width = q_data_src->width;
	r.height = q_data_src->height;

	return coda_s_fmt(ctx, f, &r);
}
---
 drivers/media/platform/coda/coda-common.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 04e35d70ce2e..40632df9e3e8 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -786,9 +786,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);
-	struct coda_q_data *q_data_src;
 	struct v4l2_format f_cap;
-	struct v4l2_rect r;
 	int ret;
 
 	ret = coda_try_fmt_vid_out(file, priv, f);
@@ -810,17 +808,7 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 	f_cap.fmt.pix.width = f->fmt.pix.width;
 	f_cap.fmt.pix.height = f->fmt.pix.height;
 
-	ret = coda_try_fmt_vid_cap(file, priv, &f_cap);
-	if (ret)
-		return ret;
-
-	q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
-	r.left = 0;
-	r.top = 0;
-	r.width = q_data_src->width;
-	r.height = q_data_src->height;
-
-	return coda_s_fmt(ctx, &f_cap, &r);
+	return coda_s_fmt_vid_cap(file, priv, &f_cap);
 }
 
 static int coda_reqbufs(struct file *file, void *priv,
-- 
2.17.0

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

* [PATCH v2 2/3] media: coda: do not try to propagate format if capture queue busy
  2018-04-27 16:19 [PATCH v2 1/3] media: coda: reuse coda_s_fmt_vid_cap to propagate format in coda_s_fmt_vid_out Philipp Zabel
@ 2018-04-27 16:19 ` Philipp Zabel
  2018-04-27 16:19 ` [PATCH v2 3/3] media: coda: set colorimetry on coded queue Philipp Zabel
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Zabel @ 2018-04-27 16:19 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Tomasz Figa, Ian Arkver, Philipp Zabel

The driver helpfully resets the capture queue format and selection
rectangle whenever output format is changed. This only works while
the capture queue is not busy.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1 [1]:
 - split out into a separate patch

[1] https://patchwork.linuxtv.org/patch/48266/
---
 drivers/media/platform/coda/coda-common.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 40632df9e3e8..d3e22c14fad4 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -787,6 +787,7 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 {
 	struct coda_ctx *ctx = fh_to_ctx(priv);
 	struct v4l2_format f_cap;
+	struct vb2_queue *dst_vq;
 	int ret;
 
 	ret = coda_try_fmt_vid_out(file, priv, f);
@@ -802,6 +803,19 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 	ctx->ycbcr_enc = f->fmt.pix.ycbcr_enc;
 	ctx->quantization = f->fmt.pix.quantization;
 
+	dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+	if (!dst_vq)
+		return -EINVAL;
+
+	/*
+	 * Setting the capture queue format is not possible while the capture
+	 * queue is still busy. This is not an error, but the user will have to
+	 * make sure themselves that the capture format is set correctly before
+	 * starting the output queue again.
+	 */
+	if (vb2_is_busy(dst_vq))
+		return 0;
+
 	memset(&f_cap, 0, sizeof(f_cap));
 	f_cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	coda_g_fmt(file, priv, &f_cap);
-- 
2.17.0

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

* [PATCH v2 3/3] media: coda: set colorimetry on coded queue
  2018-04-27 16:19 [PATCH v2 1/3] media: coda: reuse coda_s_fmt_vid_cap to propagate format in coda_s_fmt_vid_out Philipp Zabel
  2018-04-27 16:19 ` [PATCH v2 2/3] media: coda: do not try to propagate format if capture queue busy Philipp Zabel
@ 2018-04-27 16:19 ` Philipp Zabel
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Zabel @ 2018-04-27 16:19 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Tomasz Figa, Ian Arkver, Philipp Zabel

Do not set context colorimetry on the raw (OUTPUT) queue for encoders.
Always set colorimetry on the coded queue (CAPTURE for encoders, OUTPUT
for decoders).
This also skips propagation of capture queue format and selection
rectangle on S_FMT(OUTPUT) to the CAPTURE queue for encoders.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Added patch since v1 [1]:
 - remove automatic format propagation on S_FMT(OUT) for encoders
 - adding S_FMT(CAP) propagation from capture to output queue for
   encoders is left for a later time, this isn't even documented yet.

[1] https://patchwork.linuxtv.org/patch/48266/
---

 drivers/media/platform/coda/coda-common.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index d3e22c14fad4..c7631e117dd3 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -779,7 +779,19 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv,
 	r.width = q_data_src->width;
 	r.height = q_data_src->height;
 
-	return coda_s_fmt(ctx, f, &r);
+	ret = coda_s_fmt(ctx, f, &r);
+	if (ret)
+		return ret;
+
+	if (ctx->inst_type != CODA_INST_ENCODER)
+		return 0;
+
+	ctx->colorspace = f->fmt.pix.colorspace;
+	ctx->xfer_func = f->fmt.pix.xfer_func;
+	ctx->ycbcr_enc = f->fmt.pix.ycbcr_enc;
+	ctx->quantization = f->fmt.pix.quantization;
+
+	return 0;
 }
 
 static int coda_s_fmt_vid_out(struct file *file, void *priv,
@@ -798,6 +810,9 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
 	if (ret)
 		return ret;
 
+	if (ctx->inst_type != CODA_INST_DECODER)
+		return 0;
+
 	ctx->colorspace = f->fmt.pix.colorspace;
 	ctx->xfer_func = f->fmt.pix.xfer_func;
 	ctx->ycbcr_enc = f->fmt.pix.ycbcr_enc;
-- 
2.17.0

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

end of thread, other threads:[~2018-04-27 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 16:19 [PATCH v2 1/3] media: coda: reuse coda_s_fmt_vid_cap to propagate format in coda_s_fmt_vid_out Philipp Zabel
2018-04-27 16:19 ` [PATCH v2 2/3] media: coda: do not try to propagate format if capture queue busy Philipp Zabel
2018-04-27 16:19 ` [PATCH v2 3/3] media: coda: set colorimetry on coded queue Philipp Zabel

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.