All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] media: coda: jpeg: set buffer error flag when header parsing fails
@ 2022-04-06  8:53 Philipp Zabel
  2022-04-06  8:53 ` [PATCH 2/3] media: coda: jpeg: improve header parse error message Philipp Zabel
  2022-04-06  8:53 ` [PATCH 3/3] media: coda: jpeg: start streaming without valid header Philipp Zabel
  0 siblings, 2 replies; 3+ messages in thread
From: Philipp Zabel @ 2022-04-06  8:53 UTC (permalink / raw)
  To: linux-media; +Cc: Mauro Carvalho Chehab, kernel

If decoding fails because  the output buffer does not contain a
valid header, set the error flag on the returned capture buffer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/chips-media/coda-jpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/chips-media/coda-jpeg.c b/drivers/media/platform/chips-media/coda-jpeg.c
index a72f4655e5ad..9e3e05434b96 100644
--- a/drivers/media/platform/chips-media/coda-jpeg.c
+++ b/drivers/media/platform/chips-media/coda-jpeg.c
@@ -1353,7 +1353,7 @@ static int coda9_jpeg_prepare_decode(struct coda_ctx *ctx)
 		src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
 		dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
 		v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
-		v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
+		v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR);
 
 		v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx);
 		return ret;
-- 
2.30.2


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

* [PATCH 2/3] media: coda: jpeg: improve header parse error message
  2022-04-06  8:53 [PATCH 1/3] media: coda: jpeg: set buffer error flag when header parsing fails Philipp Zabel
@ 2022-04-06  8:53 ` Philipp Zabel
  2022-04-06  8:53 ` [PATCH 3/3] media: coda: jpeg: start streaming without valid header Philipp Zabel
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Zabel @ 2022-04-06  8:53 UTC (permalink / raw)
  To: linux-media; +Cc: Mauro Carvalho Chehab, kernel

If JPEG header parsing fails, output a single message instead of two
messages that say the same thing.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/chips-media/coda-common.c | 6 +-----
 drivers/media/platform/chips-media/coda-jpeg.c   | 6 ++----
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/chips-media/coda-common.c b/drivers/media/platform/chips-media/coda-common.c
index a57822b05070..9000377e592f 100644
--- a/drivers/media/platform/chips-media/coda-common.c
+++ b/drivers/media/platform/chips-media/coda-common.c
@@ -2012,12 +2012,8 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
 		if (q_data_src->fourcc == V4L2_PIX_FMT_JPEG) {
 			buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
 			ret = coda_jpeg_decode_header(ctx, &buf->vb2_buf);
-			if (ret < 0) {
-				v4l2_err(v4l2_dev,
-					 "failed to decode JPEG header: %d\n",
-					 ret);
+			if (ret < 0)
 				goto err;
-			}
 
 			q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
 			q_data_dst->width = round_up(q_data_src->width, 16);
diff --git a/drivers/media/platform/chips-media/coda-jpeg.c b/drivers/media/platform/chips-media/coda-jpeg.c
index 9e3e05434b96..155373ad73a4 100644
--- a/drivers/media/platform/chips-media/coda-jpeg.c
+++ b/drivers/media/platform/chips-media/coda-jpeg.c
@@ -283,7 +283,8 @@ int coda_jpeg_decode_header(struct coda_ctx *ctx, struct vb2_buffer *vb)
 
 	ret = v4l2_jpeg_parse_header(buf, len, &header);
 	if (ret < 0) {
-		v4l2_err(&dev->v4l2_dev, "failed to parse header\n");
+		v4l2_err(&dev->v4l2_dev, "failed to parse JPEG header: %pe\n",
+			 ERR_PTR(ret));
 		return ret;
 	}
 
@@ -1347,9 +1348,6 @@ static int coda9_jpeg_prepare_decode(struct coda_ctx *ctx)
 
 	ret = coda_jpeg_decode_header(ctx, &src_buf->vb2_buf);
 	if (ret < 0) {
-		v4l2_err(&dev->v4l2_dev, "failed to decode JPEG header: %d\n",
-			 ret);
-
 		src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
 		dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
 		v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
-- 
2.30.2


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

* [PATCH 3/3] media: coda: jpeg: start streaming without valid header
  2022-04-06  8:53 [PATCH 1/3] media: coda: jpeg: set buffer error flag when header parsing fails Philipp Zabel
  2022-04-06  8:53 ` [PATCH 2/3] media: coda: jpeg: improve header parse error message Philipp Zabel
@ 2022-04-06  8:53 ` Philipp Zabel
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Zabel @ 2022-04-06  8:53 UTC (permalink / raw)
  To: linux-media; +Cc: Mauro Carvalho Chehab, kernel

Stop bailing out on JPEG header parsing errors during streamon.
This allows userspace to provide valid output buffers later and
fixes a v4l2-compliance streaming test failure:

		fail: v4l2-test-buffers.cpp(1429): node->streamon(q.g_type())
	test MMAP (no poll): FAIL

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

diff --git a/drivers/media/platform/chips-media/coda-common.c b/drivers/media/platform/chips-media/coda-common.c
index 9000377e592f..63adbbdc1638 100644
--- a/drivers/media/platform/chips-media/coda-common.c
+++ b/drivers/media/platform/chips-media/coda-common.c
@@ -2011,9 +2011,13 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
 		 */
 		if (q_data_src->fourcc == V4L2_PIX_FMT_JPEG) {
 			buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
-			ret = coda_jpeg_decode_header(ctx, &buf->vb2_buf);
-			if (ret < 0)
-				goto err;
+			coda_jpeg_decode_header(ctx, &buf->vb2_buf);
+			/*
+			 * We have to start streaming even if the first buffer
+			 * does not contain a valid JPEG image. The error will
+			 * be caught during device run and will be signalled
+			 * via the capture buffer error flag.
+			 */
 
 			q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
 			q_data_dst->width = round_up(q_data_src->width, 16);
-- 
2.30.2


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

end of thread, other threads:[~2022-04-06 12:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  8:53 [PATCH 1/3] media: coda: jpeg: set buffer error flag when header parsing fails Philipp Zabel
2022-04-06  8:53 ` [PATCH 2/3] media: coda: jpeg: improve header parse error message Philipp Zabel
2022-04-06  8:53 ` [PATCH 3/3] media: coda: jpeg: start streaming without valid header 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.